spinto-jekyll 0.11.2.1 → 0.11.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/jekyll CHANGED
@@ -127,6 +127,10 @@ opts = OptionParser.new do |opts|
127
127
  end
128
128
  end
129
129
 
130
+ opts.on("--preview", "Publish posts that are from the future or marked unpublished") do
131
+ options['preview'] = true
132
+ end
133
+
130
134
  opts.on("--url [URL]", "Set custom site.url") do |url|
131
135
  options['url'] = url
132
136
  end
data/lib/jekyll/site.rb CHANGED
@@ -3,9 +3,10 @@ require 'set'
3
3
  module Jekyll
4
4
 
5
5
  class Site
6
- attr_accessor :config, :layouts, :posts, :pages, :static_files,
6
+ attr_accessor :config, :layouts, :posts, :unpublished_posts, :pages, :static_files,
7
7
  :categories, :exclude, :include, :source, :dest, :lsi, :pygments,
8
- :permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts
8
+ :permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
9
+ :preview
9
10
 
10
11
  attr_accessor :converters, :generators
11
12
 
@@ -26,6 +27,7 @@ module Jekyll
26
27
  self.include = config['include'] || []
27
28
  self.future = config['future']
28
29
  self.limit_posts = config['limit_posts'] || nil
30
+ self.preview = config['preview']
29
31
 
30
32
  self.reset
31
33
  self.setup
@@ -47,17 +49,18 @@ module Jekyll
47
49
  #
48
50
  # Returns nothing
49
51
  def reset
50
- self.time = if self.config['time']
51
- Time.parse(self.config['time'].to_s)
52
- else
53
- Time.now
54
- end
55
- self.layouts = {}
56
- self.posts = []
57
- self.pages = []
58
- self.static_files = []
59
- self.categories = Hash.new { |hash, key| hash[key] = [] }
60
- self.tags = Hash.new { |hash, key| hash[key] = [] }
52
+ self.time = if self.config['time']
53
+ Time.parse(self.config['time'].to_s)
54
+ else
55
+ Time.now
56
+ end
57
+ self.layouts = {}
58
+ self.posts = []
59
+ self.unpublished_posts = []
60
+ self.pages = []
61
+ self.static_files = []
62
+ self.categories = Hash.new { |hash, key| hash[key] = [] }
63
+ self.tags = Hash.new { |hash, key| hash[key] = [] }
61
64
 
62
65
  if !self.limit_posts.nil? && self.limit_posts < 1
63
66
  raise ArgumentError, "Limit posts must be nil or >= 1"
@@ -169,6 +172,8 @@ module Jekyll
169
172
  self.posts << post
170
173
  post.categories.each { |c| self.categories[c] << post }
171
174
  post.tags.each { |c| self.tags[c] << post }
175
+ else
176
+ self.unpublished_posts << post
172
177
  end
173
178
  end
174
179
  end
@@ -198,6 +203,12 @@ module Jekyll
198
203
  self.posts.each do |post|
199
204
  post.render(self.layouts, site_payload)
200
205
  end
206
+
207
+ if self.preview
208
+ self.unpublished_posts.sort.each do |post|
209
+ post.render(self.layouts, site_payload)
210
+ end
211
+ end
201
212
 
202
213
  self.pages.each do |page|
203
214
  page.render(self.layouts, site_payload)
@@ -224,6 +235,11 @@ module Jekyll
224
235
  self.posts.each do |post|
225
236
  files << post.destination(self.dest)
226
237
  end
238
+ if self.preview
239
+ self.unpublished_posts.each do |post|
240
+ files << post.destination(self.dest)
241
+ end
242
+ end
227
243
  self.pages.each do |page|
228
244
  files << page.destination(self.dest)
229
245
  end
@@ -248,6 +264,11 @@ module Jekyll
248
264
  self.posts.each do |post|
249
265
  post.write(self.dest)
250
266
  end
267
+ if self.preview
268
+ self.unpublished_posts.each do |post|
269
+ post.write(self.dest)
270
+ end
271
+ end
251
272
  self.pages.each do |page|
252
273
  page.write(self.dest)
253
274
  end
data/lib/spinto-jekyll.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SpintoJekyll
2
- VERSION = '0.11.2.1'
2
+ VERSION = '0.11.2.2'
3
3
  end
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
 
6
6
  s.name = 'spinto-jekyll'
7
- s.version = '0.11.2.1'
7
+ s.version = '0.11.2.2'
8
8
  s.date = '2012-02-23'
9
9
  s.rubyforge_project = 'spinto-jekyll'
10
10
 
@@ -69,4 +69,25 @@ class TestGeneratedSite < Test::Unit::TestCase
69
69
  end
70
70
  end
71
71
  end
