serif 0.5.2 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +58 -21
- data/LICENSE +1 -1
- data/README.md +11 -13
- data/lib/serif.rb +3 -2
- data/lib/serif/admin_server.rb +10 -10
- data/lib/serif/commands.rb +2 -2
- data/lib/serif/config.rb +1 -1
- data/lib/serif/content_file.rb +9 -9
- data/lib/serif/draft.rb +1 -1
- data/lib/serif/errors.rb +1 -1
- data/lib/serif/markup_renderer.rb +28 -17
- data/lib/serif/post.rb +1 -1
- data/lib/serif/server.rb +1 -1
- data/lib/serif/site.rb +5 -29
- data/rakefile +3 -6
- data/serif.gemspec +9 -3
- data/statics/assets/js/attachment.js +3 -3
- data/statics/skeleton/_config.yml +1 -1
- data/statics/skeleton/_layouts/default.html +1 -1
- data/statics/skeleton/_templates/archive_page.html +1 -1
- data/statics/skeleton/_templates/post.html +1 -1
- data/statics/skeleton/archive.html +1 -1
- data/statics/skeleton/index.html +1 -1
- data/statics/templates/admin/bookmarks.liquid +1 -1
- data/statics/templates/admin/edit_draft.liquid +1 -1
- data/statics/templates/admin/index.liquid +1 -1
- data/statics/templates/admin/layout.liquid +6 -4
- data/statics/templates/admin/new_draft.liquid +1 -1
- metadata +123 -127
- data/test/commands_spec.rb +0 -77
- data/test/config_spec.rb +0 -55
- data/test/content_file_spec.rb +0 -113
- data/test/draft_spec.rb +0 -275
- data/test/file_digest_tag_spec.rb +0 -38
- data/test/filters_spec.rb +0 -90
- data/test/liquid_filter_date_extension_spec.rb +0 -15
- data/test/markup_renderer_spec.rb +0 -47
- data/test/post_spec.rb +0 -139
- data/test/site_dir/_config.yml +0 -18
- data/test/site_dir/_drafts/another-sample-draft +0 -3
- data/test/site_dir/_drafts/sample-draft +0 -3
- data/test/site_dir/_layouts/alt-layout.html +0 -3
- data/test/site_dir/_layouts/default.html +0 -8
- data/test/site_dir/_posts/2012-01-05-sample-post +0 -4
- data/test/site_dir/_posts/2013-01-01-second-post +0 -4
- data/test/site_dir/_posts/2013-03-07-post-with-custom-layout +0 -5
- data/test/site_dir/_posts/2399-01-01-penultimate-post +0 -4
- data/test/site_dir/_posts/2400-01-01-final-post +0 -4
- data/test/site_dir/_templates/archive_page.html +0 -9
- data/test/site_dir/_templates/post.html +0 -10
- data/test/site_dir/archive.html +0 -7
- data/test/site_dir/file-digest-test.html +0 -4
- data/test/site_dir/index.html +0 -9
- data/test/site_dir/page-alt-layout.html +0 -3
- data/test/site_dir/page-header-but-no-layout.html +0 -3
- data/test/site_dir/test-smarty-filter.html +0 -3
- data/test/site_dir/test-stylesheet.css +0 -3
- data/test/site_generation_spec.rb +0 -204
- data/test/site_spec.rb +0 -189
- data/test/test_helper.rb +0 -61
@@ -1,38 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe Serif::FileDigest do
|
4
|
-
def file_digest(markup)
|
5
|
-
Serif::FileDigest.new("file_digest", markup, "no tokens needed")
|
6
|
-
end
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
site = Serif::Site.new(testing_dir)
|
10
|
-
@context = { "site" => { "directory" => site.directory }}
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#render" do
|
14
|
-
it "returns the md5 hex digest of the finally deployed site path" do
|
15
|
-
file_digest("test-stylesheet.css").render(@context).should == "f8390232f0c354a871f9ba0ed306163c"
|
16
|
-
end
|
17
|
-
|
18
|
-
it "ignores leading slashes" do
|
19
|
-
file_digest("/test-stylesheet.css").render(@context).should == "f8390232f0c354a871f9ba0ed306163c"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "ignores surrounding whitespace" do
|
23
|
-
file_digest(" test-stylesheet.css ").render(@context).should == "f8390232f0c354a871f9ba0ed306163c"
|
24
|
-
end
|
25
|
-
|
26
|
-
it "includes a prefix if one is specified" do
|
27
|
-
file_digest("test-stylesheet.css prefix:.").render(@context).should == ".f8390232f0c354a871f9ba0ed306163c"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "ignores trailing whitespace on the prefix" do
|
31
|
-
file_digest("test-stylesheet.css prefix:. ").render(@context).should == ".f8390232f0c354a871f9ba0ed306163c"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "raises a SyntaxError on invalid syntax" do
|
35
|
-
expect { file_digest("test-stylesheet.css pefoiejw").render(@context) }.to raise_error(SyntaxError)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/test/filters_spec.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe Serif::Filters do
|
4
|
-
subject do
|
5
|
-
o = Object.new
|
6
|
-
o.extend(Serif::Filters)
|
7
|
-
o
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#strip" do
|
11
|
-
it "calls strip on its argument" do
|
12
|
-
double = double("")
|
13
|
-
double.should_receive(:strip).once
|
14
|
-
subject.strip(double)
|
15
|
-
|
16
|
-
s = " foo "
|
17
|
-
subject.strip(s).should == s.strip
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#smarty" do
|
22
|
-
it "runs the input through a SmartyPants processor" do
|
23
|
-
subject.smarty("Testing").should == "Testing"
|
24
|
-
subject.smarty("Testing's").should == "Testing’s"
|
25
|
-
subject.smarty("\"Testing\" some \"text's\" input...").should == "“Testing” some “text’s” input…"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "does not do any markdown processing" do
|
29
|
-
subject.smarty("# Heading").should == "# Heading"
|
30
|
-
subject.smarty("Testing `code blocks` input").should == "Testing `code blocks` input"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "deals with HTML appropriately" do
|
34
|
-
subject.smarty("<p>Testing's <span>span</span> testing</p>").should == "<p>Testing’s <span>span</span> testing</p>"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "#encode_uri_component" do
|
39
|
-
it "percent-encodes various characters for use in a URI" do
|
40
|
-
{
|
41
|
-
" " => "+",
|
42
|
-
"!" => "%21",
|
43
|
-
"$" => "%24",
|
44
|
-
"&" => "%26",
|
45
|
-
"'" => "%27",
|
46
|
-
"(" => "%28",
|
47
|
-
")" => "%29",
|
48
|
-
"*" => "%2A",
|
49
|
-
"+" => "%2B",
|
50
|
-
"/" => "%2F",
|
51
|
-
":" => "%3A",
|
52
|
-
";" => "%3B",
|
53
|
-
"=" => "%3D",
|
54
|
-
"?" => "%3F",
|
55
|
-
"@" => "%40",
|
56
|
-
"[" => "%5B",
|
57
|
-
"]" => "%5D",
|
58
|
-
"~" => "%7E"
|
59
|
-
}.each do |char, enc_char|
|
60
|
-
subject.encode_uri_component(char).should == enc_char
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
it "returns an empty string on nil input" do
|
65
|
-
subject.encode_uri_component(nil).should == ""
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "#xmlschema" do
|
70
|
-
it "calls xmlschema on its input" do
|
71
|
-
d = double("")
|
72
|
-
d.should_receive(:xmlschema).once
|
73
|
-
subject.xmlschema(d)
|
74
|
-
|
75
|
-
subject.xmlschema(Time.parse("2012-01-01")).should == "2012-01-01T00:00:00+00:00"
|
76
|
-
subject.xmlschema(Time.parse("2012-01-01").utc).should == "2012-01-01T00:00:00Z"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "#markdown" do
|
81
|
-
it "processes its input as markdown" do
|
82
|
-
# bit of a stub test
|
83
|
-
subject.markdown("# Hi!").should == "<h1>Hi!</h1>\n"
|
84
|
-
end
|
85
|
-
|
86
|
-
it "uses curly single quotes properly" do
|
87
|
-
subject.markdown("# something's test").should include("something’s")
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe Liquid::StandardFilters do
|
4
|
-
subject do
|
5
|
-
o = Object.new
|
6
|
-
o.extend(Liquid::StandardFilters)
|
7
|
-
o
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#date" do
|
11
|
-
it "accepts 'now' for the current time" do
|
12
|
-
subject.date("now", "%Y").should == Time.now.year.to_s
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe Serif::MarkupRenderer do
|
4
|
-
subject do
|
5
|
-
Redcarpet::Markdown.new(Serif::MarkupRenderer, fenced_code_blocks: true)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "renders language-free code blocks correctly" do
|
9
|
-
subject.render(<<END_SOURCE).should == <<END_OUTPUT.chomp
|
10
|
-
foo
|
11
|
-
|
12
|
-
```
|
13
|
-
some code
|
14
|
-
```
|
15
|
-
END_SOURCE
|
16
|
-
<p>foo</p>
|
17
|
-
<pre><code>some code
|
18
|
-
</code></pre>
|
19
|
-
END_OUTPUT
|
20
|
-
end
|
21
|
-
|
22
|
-
it "renders code blocks with a language correctly" do
|
23
|
-
subject.render(<<END_SOURCE).should == <<END_OUTPUT
|
24
|
-
foo
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
foo
|
28
|
-
```
|
29
|
-
END_SOURCE
|
30
|
-
<p>foo</p>
|
31
|
-
<pre class="highlight"><code><span class="n">foo</span>
|
32
|
-
</code></pre>
|
33
|
-
END_OUTPUT
|
34
|
-
end
|
35
|
-
|
36
|
-
# NOTE: The output here is not the desired output.
|
37
|
-
#
|
38
|
-
# See vmg/redcarpet#57 and note that any filters that use this renderer
|
39
|
-
# are tested elsewhere.
|
40
|
-
it "renders quote marks properly" do
|
41
|
-
subject.render(<<END_SOURCE).should == <<END_OUTPUT
|
42
|
-
This "very" sentence's structure "isn't" necessary.
|
43
|
-
END_SOURCE
|
44
|
-
<p>This “very” sentence's structure “isn't” necessary.</p>
|
45
|
-
END_OUTPUT
|
46
|
-
end
|
47
|
-
end
|
data/test/post_spec.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
describe Serif::Post do
|
4
|
-
subject do
|
5
|
-
Serif::Site.new(testing_dir)
|
6
|
-
end
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
@posts = subject.posts
|
10
|
-
end
|
11
|
-
|
12
|
-
around :each do |example|
|
13
|
-
begin
|
14
|
-
d = Serif::Draft.new(subject)
|
15
|
-
d.slug = "foo-bar-bar-temp"
|
16
|
-
d.title = "Testing title"
|
17
|
-
d.save("# some content")
|
18
|
-
d.publish!
|
19
|
-
@temporary_post = Serif::Post.new(subject, d.path)
|
20
|
-
|
21
|
-
example.run
|
22
|
-
ensure
|
23
|
-
FileUtils.rm(@temporary_post.path)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#from_basename" do
|
28
|
-
it "is nil if there is nothing found" do
|
29
|
-
Serif::Post.from_basename(subject, "eoijfwoifjweofej").should be_nil
|
30
|
-
end
|
31
|
-
|
32
|
-
it "takes full filename within _posts" do
|
33
|
-
Serif::Post.from_basename(subject, @temporary_post.basename).path.should == @temporary_post.path
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "uses the config file's permalink value" do
|
38
|
-
@posts.all? { |p| p.url == "/test-blog/#{p.slug}" }.should be_true
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#inspect" do
|
42
|
-
it "includes headers" do
|
43
|
-
@posts.all? { |p| p.inspect.should include(p.headers.inspect) }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "#autoupdate=" do
|
48
|
-
it "sets the 'update' header to 'now' if truthy assigned value" do
|
49
|
-
@temporary_post.autoupdate = true
|
50
|
-
@temporary_post.headers[:update].should == "now"
|
51
|
-
end
|
52
|
-
|
53
|
-
it "removes the 'update' header entirely if falsey assigned value" do
|
54
|
-
@temporary_post.autoupdate = false
|
55
|
-
@temporary_post.headers.key?(:update).should be_false
|
56
|
-
end
|
57
|
-
|
58
|
-
it "marks the post as autoupdate? == true" do
|
59
|
-
@temporary_post.autoupdate?.should be_false
|
60
|
-
@temporary_post.autoupdate = true
|
61
|
-
@temporary_post.autoupdate?.should be_true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "#autoupdate?" do
|
66
|
-
it "returns true if there is an update: now header" do
|
67
|
-
@temporary_post.stub(:headers) { { :update => "foo" } }
|
68
|
-
@temporary_post.autoupdate?.should be_false
|
69
|
-
@temporary_post.stub(:headers) { { :update => "now" } }
|
70
|
-
@temporary_post.autoupdate?.should be_true
|
71
|
-
end
|
72
|
-
|
73
|
-
it "is ignorant of whitespace in the update header value" do
|
74
|
-
@temporary_post.stub(:headers) { { :update => "now" } }
|
75
|
-
@temporary_post.autoupdate?.should be_true
|
76
|
-
|
77
|
-
(1..3).each do |left|
|
78
|
-
(1..3).each do |right|
|
79
|
-
@temporary_post.stub(:headers) { { :update => "#{" " * left}now#{" " * right}"} }
|
80
|
-
@temporary_post.autoupdate?.should be_true
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "#update!" do
|
87
|
-
it "sets the updated header timestamp to the current time" do
|
88
|
-
old_update_time = @temporary_post.updated
|
89
|
-
t = Time.now + 50
|
90
|
-
|
91
|
-
Timecop.freeze(t) do
|
92
|
-
@temporary_post.update!
|
93
|
-
@temporary_post.updated.should_not == old_update_time
|
94
|
-
@temporary_post.updated.to_i.should == t.to_i
|
95
|
-
@temporary_post.headers[:updated].to_i.should == t.to_i
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
it "calls save and writes out the new timestamp value, without a publish: now header" do
|
100
|
-
@temporary_post.should_receive(:save).once.and_call_original
|
101
|
-
|
102
|
-
t = Time.now + 50
|
103
|
-
Timecop.freeze(t) do
|
104
|
-
@temporary_post.update!
|
105
|
-
|
106
|
-
file_content = Redhead::String[File.read(@temporary_post.path)]
|
107
|
-
Time.parse(file_content.headers[:updated].value).to_i.should == t.to_i
|
108
|
-
file_content.headers[:publish].should be_nil
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
it "marks the post as no longer auto-updating" do
|
113
|
-
@temporary_post.autoupdate?.should be_false
|
114
|
-
@temporary_post.autoupdate = true
|
115
|
-
@temporary_post.autoupdate?.should be_true
|
116
|
-
@temporary_post.update!
|
117
|
-
@temporary_post.autoupdate?.should be_false
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe "#to_liquid" do
|
122
|
-
it "contains the relevant keys" do
|
123
|
-
liq = subject.posts.sample.to_liquid
|
124
|
-
|
125
|
-
["title",
|
126
|
-
"created",
|
127
|
-
"updated",
|
128
|
-
"content",
|
129
|
-
"slug",
|
130
|
-
"url",
|
131
|
-
"type",
|
132
|
-
"draft",
|
133
|
-
"published",
|
134
|
-
"basename"].each do |e|
|
135
|
-
liq.key?(e).should be_true
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
data/test/site_dir/_config.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# This is the Serif config file. It must be a valid YAML document.
|
2
|
-
#
|
3
|
-
# Some configuration options:
|
4
|
-
#
|
5
|
-
# admin:
|
6
|
-
# username: [a username for the admin web interface]
|
7
|
-
# password: [a password for the admin web interface]
|
8
|
-
# permalink: [permalink format for generated posts]
|
9
|
-
#
|
10
|
-
# See the README for information on permalink formats.
|
11
|
-
|
12
|
-
admin:
|
13
|
-
username: test-changethisusername
|
14
|
-
password: test-changethispassword
|
15
|
-
permalink: /test-blog/:title
|
16
|
-
archive:
|
17
|
-
enabled: yes
|
18
|
-
url_format: /test-archive/:year/:month
|
@@ -1,10 +0,0 @@
|
|
1
|
-
{% if draft_preview %}<p>draftpreviewflagexists</p>{% endif %}
|
2
|
-
{% if post_page %}<p>post_page flag set for template</p>{% endif %}
|
3
|
-
<h2>{{ post.title }}</h2>
|
4
|
-
|
5
|
-
{{ post.content | markdown }}
|
6
|
-
|
7
|
-
<p><a href="http://twitter.com/share?text={{ post.title | encode_uri_component }}&url={{ 'http://www.mysite.com' | encode_uri_component }}{{ post.url | encode_uri_component }}">Submit this to Twitter.</p>
|
8
|
-
|
9
|
-
{% if prev_post %}Previous post: {{ prev_post.title }}{% endif %}
|
10
|
-
{% if next_post %}Next post: {{ next_post.title }}{% endif %}
|
data/test/site_dir/archive.html
DELETED