serif 0.3.3 → 0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/Gemfile.lock +12 -9
  2. data/README.md +57 -32
  3. data/bin/serif +12 -27
  4. data/lib/serif/admin_server.rb +48 -0
  5. data/lib/serif/content_file.rb +23 -29
  6. data/lib/serif/draft.rb +2 -4
  7. data/lib/serif/post.rb +30 -0
  8. data/lib/serif/site.rb +34 -26
  9. data/serif.gemspec +4 -3
  10. data/statics/skeleton/_config.yml +2 -46
  11. data/statics/templates/admin/bookmarks.liquid +56 -0
  12. data/statics/templates/admin/layout.liquid +4 -2
  13. data/test/config_spec.rb +7 -0
  14. data/test/draft_spec.rb +14 -0
  15. data/test/filters_spec.rb +5 -1
  16. data/test/markup_renderer_spec.rb +4 -0
  17. data/test/post_spec.rb +89 -0
  18. data/test/site_dir/_site/drafts/another-sample-draft/{9094f3a34ce2ecfe188ad813e0d3229d2488350fb0c5bca4f8b4bcfe7b11.html → 481da12b79709bfa0547fa9b5754c9506fbed29afd0334e07a8c95e76850.html} +1 -0
  19. data/test/site_dir/_site/drafts/sample-draft/{359dca7a7237a1317c5e8ac2d3a01cd29db433f4caeb0b2209484ca09a7a.html → a986a62ad5f6edd1fcac3d08f5b461b92bcb667a2af69505230c291d405c.html} +1 -0
  20. data/test/site_dir/_site/test-archive/2012/{11/index.html → 11.html} +0 -0
  21. data/test/site_dir/_site/test-archive/2012/{12/index.html → 12.html} +0 -0
  22. data/test/site_dir/_site/test-archive/2013/{01/index.html → 01.html} +0 -0
  23. data/test/site_dir/_site/test-archive/2013/{03/index.html → 03.html} +0 -0
  24. data/test/site_dir/_site/test-archive/2399/{01/index.html → 01.html} +0 -0
  25. data/test/site_dir/_site/test-archive/2400/{01/index.html → 01.html} +0 -0
  26. data/test/site_dir/_site/test-blog/final-post.html +1 -0
  27. data/test/site_dir/_site/test-blog/penultimate-post.html +1 -0
  28. data/test/site_dir/_site/test-blog/post-to-be-published-on-generate.html +1 -0
  29. data/test/site_dir/_site/test-blog/post-with-custom-layout.html +1 -0
  30. data/test/site_dir/_site/test-blog/sample-post.html +1 -0
  31. data/test/site_dir/_site/test-blog/second-post.html +1 -0
  32. data/test/site_dir/_trash/1363633154-autopublish-draft +5 -0
  33. data/test/site_dir/_trash/{1363284991-test-draft → 1363633154-test-draft} +1 -1
  34. data/test/site_generation_spec.rb +39 -11
  35. data/test/site_spec.rb +28 -0
  36. data/test/test_helper.rb +33 -1
  37. metadata +34 -17
  38. data/test/site_dir/_trash/1363284991-autopublish-draft +0 -5
@@ -8,6 +8,7 @@
8
8
 
9
9
  <p>The final post in the blog</p>
10
10
 
11
+
11
12
  <p><a href="http://twitter.com/share?text=Final+post&amp;url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Ffinal-post">Submit this to Twitter.</p>
12
13
 
13
14
  Previous post: Penultimate post
@@ -8,6 +8,7 @@
8
8
 
9
9
  <p>Penultimate post</p>
10
10
 
11
+
11
12
  <p><a href="http://twitter.com/share?text=Penultimate+post&amp;url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fpenultimate-post">Submit this to Twitter.</p>
12
13
 
13
14
  Previous post: Custom layout
@@ -8,6 +8,7 @@
8
8
 
9
9
  <p>some content</p>
10
10
 
11
+
11
12
  <p><a href="http://twitter.com/share?text=Some+draft+title&amp;url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fpost-to-be-published-on-generate">Submit this to Twitter.</p>
12
13
 
13
14
  Previous post: Sample post
@@ -5,6 +5,7 @@
5
5
 
6
6
  <p>Second post.</p>
7
7
 
8
+
8
9
  <p><a href="http://twitter.com/share?text=Custom+layout&amp;url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fpost-with-custom-layout">Submit this to Twitter.</p>
9
10
 
10
11
  Previous post: Second post
@@ -8,6 +8,7 @@
8
8
 
9
9
  <p>Just a sample post.</p>
