serious 0.2.2 → 0.2.3
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/README.rdoc +13 -6
- data/VERSION +1 -1
- data/bin/serious +9 -0
- data/lib/serious/page.rb +32 -0
- data/lib/serious.rb +17 -2
- data/lib/site/public/css/serious.css +2 -1
- data/lib/site/views/_archives.erb +3 -1
- data/lib/site/views/_article.erb +7 -3
- data/lib/site/views/archives.erb +1 -1
- data/lib/site/views/index.erb +5 -0
- data/lib/site/views/layout.erb +1 -0
- data/serious.gemspec +7 -2
- data/test/helper.rb +1 -0
- data/test/pages/about.txt +5 -0
- data/test/pages/foo-bar.txt +3 -0
- data/test/test_bin.rb +6 -0
- data/test/test_page.rb +101 -0
- data/test/test_serious.rb +49 -1
- metadata +6 -1
data/README.rdoc
CHANGED
@@ -56,7 +56,9 @@ The directory basic directory structure of your Serious site would be something
|
|
56
56
|
|
57
57
|
serious_blog/
|
58
58
|
- articles
|
59
|
-
-
|
59
|
+
- 2010-02-14-will-you-be-my-valentine.txt
|
60
|
+
- pages
|
61
|
+
- about.txt
|
60
62
|
- config.ru
|
61
63
|
- .gems
|
62
64
|
- Rakefile
|
@@ -73,14 +75,11 @@ The .gems file if you want to host on heroku:
|
|
73
75
|
|
74
76
|
serious
|
75
77
|
|
76
|
-
|
77
|
-
will install it as a gem dependency on other systems as well.
|
78
|
-
|
79
|
-
The Rakefile, which is obviously totally optional but highly recommended.
|
78
|
+
The Rakefile, which is obviously totally optional but highly recommended looks like this:
|
80
79
|
|
81
80
|
require 'serious'
|
82
81
|
require 'serious/tasks'
|
83
|
-
|
82
|
+
|
84
83
|
== Creating heroku app manually
|
85
84
|
|
86
85
|
Assuming you've got the heroku gem installed and set up and you've set up git for your blog with
|
@@ -108,6 +107,14 @@ The whole archives can be accessed at <code>/archives</code>. Archives by year,
|
|
108
107
|
are available at <code>/2009</code> (all of 2009), <code>/2009/05</code> (May 2009),
|
109
108
|
<code>/2009/05/15</code> (May 15th 2009).
|
110
109
|
|
110
|
+
== Static pages
|
111
|
+
|
112
|
+
Static pages are quite similar to blog articles, in that their formatting and processing is the same.
|
113
|
+
They have a yaml front matter, content that gets piped through the StupidFormatter and so on.
|
114
|
+
The filename sans the extension serves as the permalink, pages can be reached via
|
115
|
+
<code>/pages/PERMALINK</code>, so the content in pages/about.txt will be served at
|
116
|
+
<code>/pages/about</code>
|
117
|
+
|
111
118
|
== Rake tasks
|
112
119
|
|
113
120
|
If you've set up the Rakefile in your site's main directory like mentioned above (this happens
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/bin/serious
CHANGED
@@ -33,6 +33,7 @@ require 'fileutils'
|
|
33
33
|
puts "Creating directory #{DIRNAME}"
|
34
34
|
ORIGINAL_DIR = Dir.getwd
|
35
35
|
FileUtils.mkdir_p(File.join(DIRNAME, 'articles'))
|
36
|
+
FileUtils.mkdir_p(File.join(DIRNAME, 'pages'))
|
36
37
|
Dir.chdir(DIRNAME)
|
37
38
|
|
38
39
|
GEM_ROOT = File.join(File.dirname(__FILE__), '..')
|
@@ -66,6 +67,14 @@ end
|
|
66
67
|
copy_views if views?
|
67
68
|
copy_public if public?
|
68
69
|
|
70
|
+
puts "Writing about page"
|
71
|
+
|
72
|
+
File.open('pages/about.txt', "w+") do |about|
|
73
|
+
about.puts "title: About"
|
74
|
+
about.puts
|
75
|
+
about.puts "Something about you"
|
76
|
+
end
|
77
|
+
|
69
78
|
puts "Writing config.ru"
|
70
79
|
File.open('config.ru', 'w+') do |config|
|
71
80
|
config.puts "require 'serious'"
|
data/lib/serious/page.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
class Serious::Page < Serious::Article
|
2
|
+
class << self
|
3
|
+
#
|
4
|
+
# Returns all pages
|
5
|
+
#
|
6
|
+
def all
|
7
|
+
@pages ||= page_paths.map { |path| new(path) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(permalink)
|
11
|
+
all.find_all {|page| page.permalink == permalink }.first
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
# Returns all page files in pages path
|
17
|
+
def page_paths
|
18
|
+
@pages_paths ||= Dir[File.join(Serious.pages, '*')].sort
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def url
|
23
|
+
"/pages/#{permalink}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# Will extract the permalink from the filename.
|
29
|
+
def extract_date_and_permalink!
|
30
|
+
@permalink = File.basename(path).split('.')[0...-1].join("")
|
31
|
+
end
|
32
|
+
end
|
data/lib/serious.rb
CHANGED
@@ -10,6 +10,7 @@ require 'ruby_ext'
|
|
10
10
|
class Serious < Sinatra::Base
|
11
11
|
|
12
12
|
set :articles, Proc.new { File.join(Dir.getwd, 'articles') }
|
13
|
+
set :pages, Proc.new { File.join(Dir.getwd, 'pages') }
|
13
14
|
set :static, true # Required to serve static files, see http://www.sinatrarb.com/configuration.html
|
14
15
|
|
15
16
|
not_found do
|
@@ -55,18 +56,32 @@ class Serious < Sinatra::Base
|
|
55
56
|
|
56
57
|
# Archives route
|
57
58
|
get %r{^/(\d{4})[/]{0,1}(\d{0,2})[/]{0,1}(\d{0,2})[/]{0,1}$} do
|
58
|
-
|
59
|
-
@articles = Article.find(
|
59
|
+
selection = params[:captures].reject {|s| s.strip.length == 0 }.map {|n| n.length == 1 ? "%02d" % n : n}
|
60
|
+
@articles = Article.find(*selection)
|
61
|
+
@title = "Archives for #{selection.join("-")}"
|
60
62
|
erb :archives
|
61
63
|
end
|
62
64
|
|
63
65
|
get "/archives" do
|
64
66
|
@articles = Article.all
|
67
|
+
@title = "Archives"
|
65
68
|
erb :archives
|
66
69
|
end
|
70
|
+
|
71
|
+
get "/pages" do
|
72
|
+
@articles = Page.all
|
73
|
+
@title = "Pages"
|
74
|
+
erb :archives
|
75
|
+
end
|
76
|
+
|
77
|
+
get "/pages/:page" do
|
78
|
+
halt 404 unless @article = Page.find(params[:page])
|
79
|
+
render_article @article
|
80
|
+
end
|
67
81
|
end
|
68
82
|
|
69
83
|
require 'serious/article'
|
84
|
+
require 'serious/page'
|
70
85
|
# Set up default stupid_formatter chain
|
71
86
|
StupidFormatter.chain = [StupidFormatter::Erb, StupidFormatter::RDiscount]
|
72
87
|
|
@@ -2,7 +2,9 @@
|
|
2
2
|
<% articles.each do |article| %>
|
3
3
|
<li>
|
4
4
|
<a href="<%= article.url %>"><%= article.title %></a>
|
5
|
-
|
5
|
+
<% if article.date %>
|
6
|
+
<span class="date"><%= article.date.formatted %></span>
|
7
|
+
<% end %>
|
6
8
|
</li>
|
7
9
|
<% end %>
|
8
10
|
</ul>
|
data/lib/site/views/_article.erb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
<div class="article">
|
2
|
-
|
2
|
+
<% if article.date %>
|
3
|
+
<span class="date right"><%= article.date.formatted %></span>
|
4
|
+
<% end %>
|
3
5
|
<h2><a href="<%= article.url %>"><%= article.title %></a></h2>
|
4
6
|
<div class="body">
|
5
7
|
<% if summary_only %>
|
@@ -7,9 +9,11 @@
|
|
7
9
|
<span class="right date"><a href="<%= article.url %>">read on...</a></span>
|
8
10
|
<% else %>
|
9
11
|
<%= article.body.formatted %>
|
10
|
-
<span class="author right">Written by <%= article.author %></span>
|
11
12
|
|
12
|
-
|
13
|
+
<% if article.instance_of?(Serious::Article) %>
|
14
|
+
<span class="author right">Written by <%= article.author %></span>
|
15
|
+
<%= render_partial :disqus if Serious.disqus %>
|
16
|
+
<% end %>
|
13
17
|
<% end %>
|
14
18
|
</div>
|
15
19
|
|
data/lib/site/views/archives.erb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
<h2
|
1
|
+
<h2><%= @title %></h2>
|
2
2
|
<%= render_archived @articles %>
|
data/lib/site/views/index.erb
CHANGED
data/lib/site/views/layout.erb
CHANGED
data/serious.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{serious}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Christoph Olszowka"]
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/ruby_ext.rb",
|
30
30
|
"lib/serious.rb",
|
31
31
|
"lib/serious/article.rb",
|
32
|
+
"lib/serious/page.rb",
|
32
33
|
"lib/serious/tasks.rb",
|
33
34
|
"lib/site/public/css/coderay.css",
|
34
35
|
"lib/site/public/css/serious.css",
|
@@ -49,8 +50,11 @@ Gem::Specification.new do |s|
|
|
49
50
|
"test/articles/2009-12-11-ruby-is-the-shit.txt",
|
50
51
|
"test/articles/2009-12-24-merry-christmas.txt",
|
51
52
|
"test/helper.rb",
|
53
|
+
"test/pages/about.txt",
|
54
|
+
"test/pages/foo-bar.txt",
|
52
55
|
"test/test_article.rb",
|
53
56
|
"test/test_bin.rb",
|
57
|
+
"test/test_page.rb",
|
54
58
|
"test/test_ruby_ext.rb",
|
55
59
|
"test/test_serious.rb"
|
56
60
|
]
|
@@ -60,7 +64,8 @@ Gem::Specification.new do |s|
|
|
60
64
|
s.rubygems_version = %q{1.3.5}
|
61
65
|
s.summary = %q{Serious is a simple, file-driven blog engine inspired by toto and driven by sinatra}
|
62
66
|
s.test_files = [
|
63
|
-
"test/
|
67
|
+
"test/test_page.rb",
|
68
|
+
"test/test_bin.rb",
|
64
69
|
"test/test_serious.rb",
|
65
70
|
"test/helper.rb",
|
66
71
|
"test/test_ruby_ext.rb",
|
data/test/helper.rb
CHANGED
@@ -12,6 +12,7 @@ class Test::Unit::TestCase
|
|
12
12
|
include Rack::Test::Methods
|
13
13
|
Serious.set :title, "Serious Test Blog"
|
14
14
|
Serious.set :articles, File.join(File.dirname(__FILE__), 'articles')
|
15
|
+
Serious.set :pages, File.join(File.dirname(__FILE__), 'pages')
|
15
16
|
Serious.set :author, "TheDeadSerious"
|
16
17
|
Serious.set :url, 'http://example.com'
|
17
18
|
StupidFormatter.chain = [StupidFormatter::Erb, StupidFormatter::RDiscount]
|
data/test/test_bin.rb
CHANGED
@@ -37,6 +37,7 @@ class TestBin < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
when_running_serious_with 'foo' do
|
39
39
|
should_have_dir 'foo/articles'
|
40
|
+
should_have_dir 'foo/pages'
|
40
41
|
should_have_dir 'foo/.git'
|
41
42
|
should_have_file 'foo/.gems', 'serious --version'
|
42
43
|
should_not_have_path 'foo/public'
|
@@ -48,6 +49,11 @@ class TestBin < Test::Unit::TestCase
|
|
48
49
|
Dir.chdir('..')
|
49
50
|
end
|
50
51
|
|
52
|
+
should_have_file 'foo/pages/about.txt' do |file|
|
53
|
+
should_contain "title: About", file
|
54
|
+
should_contain "Something about you", file
|
55
|
+
end
|
56
|
+
|
51
57
|
should_have_file 'foo/config.ru' do |file|
|
52
58
|
should_contain "require 'serious'", file
|
53
59
|
should_contain "Serious.set :title, 'foo'", file
|
data/test/test_page.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestPage < Test::Unit::TestCase
|
4
|
+
# ========================================================================
|
5
|
+
# Tests for all pages
|
6
|
+
# ========================================================================
|
7
|
+
context "Serious::Page.all" do
|
8
|
+
setup do
|
9
|
+
@pages = Serious::Page.all
|
10
|
+
end
|
11
|
+
|
12
|
+
should("return 2 pages") { assert_equal 2, @pages.length }
|
13
|
+
should "have only instances of Serious::Page in the collection" do
|
14
|
+
assert @pages.all? {|a| a.instance_of?(Serious::Page) }
|
15
|
+
end
|
16
|
+
|
17
|
+
should "return an existing path for all pages" do
|
18
|
+
assert @pages.all? {|p| File.exist? p.path }
|
19
|
+
end
|
20
|
+
|
21
|
+
should "not have instance variable @yaml set on any page" do
|
22
|
+
@pages.each do |page|
|
23
|
+
assert_nil page.instance_variable_get(:@yaml)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
should "not have instance variable @content set on any page" do
|
28
|
+
@pages.each do |page|
|
29
|
+
assert_nil page.instance_variable_get(:@content)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# ========================================================================
|
35
|
+
# Tests for initializer and extracting permalink from path
|
36
|
+
# ========================================================================
|
37
|
+
context "Serious::Page.new('foo-bar.txt')" do
|
38
|
+
setup do
|
39
|
+
@page = Serious::Page.new('foo-bar.txt')
|
40
|
+
end
|
41
|
+
|
42
|
+
should "return permalink 'foo-bar'" do
|
43
|
+
assert_equal 'foo-bar', @page.permalink
|
44
|
+
end
|
45
|
+
|
46
|
+
should "return '/pages/foo-bar' as url" do
|
47
|
+
assert_equal '/pages/foo-bar', @page.url
|
48
|
+
end
|
49
|
+
|
50
|
+
should "return 'http://example.com/pages/foo-bar' as full_url" do
|
51
|
+
assert_equal 'http://example.com/pages/foo-bar', @page.full_url
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# ========================================================================
|
56
|
+
# Tests for dynamic loading and processing of title, summary and body
|
57
|
+
# ========================================================================
|
58
|
+
context "The page 'about'" do
|
59
|
+
setup do
|
60
|
+
@page = Serious::Page.find('about')
|
61
|
+
end
|
62
|
+
|
63
|
+
context "after getting the page's title" do
|
64
|
+
setup { @title = @page.title }
|
65
|
+
|
66
|
+
should "have returned 'About me'" do
|
67
|
+
assert_equal 'About me', @title
|
68
|
+
end
|
69
|
+
|
70
|
+
should "have initialized the @yaml instance variable to a hash" do
|
71
|
+
assert @page.instance_variable_get(:@yaml).kind_of?(Hash)
|
72
|
+
end
|
73
|
+
|
74
|
+
should "have initialized the @content instance variable to a string" do
|
75
|
+
assert @page.instance_variable_get(:@content).kind_of?(String)
|
76
|
+
end
|
77
|
+
|
78
|
+
should "have summary set to 'Some text about me'" do
|
79
|
+
assert_equal 'Some text about me', @page.summary
|
80
|
+
end
|
81
|
+
|
82
|
+
should 'have formatted body set to "<p>Some text about me</p>\n\n<p>And some more content with erb</p>\n"' do
|
83
|
+
assert_equal "<p>Some text about me</p>\n\n<p>And some more content with erb</p>\n", @page.body.formatted
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "The page 'foo-bar'" do
|
89
|
+
setup do
|
90
|
+
@page = Serious::Page.find('foo-bar')
|
91
|
+
end
|
92
|
+
|
93
|
+
should "be valid" do
|
94
|
+
assert @page.valid?
|
95
|
+
end
|
96
|
+
should("have title 'Foo Bar'") { assert_equal 'Foo Bar', @page.title }
|
97
|
+
should('have summary "Baz!"') { assert_equal "Baz!", @page.summary }
|
98
|
+
should('have body "Baz!"') { assert_equal "Baz!", @page.body }
|
99
|
+
should('have summary equal to body') { assert_equal @page.summary, @page.body}
|
100
|
+
end
|
101
|
+
end
|
data/test/test_serious.rb
CHANGED
@@ -27,8 +27,12 @@ class TestSerious < Test::Unit::TestCase
|
|
27
27
|
should_contain_text "Foo Bar", "ul#articles"
|
28
28
|
should_contain_text "Serious Test Blog", "head title"
|
29
29
|
|
30
|
-
should_contain_elements 1, "ul.archives li"
|
30
|
+
should_contain_elements 1, "ul.archives:first li"
|
31
31
|
should_contain_text "Disco 2000", "ul.archives li:first"
|
32
|
+
|
33
|
+
should_contain_text "Pages", "h3"
|
34
|
+
should_contain_elements 2, "ul.archives:last li"
|
35
|
+
should_contain_text "About me", "ul.archives:last li:first"
|
32
36
|
end
|
33
37
|
|
34
38
|
# ===================================================================
|
@@ -133,6 +137,7 @@ class TestSerious < Test::Unit::TestCase
|
|
133
137
|
should_contain_text "Merry Christmas! - Serious Test Blog", "head title"
|
134
138
|
should_contain_text "Merry christmas, dear reader!", ".article .body"
|
135
139
|
should_contain_text "Lorem ipsum dolor...", ".article .body"
|
140
|
+
should_contain_elements 1, ".article span.author"
|
136
141
|
end
|
137
142
|
|
138
143
|
context "GET /2009/12/11/ruby-is-the-shit" do
|
@@ -204,6 +209,14 @@ class TestSerious < Test::Unit::TestCase
|
|
204
209
|
should_contain_text "View the discussion thread.", "#container .article noscript"
|
205
210
|
should_contain_elements 1, "#container #disqus_thread"
|
206
211
|
end
|
212
|
+
|
213
|
+
context "GET /pages/about" do
|
214
|
+
setup { get '/pages/about' }
|
215
|
+
|
216
|
+
should_respond_with 200
|
217
|
+
should_set_cache_control_to 300
|
218
|
+
should_contain_elements 0, "#container #disqus_thread"
|
219
|
+
end
|
207
220
|
end
|
208
221
|
|
209
222
|
context "With disqus inactive" do
|
@@ -265,4 +278,39 @@ class TestSerious < Test::Unit::TestCase
|
|
265
278
|
end
|
266
279
|
end
|
267
280
|
|
281
|
+
|
282
|
+
|
283
|
+
# ===================================================================
|
284
|
+
# Tests for pages
|
285
|
+
# ===================================================================
|
286
|
+
context "GET /pages" do
|
287
|
+
setup { get '/pages' }
|
288
|
+
should_respond_with 200
|
289
|
+
should_set_cache_control_to 300
|
290
|
+
|
291
|
+
should_contain_elements 2, "ul.archives li"
|
292
|
+
should_contain_text "About me", "ul.archives li:first"
|
293
|
+
end
|
294
|
+
|
295
|
+
context "GET /pages/" do
|
296
|
+
setup { get '/pages/' }
|
297
|
+
should_respond_with 200
|
298
|
+
end if 1 == 2
|
299
|
+
|
300
|
+
context "GET /pages/about" do
|
301
|
+
setup { get '/pages/about' }
|
302
|
+
|
303
|
+
should_respond_with 200
|
304
|
+
should_set_cache_control_to 300
|
305
|
+
|
306
|
+
should_contain_text "About me", "#container .article h2"
|
307
|
+
should_contain_text "Some text about me", "#container .article .body"
|
308
|
+
should_contain_elements 0, ".article span.author"
|
309
|
+
should_contain_text "And some more content with erb", "#container .article .body"
|
310
|
+
end
|
311
|
+
|
312
|
+
context "GET /pages/about/" do
|
313
|
+
setup { get '/pages/about/' }
|
314
|
+
should_respond_with 200
|
315
|
+
end if 1 == 2 # TODO: FIXME
|
268
316
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christoph Olszowka
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/ruby_ext.rb
|
93
93
|
- lib/serious.rb
|
94
94
|
- lib/serious/article.rb
|
95
|
+
- lib/serious/page.rb
|
95
96
|
- lib/serious/tasks.rb
|
96
97
|
- lib/site/public/css/coderay.css
|
97
98
|
- lib/site/public/css/serious.css
|
@@ -112,8 +113,11 @@ files:
|
|
112
113
|
- test/articles/2009-12-11-ruby-is-the-shit.txt
|
113
114
|
- test/articles/2009-12-24-merry-christmas.txt
|
114
115
|
- test/helper.rb
|
116
|
+
- test/pages/about.txt
|
117
|
+
- test/pages/foo-bar.txt
|
115
118
|
- test/test_article.rb
|
116
119
|
- test/test_bin.rb
|
120
|
+
- test/test_page.rb
|
117
121
|
- test/test_ruby_ext.rb
|
118
122
|
- test/test_serious.rb
|
119
123
|
has_rdoc: true
|
@@ -145,6 +149,7 @@ signing_key:
|
|
145
149
|
specification_version: 3
|
146
150
|
summary: Serious is a simple, file-driven blog engine inspired by toto and driven by sinatra
|
147
151
|
test_files:
|
152
|
+
- test/test_page.rb
|
148
153
|
- test/test_bin.rb
|
149
154
|
- test/test_serious.rb
|
150
155
|
- test/helper.rb
|