serif 0.1.4 → 0.1.5
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.
- data/Gemfile.lock +18 -2
- data/README.md +11 -2
- data/lib/serif/config.rb +6 -4
- data/lib/serif/content_file.rb +13 -4
- data/lib/serif/draft.rb +2 -3
- data/rakefile +11 -0
- data/serif.gemspec +7 -4
- data/statics/templates/admin/edit_draft.liquid +10 -1
- data/statics/templates/admin/edit_post.liquid +9 -1
- data/statics/templates/admin/new_draft.liquid +9 -1
- data/test/config_spec.rb +48 -0
- data/test/draft_spec.rb +51 -0
- data/test/filters_spec.rb +65 -0
- data/test/liquid_filter_date_extension_spec.rb +15 -0
- data/test/markup_renderer_spec.rb +35 -0
- data/test/post_spec.rb +15 -0
- data/test/site_dir/_config.yml +18 -0
- data/test/site_dir/_drafts/another-sample-draft +3 -0
- data/test/site_dir/_drafts/sample-draft +3 -0
- data/test/site_dir/_layouts/default.html +6 -0
- data/test/site_dir/_posts/2012-01-05-sample-post +4 -0
- data/test/site_dir/_site/archive.html +11 -0
- data/test/site_dir/_site/index.html +14 -0
- data/test/site_dir/_site/test-archive/2012/11/index.html +14 -0
- data/test/site_dir/_site/test-blog/sample-post.html +10 -0
- data/test/site_dir/_templates/archive_page.html +9 -0
- data/test/site_dir/_templates/post.html +5 -0
- data/test/site_dir/_trash/1355618409-test-draft +3 -0
- data/test/site_dir/archive.html +7 -0
- data/test/site_dir/index.html +9 -0
- data/test/site_generation_spec.rb +16 -0
- data/test/site_spec.rb +90 -0
- data/test/test_helper.rb +14 -0
- metadata +213 -141
data/Gemfile.lock
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
serif (0.1.
|
4
|
+
serif (0.1.4)
|
5
5
|
liquid (~> 2.4)
|
6
6
|
pygments.rb (~> 0.3)
|
7
7
|
rack (~> 1.0)
|
8
8
|
rack-rewrite (~> 1.3.0)
|
9
|
-
rake (~> 0.9)
|
10
9
|
redcarpet (~> 2.2)
|
11
10
|
redhead (~> 0.0.6)
|
12
11
|
sinatra (~> 1.3)
|
@@ -15,7 +14,9 @@ PATH
|
|
15
14
|
GEM
|
16
15
|
remote: http://rubygems.org/
|
17
16
|
specs:
|
17
|
+
diff-lcs (1.1.2)
|
18
18
|
liquid (2.4.1)
|
19
|
+
multi_json (1.5.0)
|
19
20
|
posix-spawn (0.3.6)
|
20
21
|
pygments.rb (0.3.2)
|
21
22
|
posix-spawn (~> 0.3.6)
|
@@ -27,6 +28,18 @@ GEM
|
|
27
28
|
rake (0.9.2.2)
|
28
29
|
redcarpet (2.2.2)
|
29
30
|
redhead (0.0.6)
|
31
|
+
rspec (2.5.0)
|
32
|
+
rspec-core (~> 2.5.0)
|
33
|
+
rspec-expectations (~> 2.5.0)
|
34
|
+
rspec-mocks (~> 2.5.0)
|
35
|
+
rspec-core (2.5.1)
|
36
|
+
rspec-expectations (2.5.0)
|
37
|
+
diff-lcs (~> 1.1.2)
|
38
|
+
rspec-mocks (2.5.0)
|
39
|
+
simplecov (0.7.1)
|
40
|
+
multi_json (~> 1.0)
|
41
|
+
simplecov-html (~> 0.7.1)
|
42
|
+
simplecov-html (0.7.1)
|
30
43
|
sinatra (1.3.3)
|
31
44
|
rack (~> 1.3, >= 1.3.6)
|
32
45
|
rack-protection (~> 1.2)
|
@@ -39,4 +52,7 @@ PLATFORMS
|
|
39
52
|
ruby
|
40
53
|
|
41
54
|
DEPENDENCIES
|
55
|
+
rake (~> 0.9)
|
56
|
+
rspec (~> 2.5)
|
42
57
|
serif!
|
58
|
+
simplecov (~> 0.7)
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Serif
|
2
2
|
|
3
|
+
[](https://travis-ci.org/aprescott/serif)
|
4
|
+
|
3
5
|
Serif is a file-based blogging engine intended for simple sites. It compiles Markdown content to static files, and there is a web interface for editing and publishing ([simple video demo](https://docs.google.com/open?id=0BxPQpxGSOOyKS1J4MmlnM3JIaXM)), because managing everything with `ssh` and `git` can be a pain, compared to having a more universally accessible editing interface.
|
4
6
|
|
5
7
|
_It should be considered alpha._ I make no promises it won't all change underneath you. **It is all subject to change, and is in a rough state.**
|
@@ -18,7 +20,7 @@ With this in mind, you might think of Serif's aim as to merge Jekyll, [Second Cr
|
|
18
20
|
Some things I'm hoping to implement one day:
|
19
21
|
|
20
22
|
1. Custom hooks to fire after particular events, such as minifying CSS after publish, or committing changes and pushing to a git repository.
|
21
|
-
2. Simple Markdown pages instead of plain HTML.
|
23
|
+
2. Simple Markdown pages instead of plain HTML for non-post content.
|
22
24
|
3. Automatically detecting file changes and regenerating the site.
|
23
25
|
4. Adding custom Liquid filters and tags.
|
24
26
|
|
@@ -28,6 +30,13 @@ Serif is released under the MIT license. See LICENSE for details.
|
|
28
30
|
|
29
31
|
Any contributions will be assumed by default to be under the same terms.
|
30
32
|
|
33
|
+
The quickest way to get changes contributed:
|
34
|
+
|
35
|
+
1. Visit the [GitHub repository for Serif](https://github.com/aprescott/serif).
|
36
|
+
2. [Fork the repository](https://help.github.com/articles/fork-a-repo).
|
37
|
+
3. Check out a branch on the latest master for your change: `git checkout -b master new-feature` --- do not make changes on `master`! Make sure that anything added or changed has a test in the `test/` directory. Use the existing files as examples. All tests for new/changed behaviour should pass.
|
38
|
+
4. [Send a pull request on GitHub](https://help.github.com/articles/fork-a-repo), including a description of what you've changed. (Note: your contribution will be assumed to be under the same terms of the project by default.)
|
39
|
+
|
31
40
|
# Basics
|
32
41
|
|
33
42
|
## Installing
|
@@ -276,7 +285,7 @@ error_page 404 @not_found_page;
|
|
276
285
|
location / {
|
277
286
|
index index.html index.htm;
|
278
287
|
|
279
|
-
try_files $uri.html $uri $uri/
|
288
|
+
try_files $uri.html $uri $uri/ 404;
|
280
289
|
}
|
281
290
|
|
282
291
|
location @not_found_page {
|
data/lib/serif/config.rb
CHANGED
@@ -6,10 +6,6 @@ class Config
|
|
6
6
|
@config_file = config_file
|
7
7
|
end
|
8
8
|
|
9
|
-
def yaml
|
10
|
-
YAML.load_file(@config_file)
|
11
|
-
end
|
12
|
-
|
13
9
|
def admin_username
|
14
10
|
yaml["admin"]["username"]
|
15
11
|
end
|
@@ -35,5 +31,11 @@ class Config
|
|
35
31
|
def archive_url_format
|
36
32
|
(yaml["archive"] || {})["url_format"] || "/archive/:year/:month"
|
37
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def yaml
|
38
|
+
YAML.load_file(@config_file)
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
data/lib/serif/content_file.rb
CHANGED
@@ -19,9 +19,7 @@ class ContentFile
|
|
19
19
|
if @path
|
20
20
|
# we have to parse out the source first so that we get necessary
|
21
21
|
# metadata like published vs. draft.
|
22
|
-
|
23
|
-
source.force_encoding("UTF-8")
|
24
|
-
@source = Redhead::String[source]
|
22
|
+
load_source
|
25
23
|
|
26
24
|
dirname = File.basename(File.dirname(@path))
|
27
25
|
basename = File.basename(@path)
|
@@ -36,7 +34,7 @@ class ContentFile
|
|
36
34
|
# this will run for new drafts
|
37
35
|
|
38
36
|
if !@path
|
39
|
-
@path = File.expand_path("#{self.class.dirname}/#{@slug}")
|
37
|
+
@path = File.expand_path("#{site.directory}/#{self.class.dirname}/#{@slug}")
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
@@ -121,6 +119,9 @@ class ContentFile
|
|
121
119
|
#{markdown}}.strip
|
122
120
|
end
|
123
121
|
|
122
|
+
# after every save, ensure we've re-loaded the saved content
|
123
|
+
load_source
|
124
|
+
|
124
125
|
true # always return true for now
|
125
126
|
end
|
126
127
|
|
@@ -150,5 +151,13 @@ class ContentFile
|
|
150
151
|
def set_updated_time(time)
|
151
152
|
@source.headers[:updated] = time.xmlschema
|
152
153
|
end
|
154
|
+
|
155
|
+
private
|
156
|
+
|
157
|
+
def load_source
|
158
|
+
source = File.read(path).gsub(/\r?\n/, "\n")
|
159
|
+
source.force_encoding("UTF-8")
|
160
|
+
@source = Redhead::String[source]
|
161
|
+
end
|
153
162
|
end
|
154
163
|
end
|
data/lib/serif/draft.rb
CHANGED
@@ -5,8 +5,8 @@ class Draft < ContentFile
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def delete!
|
8
|
-
FileUtils.mkdir_p("_trash")
|
9
|
-
File.rename(@path, File.expand_path("_trash/#{Time.now.to_i}-#{slug}"))
|
8
|
+
FileUtils.mkdir_p("#{site.directory}/_trash")
|
9
|
+
File.rename(@path, File.expand_path("#{site.directory}/_trash/#{Time.now.to_i}-#{slug}"))
|
10
10
|
end
|
11
11
|
|
12
12
|
def publish!
|
@@ -51,7 +51,6 @@ class Draft < ContentFile
|
|
51
51
|
|
52
52
|
def self.from_slug(site, slug)
|
53
53
|
path = File.expand_path(File.join(site.directory, dirname, slug))
|
54
|
-
p path
|
55
54
|
new(site, path)
|
56
55
|
end
|
57
56
|
end
|
data/rakefile
ADDED
data/serif.gemspec
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "serif"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.5"
|
4
4
|
s.authors = ["Adam Prescott"]
|
5
5
|
s.email = ["adam@aprescott.com"]
|
6
6
|
s.homepage = "https://github.com/aprescott/serif"
|
7
7
|
s.summary = "Simple file-based blogging system."
|
8
8
|
s.description = "Serif is a simple file-based blogging system which generates static content and allows dynamic editing through an interface."
|
9
|
-
s.files = Dir["{lib/**/*,statics/**/*,bin
|
9
|
+
s.files = Dir["{lib/**/*,statics/**/*,bin/*,test/**/*}"] + %w[serif.gemspec rakefile LICENSE Gemfile Gemfile.lock README.md]
|
10
10
|
s.require_path = "lib"
|
11
11
|
s.bindir = "bin"
|
12
12
|
s.executables = "serif"
|
13
|
-
|
13
|
+
s.test_files = Dir["test/*"]
|
14
14
|
|
15
15
|
[
|
16
|
-
"rake", "~> 0.9",
|
17
16
|
"rack", "~> 1.0",
|
18
17
|
"rack-rewrite", "~> 1.3.0",
|
19
18
|
"redcarpet", "~> 2.2",
|
@@ -25,4 +24,8 @@ Gem::Specification.new do |s|
|
|
25
24
|
].each_slice(2) do |name, version|
|
26
25
|
s.add_runtime_dependency(name, version)
|
27
26
|
end
|
27
|
+
|
28
|
+
s.add_development_dependency("rake", "~> 0.9")
|
29
|
+
s.add_development_dependency("rspec", "~> 2.5")
|
30
|
+
s.add_development_dependency("simplecov", "~> 0.7")
|
28
31
|
end
|
@@ -33,4 +33,12 @@
|
|
33
33
|
|
34
34
|
<input type="checkbox" id="render-preview"> <label class="preview" for="render-preview">Preview</label>
|
35
35
|
</form>
|
36
|
-
</div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<script>
|
39
|
+
$(function() {
|
40
|
+
window.onbeforeunload = function() {
|
41
|
+
return "You may lose unsaved changes if you leave this page.";
|
42
|
+
}
|
43
|
+
});
|
44
|
+
</script>
|
@@ -32,4 +32,12 @@
|
|
32
32
|
<input type="checkbox" id="render-preview"> <label class="preview" for="render-preview">Preview</label>
|
33
33
|
</form>
|
34
34
|
|
35
|
-
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<script>
|
38
|
+
$(function() {
|
39
|
+
window.onbeforeunload = function() {
|
40
|
+
return "You may lose unsaved changes if you leave this page.";
|
41
|
+
}
|
42
|
+
});
|
43
|
+
</script>
|
data/test/config_spec.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Serif::Config do
|
4
|
+
subject do
|
5
|
+
Serif::Config.new(testing_dir("_config.yml"))
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#admin_username" do
|
9
|
+
it "is the admin username defined in the config file" do
|
10
|
+
subject.admin_username.should == "test-changethisusername"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#admin_password" do
|
15
|
+
it "is the admin password defined in the config file" do
|
16
|
+
subject.admin_password.should == "test-changethispassword"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#permalink" do
|
21
|
+
it "is the permalink format defined in the config file" do
|
22
|
+
subject.permalink.should == "/test-blog/:title"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "defaults to /:title" do
|
26
|
+
subject.stub(:yaml) { {} }
|
27
|
+
subject.permalink.should == "/:title"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#archive_url_format" do
|
32
|
+
it "defaults to /archive/:year/:month" do
|
33
|
+
subject.stub(:yaml) { {} }
|
34
|
+
subject.archive_url_format.should == "/archive/:year/:month"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "is the archive_url_format found in the config file" do
|
38
|
+
subject.archive_url_format.should == "/test-archive/:year/:month"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#archive_enabled?" do
|
43
|
+
it "defaults to false" do
|
44
|
+
subject.stub(:yaml) { {} }
|
45
|
+
subject.archive_enabled?.should be_false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/test/draft_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Serif::Draft do
|
4
|
+
before :all do
|
5
|
+
@site = Serif::Site.new(testing_dir)
|
6
|
+
D = Serif::Draft
|
7
|
+
FileUtils.rm_rf(testing_dir("_trash"))
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#delete!" do
|
11
|
+
it "moves the file to _trash" do
|
12
|
+
draft = D.new(@site)
|
13
|
+
draft.slug = "test-draft"
|
14
|
+
draft.title = "Some draft title"
|
15
|
+
draft.save("some content")
|
16
|
+
draft.delete!
|
17
|
+
Dir[testing_dir("_trash/*-test-draft")].length.should == 1
|
18
|
+
end
|
19
|
+
|
20
|
+
it "creates the _trash directory if it doesn't exist" do
|
21
|
+
FileUtils.rm_rf(testing_dir("_trash"))
|
22
|
+
|
23
|
+
draft = D.new(@site)
|
24
|
+
draft.slug = "test-draft"
|
25
|
+
draft.title = "Some draft title"
|
26
|
+
draft.save("some content")
|
27
|
+
draft.delete!
|
28
|
+
|
29
|
+
File.exist?(testing_dir("_trash")).should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#save" do
|
34
|
+
it "saves the file to _drafts" do
|
35
|
+
draft = D.new(@site)
|
36
|
+
draft.slug = "test-draft"
|
37
|
+
draft.title = "Some draft title"
|
38
|
+
|
39
|
+
D.exist?(@site, draft.slug).should be_false
|
40
|
+
File.exist?(testing_dir("_drafts/test-draft")).should be_false
|
41
|
+
|
42
|
+
draft.save("some content")
|
43
|
+
|
44
|
+
D.exist?(@site, draft.slug).should be_true
|
45
|
+
File.exist?(testing_dir("_drafts/test-draft")).should be_true
|
46
|
+
|
47
|
+
# clean up the file
|
48
|
+
draft.delete!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,65 @@
|
|
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 "#encode_uri_component" do
|
22
|
+
it "percent-encodes various characters for use in a URI" do
|
23
|
+
{
|
24
|
+
" " => "+",
|
25
|
+
"!" => "%21",
|
26
|
+
"$" => "%24",
|
27
|
+
"&" => "%26",
|
28
|
+
"'" => "%27",
|
29
|
+
"(" => "%28",
|
30
|
+
")" => "%29",
|
31
|
+
"*" => "%2A",
|
32
|
+
"+" => "%2B",
|
33
|
+
"/" => "%2F",
|
34
|
+
":" => "%3A",
|
35
|
+
";" => "%3B",
|
36
|
+
"=" => "%3D",
|
37
|
+
"?" => "%3F",
|
38
|
+
"@" => "%40",
|
39
|
+
"[" => "%5B",
|
40
|
+
"]" => "%5D",
|
41
|
+
"~" => "%7E"
|
42
|
+
}.each do |char, enc_char|
|
43
|
+
subject.encode_uri_component(char).should == enc_char
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#xmlschema" do
|
49
|
+
it "calls xmlschema on its input" do
|
50
|
+
d = double("")
|
51
|
+
d.should_receive(:xmlschema).once
|
52
|
+
subject.xmlschema(d)
|
53
|
+
|
54
|
+
subject.xmlschema(Time.parse("2012-01-01")).should == "2012-01-01T00:00:00+00:00"
|
55
|
+
subject.xmlschema(Time.parse("2012-01-01").utc).should == "2012-01-01T00:00:00Z"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#markdown" do
|
60
|
+
it "processes its input as markdown" do
|
61
|
+
# bit of a stub test
|
62
|
+
subject.markdown("# Hi!").should == "<h1>Hi!</h1>"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1,35 @@
|
|
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
|
+
end
|
data/test/post_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Serif::Post do
|
4
|
+
subject do
|
5
|
+
Serif::Site.new(testing_dir)
|
6
|
+
end
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@posts = subject.posts
|
10
|
+
end
|
11
|
+
|
12
|
+
it "uses the config file's permalink value" do
|
13
|
+
@posts.all? { |p| p.url == "/test-blog/#{p.slug}" }.should be_true
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<meta charset="UTF-8">
|
3
|
+
<title>My site: </title>
|
4
|
+
<h1>mysite.com</h1>
|
5
|
+
|
6
|
+
<h2>Posts</h2>
|
7
|
+
|
8
|
+
<p>There are 1 posts:</p>
|
9
|
+
|
10
|
+
<ul>
|
11
|
+
|
12
|
+
<li><a href="/test-blog/sample-post">Sample post</a> (posted 2012-11-21T17:07:09+00:00)</li>
|
13
|
+
|
14
|
+
</ul>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<meta charset="UTF-8">
|
3
|
+
<title>My site: Posts - Sample post</title>
|
4
|
+
<h1>mysite.com</h1>
|
5
|
+
|
6
|
+
<h2>Sample post</h2>
|
7
|
+
|
8
|
+
<p>Just a sample post.</p>
|
9
|
+
|
10
|
+
<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>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<h2>{{ post.title }}</h2>
|
2
|
+
|
3
|
+
{{ post.content | markdown }}
|
4
|
+
|
5
|
+
<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>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Serif::Site do
|
4
|
+
subject do
|
5
|
+
Serif::Site.new(testing_dir)
|
6
|
+
end
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
FileUtils.rm_rf(testing_dir("_site"))
|
10
|
+
end
|
11
|
+
|
12
|
+
it "uses the permalinks in the config file for site generation" do
|
13
|
+
subject.generate
|
14
|
+
File.exist?(testing_dir("_site/test-blog/sample-post.html")).should be_true
|
15
|
+
end
|
16
|
+
end
|
data/test/site_spec.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Serif::Site do
|
4
|
+
subject do
|
5
|
+
Serif::Site.new(testing_dir)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#source_directory" do
|
9
|
+
it "should be sane" do
|
10
|
+
subject.directory.should == File.join(File.dirname(__FILE__), "site_dir")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#posts" do
|
15
|
+
it "is the number of posts in the site" do
|
16
|
+
subject.posts.length.should == 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#drafts" do
|
21
|
+
it "is the number of drafts in the site" do
|
22
|
+
subject.drafts.length.should == 2
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#latest_update_time" do
|
27
|
+
it "is the latest time that a post was updated" do
|
28
|
+
subject.latest_update_time.should == Serif::Post.all(subject).max_by { |p| p.updated }.updated
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#site_path" do
|
33
|
+
it "should be relative, not absolute" do
|
34
|
+
p = Pathname.new(subject.site_path("foo"))
|
35
|
+
p.relative?.should be_true
|
36
|
+
p.absolute?.should be_false
|
37
|
+
end
|
38
|
+
|
39
|
+
it "takes a string and prepends _site to that path" do
|
40
|
+
%w[a b c d e f].each do |e|
|
41
|
+
subject.site_path(e).should == "_site/#{e}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#config" do
|
47
|
+
it "is a Serif::Config instance" do
|
48
|
+
subject.config.class.should == Serif::Config
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have the permalink format available" do
|
52
|
+
subject.config.permalink.should_not be_nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#archive_url_for_date" do
|
57
|
+
it "uses the archive URL format from the config to construct an archive URL string" do
|
58
|
+
date = Date.parse("2012-01-02")
|
59
|
+
subject.archive_url_for_date(date).should == "/test-archive/2012/01"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#bypass?" do
|
64
|
+
it "is false if the filename has a .html extension" do
|
65
|
+
subject.bypass?("foo.html").should be_false
|
66
|
+
end
|
67
|
+
|
68
|
+
it "is false if the filename has an .xml extension" do
|
69
|
+
subject.bypass?("foo.xml").should be_false
|
70
|
+
end
|
71
|
+
|
72
|
+
it "is true if the filename is neither xml nor html by extension" do
|
73
|
+
subject.bypass?("foo.css").should be_true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#tmp_path" do
|
78
|
+
it "takes a string and prepends tmp/_site to that path" do
|
79
|
+
%w[a b c d].each do |e|
|
80
|
+
subject.tmp_path(e).should == "tmp/_site/#{e}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should be relative, not absolute" do
|
85
|
+
p = Pathname.new(subject.tmp_path("foo"))
|
86
|
+
p.absolute?.should be_false
|
87
|
+
p.relative?.should be_true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require "serif"
|
5
|
+
require "fileutils"
|
6
|
+
require "pathname"
|
7
|
+
require "time"
|
8
|
+
require "date"
|
9
|
+
|
10
|
+
def testing_dir(path = nil)
|
11
|
+
full_path = File.join(File.dirname(__FILE__), "site_dir")
|
12
|
+
|
13
|
+
path ? File.join(full_path, path) : full_path
|
14
|
+
end
|
metadata
CHANGED
@@ -1,221 +1,293 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: serif
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 4045805919941635790
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Adam Prescott
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0.9'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0.9'
|
30
|
-
- !ruby/object:Gem::Dependency
|
17
|
+
|
18
|
+
date: 2012-12-16 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
31
21
|
name: rack
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '1.0'
|
38
|
-
type: :runtime
|
39
22
|
prerelease: false
|
40
|
-
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '1.0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rack-rewrite
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
49
24
|
none: false
|
50
|
-
requirements:
|
25
|
+
requirements:
|
51
26
|
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 4428665182548103036
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: "1.0"
|
54
33
|
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rack-rewrite
|
55
37
|
prerelease: false
|
56
|
-
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
57
39
|
none: false
|
58
|
-
requirements:
|
40
|
+
requirements:
|
59
41
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 1414572536435516772
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 3
|
47
|
+
- 0
|
61
48
|
version: 1.3.0
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: redcarpet
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '2.2'
|
70
49
|
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: redcarpet
|
71
53
|
prerelease: false
|
72
|
-
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '2.2'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: pygments.rb
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
81
55
|
none: false
|
82
|
-
requirements:
|
56
|
+
requirements:
|
83
57
|
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 2242578857099950856
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 2
|
63
|
+
version: "2.2"
|
86
64
|
type: :runtime
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: pygments.rb
|
87
68
|
prerelease: false
|
88
|
-
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0.3'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: sinatra
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
97
70
|
none: false
|
98
|
-
requirements:
|
71
|
+
requirements:
|
99
72
|
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3827694748118640887
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
- 3
|
78
|
+
version: "0.3"
|
102
79
|
type: :runtime
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: sinatra
|
103
83
|
prerelease: false
|
104
|
-
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
105
85
|
none: false
|
106
|
-
requirements:
|
86
|
+
requirements:
|
107
87
|
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 2609263317959306961
|
90
|
+
segments:
|
91
|
+
- 1
|
92
|
+
- 3
|
93
|
+
version: "1.3"
|
94
|
+
type: :runtime
|
95
|
+
version_requirements: *id005
|
96
|
+
- !ruby/object:Gem::Dependency
|
111
97
|
name: redhead
|
112
|
-
|
98
|
+
prerelease: false
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
113
100
|
none: false
|
114
|
-
requirements:
|
101
|
+
requirements:
|
115
102
|
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 3599632081231604877
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
- 0
|
108
|
+
- 6
|
117
109
|
version: 0.0.6
|
118
110
|
type: :runtime
|
111
|
+
version_requirements: *id006
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: liquid
|
119
114
|
prerelease: false
|
120
|
-
|
115
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
121
116
|
none: false
|
122
|
-
requirements:
|
117
|
+
requirements:
|
123
118
|
- - ~>
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 3455750172089947295
|
121
|
+
segments:
|
122
|
+
- 2
|
123
|
+
- 4
|
124
|
+
version: "2.4"
|
125
|
+
type: :runtime
|
126
|
+
version_requirements: *id007
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: slop
|
129
|
+
prerelease: false
|
130
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
129
131
|
none: false
|
130
|
-
requirements:
|
132
|
+
requirements:
|
131
133
|
- - ~>
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 549110733678160813
|
136
|
+
segments:
|
137
|
+
- 3
|
138
|
+
- 3
|
139
|
+
version: "3.3"
|
134
140
|
type: :runtime
|
141
|
+
version_requirements: *id008
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rake
|
135
144
|
prerelease: false
|
136
|
-
|
145
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
137
146
|
none: false
|
138
|
-
requirements:
|
147
|
+
requirements:
|
139
148
|
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
hash: 2854635824043747355
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
- 9
|
154
|
+
version: "0.9"
|
155
|
+
type: :development
|
156
|
+
version_requirements: *id009
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
name: rspec
|
159
|
+
prerelease: false
|
160
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
145
161
|
none: false
|
146
|
-
requirements:
|
162
|
+
requirements:
|
147
163
|
- - ~>
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
|
150
|
-
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
hash: 2619393337634056284
|
166
|
+
segments:
|
167
|
+
- 2
|
168
|
+
- 5
|
169
|
+
version: "2.5"
|
170
|
+
type: :development
|
171
|
+
version_requirements: *id010
|
172
|
+
- !ruby/object:Gem::Dependency
|
173
|
+
name: simplecov
|
151
174
|
prerelease: false
|
152
|
-
|
175
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
153
176
|
none: false
|
154
|
-
requirements:
|
177
|
+
requirements:
|
155
178
|
- - ~>
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
hash: 1678417636739112038
|
181
|
+
segments:
|
182
|
+
- 0
|
183
|
+
- 7
|
184
|
+
version: "0.7"
|
185
|
+
type: :development
|
186
|
+
version_requirements: *id011
|
187
|
+
description: Serif is a simple file-based blogging system which generates static content and allows dynamic editing through an interface.
|
188
|
+
email:
|
161
189
|
- adam@aprescott.com
|
162
|
-
executables:
|
190
|
+
executables:
|
163
191
|
- serif
|
164
192
|
extensions: []
|
193
|
+
|
165
194
|
extra_rdoc_files: []
|
166
|
-
|
167
|
-
|
168
|
-
- lib/serif
|
169
|
-
- lib/serif/markup_renderer.rb
|
195
|
+
|
196
|
+
files:
|
197
|
+
- lib/serif.rb
|
170
198
|
- lib/serif/post.rb
|
171
|
-
- lib/serif/config.rb
|
172
199
|
- lib/serif/admin_server.rb
|
200
|
+
- lib/serif/server.rb
|
201
|
+
- lib/serif/config.rb
|
173
202
|
- lib/serif/draft.rb
|
203
|
+
- lib/serif/markup_renderer.rb
|
174
204
|
- lib/serif/site.rb
|
175
|
-
- lib/serif.rb
|
205
|
+
- lib/serif/content_file.rb
|
206
|
+
- statics/skeleton/index.html
|
207
|
+
- statics/skeleton/_config.yml
|
208
|
+
- statics/skeleton/archive.html
|
209
|
+
- statics/assets/js/mousetrap.min.js
|
210
|
+
- statics/assets/js/jquery.autosize.js
|
176
211
|
- statics/templates/admin/new_draft.liquid
|
177
212
|
- statics/templates/admin/edit_draft.liquid
|
178
213
|
- statics/templates/admin/layout.liquid
|
179
|
-
- statics/templates/admin/index.liquid
|
180
214
|
- statics/templates/admin/edit_post.liquid
|
181
|
-
- statics/
|
182
|
-
- statics/skeleton/_templates/archive_page.html
|
215
|
+
- statics/templates/admin/index.liquid
|
183
216
|
- statics/skeleton/_templates/post.html
|
184
|
-
- statics/skeleton/
|
185
|
-
- statics/skeleton/_config.yml
|
186
|
-
- statics/skeleton/_posts/2012-01-05-sample-post
|
217
|
+
- statics/skeleton/_templates/archive_page.html
|
187
218
|
- statics/skeleton/_layouts/default.html
|
188
|
-
- statics/skeleton/
|
189
|
-
- statics/
|
190
|
-
- statics/assets/js/jquery.autosize.js
|
219
|
+
- statics/skeleton/_posts/2012-01-05-sample-post
|
220
|
+
- statics/skeleton/_drafts/sample-draft
|
191
221
|
- bin/serif
|
222
|
+
- test/test_helper.rb
|
223
|
+
- test/post_spec.rb
|
224
|
+
- test/site_spec.rb
|
225
|
+
- test/draft_spec.rb
|
226
|
+
- test/config_spec.rb
|
227
|
+
- test/markup_renderer_spec.rb
|
228
|
+
- test/liquid_filter_date_extension_spec.rb
|
229
|
+
- test/site_generation_spec.rb
|
230
|
+
- test/filters_spec.rb
|
231
|
+
- test/site_dir/index.html
|
232
|
+
- test/site_dir/_config.yml
|
233
|
+
- test/site_dir/archive.html
|
234
|
+
- test/site_dir/_templates/post.html
|
235
|
+
- test/site_dir/_templates/archive_page.html
|
236
|
+
- test/site_dir/_layouts/default.html
|
237
|
+
- test/site_dir/_posts/2012-01-05-sample-post
|
238
|
+
- test/site_dir/_drafts/another-sample-draft
|
239
|
+
- test/site_dir/_drafts/sample-draft
|
240
|
+
- test/site_dir/_site/index.html
|
241
|
+
- test/site_dir/_site/archive.html
|
242
|
+
- test/site_dir/_trash/1355618409-test-draft
|
243
|
+
- test/site_dir/_site/test-blog/sample-post.html
|
244
|
+
- test/site_dir/_site/test-archive/2012/11/index.html
|
192
245
|
- serif.gemspec
|
246
|
+
- rakefile
|
193
247
|
- LICENSE
|
194
248
|
- Gemfile
|
195
249
|
- Gemfile.lock
|
196
250
|
- README.md
|
197
251
|
homepage: https://github.com/aprescott/serif
|
198
252
|
licenses: []
|
253
|
+
|
199
254
|
post_install_message:
|
200
255
|
rdoc_options: []
|
201
|
-
|
256
|
+
|
257
|
+
require_paths:
|
202
258
|
- lib
|
203
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
259
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
204
260
|
none: false
|
205
|
-
requirements:
|
206
|
-
- -
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
|
209
|
-
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
hash: 2002549777813010636
|
265
|
+
segments:
|
266
|
+
- 0
|
267
|
+
version: "0"
|
268
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
269
|
none: false
|
211
|
-
requirements:
|
212
|
-
- -
|
213
|
-
- !ruby/object:Gem::Version
|
214
|
-
|
270
|
+
requirements:
|
271
|
+
- - ">="
|
272
|
+
- !ruby/object:Gem::Version
|
273
|
+
hash: 2002549777813010636
|
274
|
+
segments:
|
275
|
+
- 0
|
276
|
+
version: "0"
|
215
277
|
requirements: []
|
278
|
+
|
216
279
|
rubyforge_project:
|
217
280
|
rubygems_version: 1.8.24
|
218
281
|
signing_key:
|
219
282
|
specification_version: 3
|
220
283
|
summary: Simple file-based blogging system.
|
221
|
-
test_files:
|
284
|
+
test_files:
|
285
|
+
- test/test_helper.rb
|
286
|
+
- test/post_spec.rb
|
287
|
+
- test/site_spec.rb
|
288
|
+
- test/draft_spec.rb
|
289
|
+
- test/config_spec.rb
|
290
|
+
- test/markup_renderer_spec.rb
|
291
|
+
- test/liquid_filter_date_extension_spec.rb
|
292
|
+
- test/site_generation_spec.rb
|
293
|
+
- test/filters_spec.rb
|