72
+
73
+ context "generating with preview" do
74
+ setup do
75
+ clear_dest
76
+ stub(Jekyll).configuration do
77
+ Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'preview' => true})
78
+ end
79
+
80
+ @site = Site.new(Jekyll.configuration)
81
+ @site.process
82
+ @index = File.read(dest_dir('index.html'))
83
+ end
84
+
85
+ should "publishes unpublished posts" do
86
+ published = Dir[dest_dir('publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
87
+
88
+ assert_equal 2, published.size
89
+ assert_equal %w{ not-published.html published.html}, published
90
+ end
91
+
92
+ end
72
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinto-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2.1
4
+ version: 0.11.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-02-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: liquid
17
- requirement: &2152944140 !ruby/object:Gem::Requirement
17
+ requirement: &2152664140 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '2.3'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152944140
25
+ version_requirements: *2152664140
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: classifier
28
- requirement: &2152941940 !ruby/object:Gem::Requirement
28
+ requirement: &2152662920 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '1.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2152941940
36
+ version_requirements: *2152662920
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: directory_watcher
39
- requirement: &2152937700 !ruby/object:Gem::Requirement
39
+ requirement: &2152661180 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '1.1'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2152937700
47
+ version_requirements: *2152661180
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: maruku
50
- requirement: &2152953660 !ruby/object:Gem::Requirement
50
+ requirement: &2152660000 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0.5'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2152953660
58
+ version_requirements: *2152660000
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: kramdown
61
- requirement: &2152952820 !ruby/object:Gem::Requirement
61
+ requirement: &2152678020 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0.13'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2152952820
69
+ version_requirements: *2152678020
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: albino
72
- requirement: &2152952040 !ruby/object:Gem::Requirement
72
+ requirement: &2152674740 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '1.3'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *2152952040
80
+ version_requirements: *2152674740
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rake
83
- requirement: &2152950180 !ruby/object:Gem::Requirement
83
+ requirement: &2152672500 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0.9'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *2152950180
91
+ version_requirements: *2152672500
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: rdoc
94
- requirement: &2152948740 !ruby/object:Gem::Requirement
94
+ requirement: &2152671540 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ~>
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '3.11'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *2152948740
102
+ version_requirements: *2152671540
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: redgreen
105
- requirement: &2152947100 !ruby/object:Gem::Requirement
105
+ requirement: &2152686840 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ~>
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '1.2'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *2152947100
113
+ version_requirements: *2152686840
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: shoulda
116
- requirement: &2152962760 !ruby/object:Gem::Requirement
116
+ requirement: &2152685520 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ~>
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: '2.11'
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *2152962760
124
+ version_requirements: *2152685520
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rr
127
- requirement: &2152960680 !ruby/object:Gem::Requirement
127
+ requirement: &2152715560 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ~>
@@ -132,10 +132,10 @@ dependencies:
132
132
  version: '1.0'
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *2152960680
135
+ version_requirements: *2152715560
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: cucumber
138
- requirement: &2152958880 !ruby/object:Gem::Requirement
138
+ requirement: &2152713820 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - =
@@ -143,10 +143,10 @@ dependencies:
143
143
  version: '1.1'
144
144
  type: :development
145
145
  prerelease: false
146
- version_requirements: *2152958880
146
+ version_requirements: *2152713820
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: RedCloth
149
- requirement: &2152957820 !ruby/object:Gem::Requirement
149
+ requirement: &2152711540 !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
152
152
  - - ~>
@@ -154,10 +154,10 @@ dependencies:
154
154
  version: '4.2'
155
155
  type: :development
156
156
  prerelease: false
157
- version_requirements: *2152957820
157
+ version_requirements: *2152711540
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: rdiscount
160
- requirement: &2152975620 !ruby/object:Gem::Requirement
160
+ requirement: &2152710760 !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
163
163
  - - ~>
@@ -165,10 +165,10 @@ dependencies:
165
165
  version: '1.6'
166
166
  type: :development
167
167
  prerelease: false
168
- version_requirements: *2152975620
168
+ version_requirements: *2152710760
169
169
  - !ruby/object:Gem::Dependency
170
170
  name: redcarpet
171
- requirement: &2152973400 !ruby/object:Gem::Requirement
171
+ requirement: &2152709460 !ruby/object:Gem::Requirement
172
172
  none: false
173
173
  requirements:
174
174
  - - ~>
@@ -176,7 +176,7 @@ dependencies:
176
176
  version: '1.9'
177
177
  type: :development
178
178
  prerelease: false
179
- version_requirements: *2152973400
179
+ version_requirements: *2152709460
180
180
  description: Jekyll is a simple, blog aware, static site generator.
181
181
  email: matt.beale@madhatted.com
182
182
  executables: []
@@ -307,7 +307,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
307
307
  version: '0'
308
308
  segments:
309
309
  - 0
310
- hash: 1409829756844429741
310
+ hash: -2395415104563982128
311
311
  required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  none: false
313
313
  requirements: