serif 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- serif (0.1.2)
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
+ [![Build Status](https://travis-ci.org/aprescott/serif.png?branch=master)](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/ @not_found_page;
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
@@ -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
- source = File.read(path).gsub(/\r?\n/, "\n")
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
@@ -0,0 +1,11 @@
1
+ require "rake"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:test) do |t|
5
+ t.rspec_opts = "-I test --color --format nested"
6
+ t.pattern = "test/**/*_spec.rb"
7
+ t.verbose = false
8
+ t.fail_on_error = true
9
+ end
10
+
11
+ task :default => :test
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.4"
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/*}"] + %w[serif.gemspec LICENSE Gemfile Gemfile.lock README.md]
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
- #s.test_files = Dir["test/*"]
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
@@ -51,4 +51,13 @@
51
51
  </form>
52
52
  {% endif %}
53
53
 
54
- </div>
54
+ </div>
55
+
56
+
57
+ <script>
58
+ $(function() {
59
+ window.onbeforeunload = function() {
60
+ return "You may lose unsaved changes if you leave this page.";
61
+ }
62
+ });
63
+ </script>
@@ -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>
@@ -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
@@ -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,3 @@
1
+ title: another sample draft
2
+
3
+ another-sample-draft
@@ -0,0 +1,3 @@
1
+ title: Sample draft
2
+
3
+ Just a sample draft.
@@ -0,0 +1,6 @@
1
+ <!doctype html>
2
+ <meta charset="UTF-8">
3
+ <title>My site: {% if page.title and page.title != empty %}{{ page.title | join:" - " }}{% endif %}</title>
4
+ <h1>mysite.com</h1>
5
+
6
+ {{ content }}
@@ -0,0 +1,4 @@
1
+ title: Sample post
2
+ Created: 2012-11-21T17:07:09+00:00
3
+
4
+ Just a sample post.
@@ -0,0 +1,11 @@
1
+ <!doctype html>
2
+ <meta charset="UTF-8">
3
+ <title>My site: </title>
4
+ <h1>mysite.com</h1>
5
+
6
+
7
+
8
+ <h1>
9
+ <a href="/test-archive/2012/11">November 2012</a>
10
+ </h1>
11
+
@@ -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,14 @@
1
+ <!doctype html>
2
+ <meta charset="UTF-8">
3
+ <title>My site: </title>
4
+ <h1>mysite.com</h1>
5
+
6
+ <h1>Nov 2012 (1)</h1>
7
+
8
+ <ul>
9
+
10
+ <li>
11
+ <a href="/test-blog/sample-post">Sample post</a>
12
+ </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&amp;url=http%3A%2F%2Fwww.mysite.com%2Ftest-blog%2Fsample-post">Submit this to Twitter.</p>
@@ -0,0 +1,9 @@
1
+ <h1>{{ month | date: "%b %Y" }} ({{ posts | size }})</h1>
2
+
3
+ <ul>
4
+ {% for post in posts %}
5
+ <li>
6
+ <a href="{{ post.url }}">{{ post.title }}</a>
7
+ </li>
8
+ {% endfor %}
9
+ </ul>
@@ -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 }}&amp;url={{ 'http://www.mysite.com' | encode_uri_component }}{{ post.url | encode_uri_component }}">Submit this to Twitter.</p>
@@ -0,0 +1,3 @@
1
+ title: Some draft title
2
+
3
+ some content
@@ -0,0 +1,7 @@
1
+ {% for year in site.archive.years %}
2
+ {% for month in year.months %}
3
+ <h1>
4
+ <a href="{{ month.archive_url }}">{{ month.date | date: "%B %Y" }}</a>
5
+ </h1>
6
+ {% endfor %}
7
+ {% endfor %}
@@ -0,0 +1,9 @@
1
+ <h2>Posts</h2>
2
+
3
+ <p>There are {{ site.posts.size }} posts:</p>
4
+
5
+ <ul>
6
+ {% for post in site.posts %}
7
+ <li><a href="{{ post.url | escape }}">{{ post.title | escape }}</a> (posted {{ post.created | xmlschema }})</li>
8
+ {% endfor %}
9
+ </ul>
@@ -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
@@ -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
- version: 0.1.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
- date: 2012-12-01 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rake
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
- version_requirements: !ruby/object:Gem::Requirement
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
- version: 1.3.0
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
- version_requirements: !ruby/object:Gem::Requirement
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
- version_requirements: !ruby/object:Gem::Requirement
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
- version: '0.3'
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
- version_requirements: !ruby/object:Gem::Requirement
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
- version: '1.3'
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
- version_requirements: !ruby/object:Gem::Requirement
84
+ requirement: &id005 !ruby/object:Gem::Requirement
105
85
  none: false
106
- requirements:
86
+ requirements:
107
87
  - - ~>
108
- - !ruby/object:Gem::Version
109
- version: '1.3'
110
- - !ruby/object:Gem::Dependency
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
- requirement: !ruby/object:Gem::Requirement
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
- version_requirements: !ruby/object:Gem::Requirement
115
+ requirement: &id007 !ruby/object:Gem::Requirement
121
116
  none: false
122
- requirements:
117
+ requirements:
123
118
  - - ~>
124
- - !ruby/object:Gem::Version
125
- version: 0.0.6
126
- - !ruby/object:Gem::Dependency
127
- name: liquid
128
- requirement: !ruby/object:Gem::Requirement
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
- version: '2.4'
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
- version_requirements: !ruby/object:Gem::Requirement
145
+ requirement: &id009 !ruby/object:Gem::Requirement
137
146
  none: false
138
- requirements:
147
+ requirements:
139
148
  - - ~>
140
- - !ruby/object:Gem::Version
141
- version: '2.4'
142
- - !ruby/object:Gem::Dependency
143
- name: slop
144
- requirement: !ruby/object:Gem::Requirement
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
- version: '3.3'
150
- type: :runtime
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
- version_requirements: !ruby/object:Gem::Requirement
175
+ requirement: &id011 !ruby/object:Gem::Requirement
153
176
  none: false
154
- requirements:
177
+ requirements:
155
178
  - - ~>
156
- - !ruby/object:Gem::Version
157
- version: '3.3'
158
- description: Serif is a simple file-based blogging system which generates static content
159
- and allows dynamic editing through an interface.
160
- email:
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
- files:
167
- - lib/serif/content_file.rb
168
- - lib/serif/server.rb
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/skeleton/index.html
182
- - statics/skeleton/_templates/archive_page.html
215
+ - statics/templates/admin/index.liquid
183
216
  - statics/skeleton/_templates/post.html
184
- - statics/skeleton/_drafts/sample-draft
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/archive.html
189
- - statics/assets/js/mousetrap.min.js
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
- require_paths:
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
- version: '0'
209
- required_rubygems_version: !ruby/object:Gem::Requirement
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
- version: '0'
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