10
10
 
11
+
11
12
  <p><a href="http://twitter.com/share?text=Sample+post&amp;url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fsample-post">Submit this to Twitter.</p>
12
13
 
13
14
 
@@ -8,6 +8,7 @@
8
8
 
9
9
  <p>Second post.</p>
10
10
 
11
+
11
12
  <p><a href="http://twitter.com/share?text=Second+post&amp;url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fsecond-post">Submit this to Twitter.</p>
12
13
 
13
14
  Previous post: Some draft title
@@ -0,0 +1,5 @@
1
+ title: Some draft title
2
+ Updated: 2013-03-18T18:59:14+00:00
3
+ Created: 2013-03-18T18:59:14+00:00
4
+
5
+ some content
@@ -1,4 +1,4 @@
1
1
  title: Some draft title
2
- Updated: 2013-03-14T18:16:31+00:00
2
+ Updated: 2013-03-18T18:59:14+00:00
3
3
 
4
4
  some content
@@ -11,12 +11,12 @@ describe Serif::Site do
11
11
 
12
12
  describe "site generation" do
13
13
  it "uses the permalinks in the config file for site generation" do
14
- subject.generate
14
+ capture_stdout { subject.generate }
15
15
  File.exist?(testing_dir("_site/test-blog/sample-post.html")).should be_true
16
16
  end
17
17
 
18
18
  it "reads the layout header for a non-post file and uses the appropriate layout file" do
19
- subject.generate
19
+ capture_stdout { subject.generate }
20
20
 
21
21
  # check it actually got generated
22
22
  File.exist?(testing_dir("_site/page-alt-layout.html")).should be_true
@@ -24,7 +24,7 @@ describe Serif::Site do
24
24
  end
25
25
 
26
26
  it "reads the layout header for a post file and uses the appropriate layout file" do
27
- subject.generate
27
+ capture_stdout { subject.generate }
28
28
 
29
29
  # check it actually got generated
30
30
  File.exist?(testing_dir("_site/test-blog/post-with-custom-layout.html")).should be_true
@@ -32,18 +32,18 @@ describe Serif::Site do
32
32
  end
33
33
 
34
34
  it "supports a smarty filter" do
35
- subject.generate
35
+ capture_stdout { subject.generate }
36
36
  File.read("_site/test-smarty-filter.html").should =~ /testing&rsquo;s for a &ldquo;heading&rsquo;s&rdquo; `with code` in it&hellip;/
37
37
  end
38
38
 
39
39
  it "correctly handles file_digest calls" do
40
- subject.generate
40
+ capture_stdout { subject.generate }
41
41
 
42
42
  File.read("_site/file-digest-test.html").strip.should == "f8390232f0c354a871f9ba0ed306163c\n.f8390232f0c354a871f9ba0ed306163c"
43
43
  end
44
44
 
45
45
  it "makes the previous and next posts available" do
46
- subject.generate
46
+ capture_stdout { subject.generate }
47
47
 
48
48
  contents = File.read("_site/test-blog/sample-post.html")
49
49
  previous_title = contents[/^Previous post: .+?$/]
@@ -65,7 +65,7 @@ describe Serif::Site do
65
65
  it "sets a draft_preview flag for preview urls" do
66
66
  preview_flag_pattern = /draftpreviewflagexists/
67
67
 
68
- subject.generate
68
+ capture_stdout { subject.generate }
69
69
 
70
70
  d = Serif::Draft.from_slug(subject, "sample-draft")
71
71
  preview_contents = File.read(testing_dir("_site/#{subject.private_url(d)}.html"))
@@ -76,7 +76,7 @@ describe Serif::Site do
76
76
  end
77
77
 
78
78
  it "creates draft preview files" do
79
- subject.generate
79
+ capture_stdout { subject.generate }
80
80
 
81
81
  Dir.exist?(testing_dir("_site/drafts")).should be_true
82
82
  Dir[File.join(testing_dir("_site/drafts/*"))].size.should == subject.drafts.size
@@ -94,10 +94,38 @@ describe Serif::Site do
94
94
  (subject.private_url(d) =~ /\A\/drafts\/#{d.slug}\/[a-z0-9]{60}\z/).should be_true
95
95
 
96
96
  # does not create more than one
97
- subject.generate
97
+ capture_stdout { subject.generate }
98
98
  Dir[File.join(testing_dir("_site/drafts/sample-draft"), "*.html")].size.should == 1
99
99
  end
100
100
 
101
+ context "for posts with an update: now header" do
102
+ around :each do |example|
103
+ begin
104
+ d = Serif::Draft.new(subject)
105
+ d.slug = "post-to-be-auto-updated"
106
+ d.title = "Testing title"
107
+ d.save("# some content")
108
+ d.publish!
109
+
110
+ @temporary_post = Serif::Post.from_slug(subject, d.slug)
111
+ @temporary_post.autoupdate = true
112
+ @temporary_post.save
113
+
114
+ example.run
115
+ ensure
116
+ FileUtils.rm(@temporary_post.path)
117
+ end
118
+ end
119
+
120
+ it "sets the updated header to the current time" do
121
+ t = Time.now + 30
122
+ Timecop.freeze(t) do
123
+ capture_stdout { subject.generate }
124
+ Serif::Post.from_slug(subject, @temporary_post.slug).updated.to_i.should == t.to_i
125
+ end
126
+ end
127
+ end
128
+
101
129
  context "for drafts with a publish: now header" do
102
130
  before :all do
103
131
  @time = Time.utc(2012, 12, 21, 15, 30, 00)
@@ -132,12 +160,12 @@ describe Serif::Site do
132
160
  end
133
161
 
134
162
  it "places the file in the published posts folder" do
135
- subject.generate
163
+ capture_stdout { subject.generate }
136
164
  File.exist?(testing_dir("_site/test-blog/#{@post.slug}.html")).should be_true
137
165
  end
138
166
 
139
167
  it "marks the creation time as the current time" do
140
- subject.generate
168
+ capture_stdout { subject.generate }
141
169
  Serif::Post.from_slug(subject, @post.slug).created.should == @time
142
170
  end
143
171
  end
@@ -61,6 +61,34 @@ describe Serif::Site do
61
61
  end
62
62
  end
63
63
 
64
+ describe "#archives" do
65
+ it "contains posts given in reverse chronological order" do
66
+ archives = subject.archives
67
+ archives[:posts].each_cons(2) do |a, b|
68
+ (a.created >= b.created).should be_true
69
+ end
70
+
71
+ archives[:years].each do |year|
72
+ year[:posts].each_cons(2) do |a, b|
73
+ (a.created >= b.created).should be_true
74
+ end
75
+
76
+ year[:months].each do |month|
77
+ month[:posts].each_cons(2) do |a, b|
78
+ (a.created >= b.created).should be_true
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ describe "#to_liquid" do
86
+ it "uses the value of #archives without modification" do
87
+ subject.should_receive(:archives).once
88
+ subject.to_liquid
89
+ end
90
+ end
91
+
64
92
  describe "#archive_url_for_date" do
65
93
  it "uses the archive URL format from the config to construct an archive URL string" do
66
94
  date = Date.parse("2012-01-02")
@@ -6,6 +6,26 @@ end
6
6
  # run tests in production mode so that file digests are enabled
7
7
  ENV["ENV"] = "production"
8
8
 
9
+ # workaround checking. here before loading our application to ensure
10
+ # we aren't testing against our own monkeypatches.
11
+
12
+ describe "date 'now' patch" do
13
+ # if this test fails, the monkey match on StandardFilters#date can be removed
14
+ it "is necessary" do
15
+ liquid_filter = Object.new
16
+ liquid_filter.extend(Liquid::StandardFilters)
17
+ (liquid_filter.date_orig("now", "%Y") rescue "").should_not == Time.now.year.to_s
18
+ end
19
+ end
20
+
21
+ describe "curly quote patch" do
22
+ # if this test fails, the workaround for the "markdown" filter can be removed
23
+ it "is necessary" do
24
+ renderer = Redcarpet::Markdown.new(Serif::MarkupRenderer)
25
+ renderer.render("something's here").should_not include("something&rsquo;s here")
26
+ end
27
+ end
28
+
9
29
  require "serif"
10
30
  require "fileutils"
11
31
  require "pathname"
@@ -17,4 +37,16 @@ def testing_dir(path = nil)
17
37
  full_path = File.join(File.dirname(__FILE__), "site_dir")
18
38
 
19
39
  path ? File.join(full_path, path) : full_path
20
- end
40
+ end
41
+
42
+ def capture_stdout
43
+ begin
44
+ $orig_stdout = $stdout
45
+ $stdout = StringIO.new
46
+ yield
47
+ $stdout.rewind
48
+ return $stdout.string
49
+ ensure
50
+ $stdout = $orig_stdout
51
+ end
52
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serif
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: '0.4'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-14 00:00:00.000000000 Z
12
+ date: 2013-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -108,13 +108,13 @@ dependencies:
108
108
  - !ruby/object:Gem::Version
109
109
  version: '2.4'
110
110
  - !ruby/object:Gem::Dependency
111
- name: slop
111
+ name: reverse_markdown
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: '3.3'
117
+ version: 0.4.3
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,23 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: '3.3'
125
+ version: 0.4.3
126
+ - !ruby/object:Gem::Dependency
127
+ name: nokogiri
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '1.5'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '1.5'
126
142
  - !ruby/object:Gem::Dependency
127
143
  name: timeout_cache
128
144
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +210,7 @@ dependencies:
194
210
  requirements:
195
211
  - - ~>
196
212
  - !ruby/object:Gem::Version
197
- version: 0.5.5
213
+ version: 0.6.1
198
214
  type: :development
199
215
  prerelease: false
200
216
  version_requirements: !ruby/object:Gem::Requirement
@@ -202,7 +218,7 @@ dependencies:
202
218
  requirements:
203
219
  - - ~>
204
220
  - !ruby/object:Gem::Version
205
- version: 0.5.5
221
+ version: 0.6.1
206
222
  description: Serif is a blogging system powered by markdown files and an optional
207
223
  admin interface complete with drag-and-drop image uploading.
208
224
  email:
@@ -225,6 +241,7 @@ files:
225
241
  - statics/templates/admin/edit_draft.liquid
226
242
  - statics/templates/admin/layout.liquid
227
243
  - statics/templates/admin/index.liquid
244
+ - statics/templates/admin/bookmarks.liquid
228
245
  - statics/templates/admin/edit_post.liquid
229
246
  - statics/skeleton/index.html
230
247
  - statics/skeleton/_templates/archive_page.html
@@ -257,14 +274,14 @@ files:
257
274
  - test/site_dir/page-header-but-no-layout.html
258
275
  - test/site_dir/test-stylesheet.css
259
276
  - test/site_dir/_config.yml
260
- - test/site_dir/_site/test-archive/2013/01/index.html
261
- - test/site_dir/_site/test-archive/2013/03/index.html
262
- - test/site_dir/_site/test-archive/2012/12/index.html
263
- - test/site_dir/_site/test-archive/2012/11/index.html
264
- - test/site_dir/_site/test-archive/2400/01/index.html
265
- - test/site_dir/_site/test-archive/2399/01/index.html
266
- - test/site_dir/_site/drafts/another-sample-draft/9094f3a34ce2ecfe188ad813e0d3229d2488350fb0c5bca4f8b4bcfe7b11.html
267
- - test/site_dir/_site/drafts/sample-draft/359dca7a7237a1317c5e8ac2d3a01cd29db433f4caeb0b2209484ca09a7a.html
277
+ - test/site_dir/_site/test-archive/2013/01.html
278
+ - test/site_dir/_site/test-archive/2013/03.html
279
+ - test/site_dir/_site/test-archive/2012/12.html
280
+ - test/site_dir/_site/test-archive/2012/11.html
281
+ - test/site_dir/_site/test-archive/2400/01.html
282
+ - test/site_dir/_site/test-archive/2399/01.html
283
+ - test/site_dir/_site/drafts/another-sample-draft/481da12b79709bfa0547fa9b5754c9506fbed29afd0334e07a8c95e76850.html
284
+ - test/site_dir/_site/drafts/sample-draft/a986a62ad5f6edd1fcac3d08f5b461b92bcb667a2af69505230c291d405c.html
268
285
  - test/site_dir/_site/index.html
269
286
  - test/site_dir/_site/file-digest-test.html
270
287
  - test/site_dir/_site/page-alt-layout.html
@@ -278,8 +295,8 @@ files:
278
295
  - test/site_dir/_site/test-blog/penultimate-post.html
279
296
  - test/site_dir/_site/test-smarty-filter.html
280
297
  - test/site_dir/_site/archive.html
281
- - test/site_dir/_trash/1363284991-test-draft
282
- - test/site_dir/_trash/1363284991-autopublish-draft
298
+ - test/site_dir/_trash/1363633154-autopublish-draft
299
+ - test/site_dir/_trash/1363633154-test-draft
283
300
  - test/site_dir/_posts/2013-03-07-post-with-custom-layout
284
301
  - test/site_dir/_posts/2012-01-05-sample-post
285
302
  - test/site_dir/_posts/2400-01-01-final-post
@@ -1,5 +0,0 @@
1
- title: Some draft title
2
- Updated: 2013-03-14T18:16:31+00:00
3
- Created: 2013-03-14T18:16:31+00:00
4
-
5
- some content