serif 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/serif/content_file.rb +10 -2
- data/serif.gemspec +2 -1
- data/test/content_file_spec.rb +15 -0
- data/test/draft_spec.rb +6 -0
- metadata +3 -27
- data/test/site_dir/_site/archive.html +0 -39
- data/test/site_dir/_site/drafts/another-sample-draft/893209b2ce83164321ca8f311a32a3c87399498377e1229e7ecc26ff850f.html +0 -17
- data/test/site_dir/_site/drafts/sample-draft/1b015cdf8a931d05f12b95c6a9ea308c6e006596d6ccae5849935e7aaf24.html +0 -17
- data/test/site_dir/_site/file-digest-test.html +0 -2
- data/test/site_dir/_site/index.html +0 -26
- data/test/site_dir/_site/page-alt-layout.html +0 -3
- data/test/site_dir/_site/page-header-but-no-layout.html +0 -8
- data/test/site_dir/_site/test-archive/2012/11.html +0 -16
- data/test/site_dir/_site/test-archive/2012/12.html +0 -16
- data/test/site_dir/_site/test-archive/2013/01.html +0 -16
- data/test/site_dir/_site/test-archive/2013/03.html +0 -16
- data/test/site_dir/_site/test-archive/2399/01.html +0 -16
- data/test/site_dir/_site/test-archive/2400/01.html +0 -16
- data/test/site_dir/_site/test-blog/final-post.html +0 -17
- data/test/site_dir/_site/test-blog/penultimate-post.html +0 -18
- data/test/site_dir/_site/test-blog/post-to-be-published-on-generate.html +0 -18
- data/test/site_dir/_site/test-blog/post-with-custom-layout.html +0 -13
- data/test/site_dir/_site/test-blog/sample-post.html +0 -18
- data/test/site_dir/_site/test-blog/second-post.html +0 -18
- data/test/site_dir/_site/test-smarty-filter.html +0 -10
- data/test/site_dir/_site/test-stylesheet.css +0 -3
- data/test/site_dir/_trash/1365433969-test-draft +0 -4
- data/test/site_dir/_trash/1365433970-autopublish-draft +0 -5
- data/test/site_dir/_trash/1365433970-test-draft +0 -4
data/lib/serif/content_file.rb
CHANGED
@@ -51,13 +51,21 @@ class ContentFile
|
|
51
51
|
@cached_headers = nil
|
52
52
|
end
|
53
53
|
|
54
|
-
# Returns true if the file is in the directory for draft content
|
54
|
+
# Returns true if the file is in the directory for draft content, or
|
55
|
+
# has no saved path yet.
|
55
56
|
def draft?
|
57
|
+
return true if !path
|
58
|
+
|
56
59
|
File.dirname(path) == File.join(site.directory, Draft.dirname)
|
57
60
|
end
|
58
61
|
|
59
|
-
# Returns true if the file is in the directory for published posts
|
62
|
+
# Returns true if the file is in the directory for published posts,
|
63
|
+
# false otherwise.
|
64
|
+
#
|
65
|
+
# If there is no path at all, returns false.
|
60
66
|
def published?
|
67
|
+
return false if !path
|
68
|
+
|
61
69
|
File.dirname(path) == File.join(site.directory, Post.dirname)
|
62
70
|
end
|
63
71
|
|
data/serif.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "serif"
|
3
|
-
s.version = "0.5.
|
3
|
+
s.version = "0.5.2"
|
4
4
|
s.authors = ["Adam Prescott"]
|
5
5
|
s.email = ["adam@aprescott.com"]
|
6
6
|
s.homepage = "https://github.com/aprescott/serif"
|
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.bindir = "bin"
|
12
12
|
s.executables = "serif"
|
13
13
|
s.test_files = Dir["test/*"]
|
14
|
+
s.required_ruby_version = ">= 1.9.3"
|
14
15
|
|
15
16
|
[
|
16
17
|
"rack", "~> 1.0",
|
data/test/content_file_spec.rb
CHANGED
@@ -36,6 +36,15 @@ describe Serif::ContentFile do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
describe "draft and published status" do
|
40
|
+
it "can handle a nil path" do
|
41
|
+
c = Serif::ContentFile.new(subject)
|
42
|
+
c.path.should be_nil
|
43
|
+
c.draft?.should be_true
|
44
|
+
c.published?.should be_false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
39
48
|
describe "draft?" do
|
40
49
|
it "is true if the file is in the _drafts directory" do
|
41
50
|
subject.drafts.each do |d|
|
@@ -51,6 +60,12 @@ describe Serif::ContentFile do
|
|
51
60
|
end
|
52
61
|
|
53
62
|
describe "published?" do
|
63
|
+
it "can handle a nil path" do
|
64
|
+
d = Serif::Post.new(subject)
|
65
|
+
d.draft?.should be_true
|
66
|
+
d.published?.should be_false
|
67
|
+
end
|
68
|
+
|
54
69
|
it "is true if the file is in the _posts directory" do
|
55
70
|
subject.posts.each do |p|
|
56
71
|
p.published?.should be_true
|
data/test/draft_spec.rb
CHANGED
@@ -246,6 +246,12 @@ describe Serif::Draft do
|
|
246
246
|
liq.key?(e).should be_true
|
247
247
|
end
|
248
248
|
end
|
249
|
+
|
250
|
+
context "for an initial draft" do
|
251
|
+
it "works fine" do
|
252
|
+
expect { Serif::Draft.new(@site).to_liquid }.to_not raise_error
|
253
|
+
end
|
254
|
+
end
|
249
255
|
end
|
250
256
|
|
251
257
|
describe "#save" do
|
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.5.
|
4
|
+
version: 0.5.2
|
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-
|
12
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -309,32 +309,8 @@ files:
|
|
309
309
|
- test/site_dir/_posts/2013-03-07-post-with-custom-layout
|
310
310
|
- test/site_dir/_posts/2399-01-01-penultimate-post
|
311
311
|
- test/site_dir/_posts/2400-01-01-final-post
|
312
|
-
- test/site_dir/_site/archive.html
|
313
|
-
- test/site_dir/_site/drafts/another-sample-draft/893209b2ce83164321ca8f311a32a3c87399498377e1229e7ecc26ff850f.html
|
314
|
-
- test/site_dir/_site/drafts/sample-draft/1b015cdf8a931d05f12b95c6a9ea308c6e006596d6ccae5849935e7aaf24.html
|
315
|
-
- test/site_dir/_site/file-digest-test.html
|
316
|
-
- test/site_dir/_site/index.html
|
317
|
-
- test/site_dir/_site/page-alt-layout.html
|
318
|
-
- test/site_dir/_site/page-header-but-no-layout.html
|
319
|
-
- test/site_dir/_site/test-archive/2012/11.html
|
320
|
-
- test/site_dir/_site/test-archive/2012/12.html
|
321
|
-
- test/site_dir/_site/test-archive/2013/01.html
|
322
|
-
- test/site_dir/_site/test-archive/2013/03.html
|
323
|
-
- test/site_dir/_site/test-archive/2399/01.html
|
324
|
-
- test/site_dir/_site/test-archive/2400/01.html
|
325
|
-
- test/site_dir/_site/test-blog/final-post.html
|
326
|
-
- test/site_dir/_site/test-blog/penultimate-post.html
|
327
|
-
- test/site_dir/_site/test-blog/post-to-be-published-on-generate.html
|
328
|
-
- test/site_dir/_site/test-blog/post-with-custom-layout.html
|
329
|
-
- test/site_dir/_site/test-blog/sample-post.html
|
330
|
-
- test/site_dir/_site/test-blog/second-post.html
|
331
|
-
- test/site_dir/_site/test-smarty-filter.html
|
332
|
-
- test/site_dir/_site/test-stylesheet.css
|
333
312
|
- test/site_dir/_templates/archive_page.html
|
334
313
|
- test/site_dir/_templates/post.html
|
335
|
-
- test/site_dir/_trash/1365433969-test-draft
|
336
|
-
- test/site_dir/_trash/1365433970-autopublish-draft
|
337
|
-
- test/site_dir/_trash/1365433970-test-draft
|
338
314
|
- test/site_dir/archive.html
|
339
315
|
- test/site_dir/file-digest-test.html
|
340
316
|
- test/site_dir/index.html
|
@@ -362,7 +338,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
362
338
|
requirements:
|
363
339
|
- - ! '>='
|
364
340
|
- !ruby/object:Gem::Version
|
365
|
-
version:
|
341
|
+
version: 1.9.3
|
366
342
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
367
343
|
none: false
|
368
344
|
requirements:
|
@@ -1,39 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: </title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<h1>
|
11
|
-
<a href="/test-archive/2400/01">January 2400</a>
|
12
|
-
</h1>
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
<h1>
|
17
|
-
<a href="/test-archive/2399/01">January 2399</a>
|
18
|
-
</h1>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<h1>
|
23
|
-
<a href="/test-archive/2013/03">March 2013</a>
|
24
|
-
</h1>
|
25
|
-
|
26
|
-
<h1>
|
27
|
-
<a href="/test-archive/2013/01">January 2013</a>
|
28
|
-
</h1>
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
<h1>
|
33
|
-
<a href="/test-archive/2012/12">December 2012</a>
|
34
|
-
</h1>
|
35
|
-
|
36
|
-
<h1>
|
37
|
-
<a href="/test-archive/2012/11">November 2012</a>
|
38
|
-
</h1>
|
39
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: another sample draft</title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<p>draftpreviewflagexists</p>
|
9
|
-
|
10
|
-
<h2>another sample draft</h2>
|
11
|
-
|
12
|
-
<p>another-sample-draft</p>
|
13
|
-
|
14
|
-
|
15
|
-
<p><a href="http://twitter.com/share?text=another+sample+draft&url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fanother-sample-draft">Submit this to Twitter.</p>
|
16
|
-
|
17
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: Sample draft</title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<p>draftpreviewflagexists</p>
|
9
|
-
|
10
|
-
<h2>Sample draft</h2>
|
11
|
-
|
12
|
-
<p>Just a sample draft.</p>
|
13
|
-
|
14
|
-
|
15
|
-
<p><a href="http://twitter.com/share?text=Sample+draft&url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fsample-draft">Submit this to Twitter.</p>
|
16
|
-
|
17
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: </title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<h2>Posts</h2>
|
9
|
-
|
10
|
-
<p>There are 6 posts:</p>
|
11
|
-
|
12
|
-
<ul>
|
13
|
-
|
14
|
-
<li><a href="/test-blog/final-post">Final post</a> (posted 2400-01-01T00:00:00Z)</li>
|
15
|
-
|
16
|
-
<li><a href="/test-blog/penultimate-post">Penultimate post</a> (posted 2399-01-01T00:00:00Z)</li>
|
17
|
-
|
18
|
-
<li><a href="/test-blog/post-with-custom-layout">Custom layout</a> (posted 2013-03-07T00:00:00Z)</li>
|
19
|
-
|
20
|
-
<li><a href="/test-blog/second-post">Second post</a> (posted 2013-01-01T00:00:00Z)</li>
|
21
|
-
|
22
|
-
<li><a href="/test-blog/post-to-be-published-on-generate">Some draft title</a> (posted 2012-12-21T15:30:00Z)</li>
|
23
|
-
|
24
|
-
<li><a href="/test-blog/sample-post">Sample post</a> (posted 2012-11-21T17:07:09Z)</li>
|
25
|
-
|
26
|
-
</ul>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: Final post</title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
<p>post_page flag set for layout</p>
|
7
|
-
|
8
|
-
|
9
|
-
<p>post_page flag set for template</p>
|
10
|
-
<h2>Final post</h2>
|
11
|
-
|
12
|
-
<p>The final post in the blog</p>
|
13
|
-
|
14
|
-
|
15
|
-
<p><a href="http://twitter.com/share?text=Final+post&url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Ffinal-post">Submit this to Twitter.</p>
|
16
|
-
|
17
|
-
Previous post: Penultimate post
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: Penultimate post</title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
<p>post_page flag set for layout</p>
|
7
|
-
|
8
|
-
|
9
|
-
<p>post_page flag set for template</p>
|
10
|
-
<h2>Penultimate post</h2>
|
11
|
-
|
12
|
-
<p>Penultimate post</p>
|
13
|
-
|
14
|
-
|
15
|
-
<p><a href="http://twitter.com/share?text=Penultimate+post&url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fpenultimate-post">Submit this to Twitter.</p>
|
16
|
-
|
17
|
-
Previous post: Custom layout
|
18
|
-
Next post: Final post
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: Some draft title</title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
<p>post_page flag set for layout</p>
|
7
|
-
|
8
|
-
|
9
|
-
<p>post_page flag set for template</p>
|
10
|
-
<h2>Some draft title</h2>
|
11
|
-
|
12
|
-
<p>some content</p>
|
13
|
-
|
14
|
-
|
15
|
-
<p><a href="http://twitter.com/share?text=Some+draft+title&url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fpost-to-be-published-on-generate">Submit this to Twitter.</p>
|
16
|
-
|
17
|
-
Previous post: Sample post
|
18
|
-
Next post: Second post
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<h1 id="layout" data-name="alternate-layout">Alternate layout</h1>
|
2
|
-
|
3
|
-
|
4
|
-
<p>post_page flag set for template</p>
|
5
|
-
<h2>Custom layout</h2>
|
6
|
-
|
7
|
-
<p>Second post.</p>
|
8
|
-
|
9
|
-
|
10
|
-
<p><a href="http://twitter.com/share?text=Custom+layout&url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fpost-with-custom-layout">Submit this to Twitter.</p>
|
11
|
-
|
12
|
-
Previous post: Second post
|
13
|
-
Next post: Penultimate post
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: Sample post</title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
<p>post_page flag set for layout</p>
|
7
|
-
|
8
|
-
|
9
|
-
<p>post_page flag set for template</p>
|
10
|
-
<h2>Sample post</h2>
|
11
|
-
|
12
|
-
<p>Just a sample post.</p>
|
13
|
-
|
14
|
-
|
15
|
-
<p><a href="http://twitter.com/share?text=Sample+post&url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fsample-post">Submit this to Twitter.</p>
|
16
|
-
|
17
|
-
|
18
|
-
Next post: Some draft title
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<meta charset="UTF-8">
|
3
|
-
<title>My site: Second post</title>
|
4
|
-
<h1>mysite.com</h1>
|
5
|
-
|
6
|
-
<p>post_page flag set for layout</p>
|
7
|
-
|
8
|
-
|
9
|
-
<p>post_page flag set for template</p>
|
10
|
-
<h2>Second post</h2>
|
11
|
-
|
12
|
-
<p>Second post.</p>
|
13
|
-
|
14
|
-
|
15
|
-
<p><a href="http://twitter.com/share?text=Second+post&url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fsecond-post">Submit this to Twitter.</p>
|
16
|
-
|
17
|
-
Previous post: Some draft title
|
18
|
-
Next post: Custom layout
|