middleman-blog-drafts 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.3.0
2
+ ====
3
+ * Add support to override blog-wide `build` config in draft's frontmatter
4
+
1
5
  0.2.0
2
6
  ====
3
7
  * Middleman 3.2 compatible release, complete overhaul
data/Gemfile CHANGED
@@ -19,4 +19,5 @@ group :development do
19
19
  gem "rdoc", "~> 3.9"
20
20
  gem "yard", "~> 0.8.0"
21
21
  gem "guard-cucumber"
22
+ gem 'pry'
22
23
  end
data/Gemfile.lock CHANGED
@@ -17,7 +17,7 @@ GIT
17
17
  PATH
18
18
  remote: .
19
19
  specs:
20
- middleman-blog-drafts (0.2.0)
20
+ middleman-blog-drafts (0.3.0)
21
21
  middleman-blog (~> 3.5.1)
22
22
  middleman-core (~> 3.2.2)
23
23
 
@@ -123,6 +123,7 @@ DEPENDENCIES
123
123
  kramdown
124
124
  middleman-blog-drafts!
125
125
  middleman-core!
126
+ pry
126
127
  rake (~> 10.1.0)
127
128
  rdoc (~> 3.9)
128
129
  sass
data/README.md CHANGED
@@ -44,13 +44,18 @@ middleman publish source/drafts/my-awesome-new-blog-post.markdown
44
44
  <% end %>
45
45
  ```
46
46
 
47
- As drafts won't be be available in the generated page by default, checking whether there are any is enough to decide whether to render the listing or not.
47
+ As drafts won't be be available in the generated page by default, checking
48
+ whether there are any is enough to decide whether to render the listing or not.
48
49
 
49
50
  ## Configuration options
50
51
 
51
- `build`: when `true`, the drafts will be available unconditionally. If not given, the drafts will be available in middlemans development mode and unavailable in `middleman build`.
52
+ `build`: when `true`, the drafts will be available unconditionally. If not
53
+ given, the drafts will be available in middleman's development mode and
54
+ unavailable in `middleman build`.
52
55
 
53
- This allows you to control the behaviour, for example if you have a preview instance of your blog. One way to do so would be to set it based on an environment variable:
56
+ This allows you to control the behaviour, for example if you have a preview
57
+ instance of your blog. One way to do so would be to set it based on an
58
+ environment variable:
54
59
 
55
60
  ```ruby
56
61
  activate :drafts do |drafts|
@@ -58,16 +63,36 @@ activate :drafts do |drafts|
58
63
  end
59
64
  ```
60
65
 
61
- This activates drafts in any environment where `SHOW_DRAFTS` is given and uses the default otherwise.
66
+ This activates drafts in any environment where `SHOW_DRAFTS` is given and uses
67
+ the default otherwise.
68
+
69
+ ## Frontmatter options
70
+
71
+ `build` can be overriden on a per-draft basis. For example if you want to make
72
+ a draft available to a small audience for proofreading, you may force the build
73
+ of that one draft with the following frontmatter:
74
+
75
+ ```yaml
76
+ ---
77
+ title: "Example blog post"
78
+ build: true
79
+ ---
80
+ ```
81
+
82
+ Likewise if you configure `build` to `true` for your entire blog, you may still
83
+ withhold single drafts from being built by setting `build: false` in the
84
+ frontmatter.
62
85
 
63
86
  ## Learn More
64
87
 
65
- See the [blog extension guide](http://middlemanapp.com/basics/blogging/) for detailed
88
+ See the [blog extension guide](http://middlemanapp.com/basics/blogging/) for
89
+ detailed
66
90
  information on configuring and using the blog extension.
67
91
 
68
92
  ## Credits
69
93
 
70
- Most of the code was based on the [middleman-blog](https://github.com/middleman/middleman-blog)
94
+ Most of the code was based on the
95
+ [middleman-blog](https://github.com/middleman/middleman-blog)
71
96
  gem itself, so many thanks to everyone that helped out with it.
72
97
 
73
98
  ## Contributing
@@ -1,5 +1,17 @@
1
1
  Feature: Building the site
2
- Scenario: Unpublished articles don't get built
2
+
3
+ Scenario: Default config builds only drafts with frontmatter build=true
3
4
  Given a fixture app "drafts-app"
4
5
  When I run `middleman build`
5
- Then the build directory should be empty
6
+ Then the following files should not exist:
7
+ | build/drafts/new-draft.html |
8
+ And the following files should exist:
9
+ | build/drafts/draft-build-true.html |
10
+
11
+ Scenario: Config build=true does not build drafts with frontmatter build=false
12
+ Given a fixture app "drafts-build-true-app"
13
+ When I run `middleman build`
14
+ Then the following files should exist:
15
+ | build/drafts/new-draft.html |
16
+ And the following files should not exist:
17
+ | build/drafts/draft-build-false.html |
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: "Draft with build = false"
3
+ build: false
4
+ ---
5
+ <h1>Draft with build = false</h1>
6
+ <p>Date: <%= current_article.date.iso8601 %></p>
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: "Draft with build = true"
3
+ build: true
4
+ ---
5
+ <h1>Draft with build = true</h1>
6
+ <p>Date: <%= current_article.date.iso8601 %></p>
@@ -0,0 +1,9 @@
1
+ require 'middleman-blog'
2
+
3
+ activate :blog do |b|
4
+ b.prefix = 'blog'
5
+ end
6
+
7
+ activate :drafts do |d|
8
+ d.build = true
9
+ end
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: "Draft with build = false"
3
+ build: false
4
+ ---
5
+ <h1>Draft with build = false</h1>
6
+ <p>Date: <%= current_article.date.iso8601 %></p>
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: "Draft with build = true"
3
+ build: true
4
+ ---
5
+ <h1>Draft with build = true</h1>
6
+ <p>Date: <%= current_article.date.iso8601 %></p>
@@ -0,0 +1,11 @@
1
+ ---
2
+ title: "Drafts List"
3
+ ---
4
+
5
+ <% if settings[:environment] == :development %>
6
+ <ul>
7
+ <% drafts.each do |draft| %>
8
+ <li><%= draft.title %></li>
9
+ <% end %>
10
+ </ul>
11
+ <% end %>
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: "New Draft Title"
3
+ ---
4
+ <h1>New Draft Title</h1>
5
+ <p>Date: <%= current_article.date.iso8601 %></p>
@@ -0,0 +1,8 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ </head>
5
+ <body>
6
+ <%= yield %>
7
+ </body>
8
+ </html>
@@ -83,7 +83,9 @@ module Middleman
83
83
  # @param [DraftArticle] draft A draft article
84
84
  # @return [Boolean] Whether it should be built
85
85
  def build?(draft)
86
- @app.environment == :development || @options.build
86
+ build = draft.data["build"]
87
+ build = @options.build if build == nil
88
+ @app.environment == :development || build
87
89
  end
88
90
 
89
91
  private
@@ -1,7 +1,7 @@
1
1
  module Middleman
2
2
  module Blog
3
3
  module Drafts
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-blog-drafts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-02-12 00:00:00.000000000 Z
13
+ date: 2014-02-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: middleman-core
@@ -69,10 +69,18 @@ files:
69
69
  - features/step_definitions/drafts_steps.rb
70
70
  - features/support/env.rb
71
71
  - fixtures/drafts-app/config.rb
72
+ - fixtures/drafts-app/source/drafts/draft-build-false.html.erb
73
+ - fixtures/drafts-app/source/drafts/draft-build-true.html.erb
72
74
  - fixtures/drafts-app/source/drafts/listing_drafts.html.erb
73
75
  - fixtures/drafts-app/source/drafts/new-draft.html.erb
74
76
  - fixtures/drafts-app/source/drafts/other-draft.html.erb
75
77
  - fixtures/drafts-app/source/layout.erb
78
+ - fixtures/drafts-build-true-app/config.rb
79
+ - fixtures/drafts-build-true-app/source/drafts/draft-build-false.html.erb
80
+ - fixtures/drafts-build-true-app/source/drafts/draft-build-true.html.erb
81
+ - fixtures/drafts-build-true-app/source/drafts/listing_drafts.html.erb
82
+ - fixtures/drafts-build-true-app/source/drafts/new-draft.html.erb
83
+ - fixtures/drafts-build-true-app/source/layout.erb
76
84
  - lib/middleman-blog-drafts.rb
77
85
  - lib/middleman-blog-drafts/blog_data_extensions.rb
78
86
  - lib/middleman-blog-drafts/commands/draft.rb
@@ -105,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
113
  version: '0'
106
114
  segments:
107
115
  - 0
108
- hash: -4520017841201487203
116
+ hash: 2863171145305893052
109
117
  requirements: []
110
118
  rubyforge_project:
111
119
  rubygems_version: 1.8.25
@@ -121,8 +129,16 @@ test_files:
121
129
  - features/step_definitions/drafts_steps.rb
122
130
  - features/support/env.rb
123
131
  - fixtures/drafts-app/config.rb
132
+ - fixtures/drafts-app/source/drafts/draft-build-false.html.erb
133
+ - fixtures/drafts-app/source/drafts/draft-build-true.html.erb
124
134
  - fixtures/drafts-app/source/drafts/listing_drafts.html.erb
125
135
  - fixtures/drafts-app/source/drafts/new-draft.html.erb
126
136
  - fixtures/drafts-app/source/drafts/other-draft.html.erb
127
137
  - fixtures/drafts-app/source/layout.erb
138
+ - fixtures/drafts-build-true-app/config.rb
139
+ - fixtures/drafts-build-true-app/source/drafts/draft-build-false.html.erb
140
+ - fixtures/drafts-build-true-app/source/drafts/draft-build-true.html.erb
141
+ - fixtures/drafts-build-true-app/source/drafts/listing_drafts.html.erb
142
+ - fixtures/drafts-build-true-app/source/drafts/new-draft.html.erb
143
+ - fixtures/drafts-build-true-app/source/layout.erb
128
144
  has_rdoc: