ruby-slippers 0.0.13 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -6
- data/VERSION +1 -1
- data/lib/ruby_slippers/article.rb +6 -1
- data/test/fixtures/articles/2011-05-18-ozma-of-oz.txt +1 -1
- data/test/fixtures/pages/about.rhtml +1 -1
- data/test/fixtures/pages/archives.rhtml +9 -3
- data/test/fixtures/pages/article.rhtml +27 -3
- data/test/fixtures/pages/index.rhtml +26 -12
- data/test/fixtures/pages/tagged.rhtml +1 -1
- data/test/integration/article_test.rb +41 -34
- data/test/integration/atom_test.rb +21 -16
- data/test/integration/ruby_slippers_test.rb +50 -57
- data/test/unit/article_test.rb +2 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -6,11 +6,7 @@ RubySlippers, the smartest blogging engine in all of Oz!
|
|
6
6
|
Introduction
|
7
7
|
------------
|
8
8
|
|
9
|
-
|
10
|
-
For Developers
|
11
|
-
--------------
|
12
|
-
|
13
|
-
#### To set up a new blog
|
9
|
+
### To set up a new blog
|
14
10
|
|
15
11
|
$ git clone git://github.com/dreamr/ruby-slippers.git myblog
|
16
12
|
$ cd myblog
|
@@ -22,7 +18,7 @@ For Developers
|
|
22
18
|
$ Blog installed!
|
23
19
|
|
24
20
|
|
25
|
-
|
21
|
+
### To create an article
|
26
22
|
|
27
23
|
$ rake new
|
28
24
|
$ -> Title: My new blog post!
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.25
|
@@ -72,13 +72,18 @@ module RubySlippers
|
|
72
72
|
"<a href=\"/tagged/#{tag.strip.slugize}\">#{tag.strip.humanize.downcase}</a>"
|
73
73
|
end.join(@config[:tag_separator])
|
74
74
|
end
|
75
|
+
|
76
|
+
def full_image_path
|
77
|
+
self[:date].strftime("/img/articles/%Y/%B/#{self[:image]}").downcase
|
78
|
+
end
|
75
79
|
|
76
80
|
def title() self[:title] || "an article" end
|
77
81
|
def date() @config[:date].call(self[:date]) end
|
78
82
|
def author() self[:author] || @config[:author] end
|
79
|
-
def image_src()
|
83
|
+
def image_src() full_image_path end
|
80
84
|
def to_html() self.load; super(:article, @config) end
|
81
85
|
alias :to_s to_html
|
86
|
+
|
82
87
|
end
|
83
88
|
end
|
84
89
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
title: Ozma of Oz
|
2
2
|
date: 18/05/2011
|
3
3
|
tags: ozma, oz
|
4
|
-
image:
|
4
|
+
image: ozma.png
|
5
5
|
|
6
6
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
7
7
|
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Fill me in with your about info!
|
@@ -1,5 +1,11 @@
|
|
1
1
|
<h1><%= @path %></h1>
|
2
|
-
|
3
|
-
|
4
|
-
<%
|
2
|
+
<ul>
|
3
|
+
<% if archives.length > 0 %>
|
4
|
+
<% for article in archives %>
|
5
|
+
<li class="article">
|
6
|
+
<a href="<%= article.path %>"><%= article.title %></a>
|
7
|
+
</li>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
5
11
|
|
@@ -1,4 +1,28 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
<
|
1
|
+
<article class="article">
|
2
|
+
<header>
|
3
|
+
<h1><%= title %></h1>
|
4
|
+
<span class="date"><%= date %></span>
|
5
|
+
</header>
|
6
|
+
|
7
|
+
|
8
|
+
<% if image_src %>
|
9
|
+
<figure>
|
10
|
+
<img src="<%= image_src || '/img/missing_thumb.png' %>" alt="Post thumbnail" class="thumbnail alignleft" />
|
11
|
+
</figure>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
|
15
|
+
<section class="content">
|
16
|
+
<%= body %>
|
17
|
+
</section>
|
18
|
+
|
19
|
+
<section class="comments">
|
20
|
+
<% if @config[:disqus] %>
|
21
|
+
<div id="disqus_thread"></div>
|
22
|
+
<script type="text/javascript" src="http://disqus.com/forums/<%= @config[:disqus] %>/embed.js"> </script>
|
23
|
+
<noscript><a href="http://<%= @config[:disqus] %>.disqus.com/?url=ref">View the discussion thread.</a></noscript>
|
24
|
+
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
|
25
|
+
<% end %>
|
26
|
+
</section>
|
27
|
+
</article>
|
4
28
|
|
@@ -1,13 +1,27 @@
|
|
1
|
-
<
|
2
|
-
<% for article in articles[0...
|
3
|
-
<
|
1
|
+
<section id="articles">
|
2
|
+
<% for article in articles[0...3] %>
|
3
|
+
<article class="article">
|
4
|
+
<header>
|
5
|
+
<h1><a href="<%= article.path %>"><%= article.title %></a></h1>
|
6
|
+
<span class="date"><%= article.date %></span>
|
7
|
+
</header>
|
8
|
+
|
9
|
+
<% if article.image_src %>
|
10
|
+
<figure>
|
11
|
+
<img src="<%= article.image_src || '/img/missing_thumb.png' %>" alt="Post thumbnail" class="thumbnail alignleft" />
|
12
|
+
</figure>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<section class="content">
|
16
|
+
<%= article.summary %>
|
17
|
+
</section>
|
18
|
+
|
19
|
+
<footer>
|
20
|
+
<div class="more-link"><a href="<%= article.path %>">read on »</a></div>
|
21
|
+
<span class="meta">
|
22
|
+
<p>Posted by <%= article.author %> in <%= article.tag_links %> on <%= article.date %></p>
|
23
|
+
</div>
|
24
|
+
</footer>
|
25
|
+
</article>
|
4
26
|
<% end %>
|
5
|
-
</
|
6
|
-
<div id="archives">
|
7
|
-
<%= archives[2...5] %>
|
8
|
-
</div>
|
9
|
-
<!-- testing env variable passing -->
|
10
|
-
<p>env passed: <%= env != nil %><br/></p>
|
11
|
-
<!-- testing get/post parameter passing -->
|
12
|
-
<p>request method type: <%= env['REQUEST_METHOD'] %><br/></p>
|
13
|
-
<p>request name value pair: <%= env['QUERY_STRING'] %><br/></p>
|
27
|
+
</section>
|
@@ -1,44 +1,51 @@
|
|
1
1
|
require 'support/test_helper'
|
2
|
-
context RubySlippers::Engine::Article do
|
3
|
-
setup do
|
4
|
-
@config = RubySlippers::Engine::Config.new(:markdown => true, :author => AUTHOR, :url => URL)
|
5
|
-
@ruby_slippers = Rack::MockRequest.new(RubySlippers::Engine::App.new(@config))
|
6
|
-
RubySlippers::Engine::Paths[:articles] = "test/fixtures/articles"
|
7
|
-
RubySlippers::Engine::Paths[:pages] = "test/fixtures/pages"
|
8
|
-
RubySlippers::Engine::Paths[:templates] = "test/fixtures/templates"
|
9
|
-
end
|
10
|
-
|
11
|
-
context "GET a single article" do
|
12
|
-
setup { @ruby_slippers.get("/2010/05/17/the-wonderful-wizard-of-oz") }
|
13
|
-
asserts("returns a 200") { topic.status }.equals 200
|
14
|
-
asserts("content type is set properly") { topic.content_type }.equals "text/html"
|
15
|
-
should("contain the article") { topic.body }.includes_html("p" => /Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum./)
|
16
|
-
end
|
17
2
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
module RubySlippers::Engine
|
4
|
+
context Article do
|
5
|
+
setup do
|
6
|
+
@config = RubySlippers::Engine::Config.new(:markdown => true, :author => AUTHOR, :url => URL)
|
7
|
+
@ruby_slippers = Rack::MockRequest.new(RubySlippers::Engine::App.new(@config))
|
8
|
+
|
9
|
+
RubySlippers::Engine::Paths[:articles] = "test/fixtures/articles"
|
10
|
+
if File.expand_path("../../", __FILE__) =~ /engine/
|
11
|
+
RubySlippers::Engine::Paths[:templates] = "test/fixtures/templates"
|
12
|
+
RubySlippers::Engine::Paths[:pages] = "test/fixtures/pages"
|
13
|
+
end
|
23
14
|
end
|
24
15
|
|
25
|
-
context "
|
26
|
-
setup { @ruby_slippers.get(
|
27
|
-
asserts("returns a 200")
|
28
|
-
|
29
|
-
should("
|
16
|
+
context "GET a single article" do
|
17
|
+
setup { @ruby_slippers.get("/2010/05/17/the-wonderful-wizard-of-oz") }
|
18
|
+
asserts("returns a 200") { topic.status }.equals 200
|
19
|
+
asserts("content type is set properly") { topic.content_type }.equals "text/html"
|
20
|
+
should("contain the article") { topic.body }.includes_html("p" => /Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum./)
|
30
21
|
end
|
31
22
|
|
32
|
-
context "
|
33
|
-
|
23
|
+
context "GET to the archive" do
|
24
|
+
context "through a year" do
|
25
|
+
setup { @ruby_slippers.get('/2011') }
|
26
|
+
asserts("returns a 200") { topic.status }.equals 200
|
27
|
+
should("includes the entries for that year") { topic.body }.includes_elements("li.article", 1)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "through a year & month" do
|
31
|
+
setup { @ruby_slippers.get('/2011/05') }
|
32
|
+
asserts("returns a 200") { topic.status }.equals 200
|
33
|
+
should("includes the entries for that month") { topic.body }.includes_elements("li.article", 1)
|
34
|
+
should("includes the year & month") { topic.body }.includes_html("h1" => /2011\/05/)
|
35
|
+
end
|
36
|
+
|
37
|
+
context "through /archives" do
|
38
|
+
setup { @ruby_slippers.get('/archives') }
|
39
|
+
end
|
34
40
|
end
|
35
|
-
end
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
context "GET the tagged page" do
|
43
|
+
setup { @ruby_slippers.get('/tagged/wizard') }
|
44
|
+
asserts("returns a 200") { topic.status }.equals 200
|
45
|
+
asserts("body is not empty") { not topic.body.empty? }
|
46
|
+
should("includes only the entries for that tag") { topic.body }.includes_elements("li.article", 1)
|
47
|
+
should("has access to @tag") { topic.body }.includes_html("h1" => /wizard/)
|
48
|
+
end
|
43
49
|
end
|
50
|
+
|
44
51
|
end
|
@@ -1,19 +1,24 @@
|
|
1
1
|
require 'support/test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
module RubySlippers::Engine
|
4
|
+
context Article do
|
5
|
+
setup do
|
6
|
+
@config = RubySlippers::Engine::Config.new(:markdown => true, :author => AUTHOR, :url => URL)
|
7
|
+
@ruby_slippers = Rack::MockRequest.new(RubySlippers::Engine::App.new(@config))
|
8
|
+
|
9
|
+
RubySlippers::Engine::Paths[:articles] = "test/fixtures/articles"
|
10
|
+
if File.expand_path("../../", __FILE__) =~ /engine/
|
11
|
+
RubySlippers::Engine::Paths[:templates] = "test/fixtures/templates"
|
12
|
+
RubySlippers::Engine::Paths[:pages] = "test/fixtures/pages"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "GET /index.xml (atom feed)" do
|
17
|
+
setup { @ruby_slippers.get('/index.xml') }
|
18
|
+
asserts("content type is set properly") { topic.content_type }.equals "application/xml"
|
19
|
+
asserts("body should be valid xml") { topic.body }.includes_html("feed > entry" => /.+/)
|
20
|
+
asserts("summary shouldn't be empty") { topic.body }.includes_html("summary" => /.{10,}/)
|
21
|
+
end
|
22
|
+
|
17
23
|
end
|
18
|
-
|
19
|
-
end
|
24
|
+
end
|
@@ -1,77 +1,70 @@
|
|
1
1
|
require 'support/test_helper'
|
2
2
|
require 'date'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
module RubySlippers
|
5
|
+
context Engine do
|
6
|
+
setup do
|
7
|
+
@config = RubySlippers::Engine::Config.new(:markdown => true, :author => AUTHOR, :url => URL)
|
8
|
+
@ruby_slippers = Rack::MockRequest.new(RubySlippers::Engine::App.new(@config))
|
9
|
+
|
10
|
+
RubySlippers::Engine::Paths[:articles] = "test/fixtures/articles"
|
11
|
+
if File.expand_path("../../", __FILE__) =~ /engine/
|
12
|
+
RubySlippers::Engine::Paths[:templates] = "test/fixtures/templates"
|
13
|
+
RubySlippers::Engine::Paths[:pages] = "test/fixtures/pages"
|
14
|
+
end
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
context "GET /" do
|
18
|
+
setup { @ruby_slippers.get('/') }
|
15
19
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
should("include an archive") { topic.body }.includes_elements("#archives li", 2)
|
20
|
+
asserts("returns a 200") { topic.status }.equals 200
|
21
|
+
asserts("body is not empty") { not topic.body.empty? }
|
22
|
+
asserts("content type is set properly") { topic.content_type }.equals "text/html"
|
23
|
+
should("include 3 articles"){ topic.body }.includes_elements("article", 3)
|
21
24
|
|
22
|
-
|
23
|
-
|
25
|
+
context "with no articles" do
|
26
|
+
setup { Rack::MockRequest.new(RubySlippers::Engine::App.new(@config.merge(:ext => 'oxo'))).get('/') }
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
asserts("body is not empty") { not topic.body.empty? }
|
29
|
+
asserts("returns a 200") { topic.status }.equals 200
|
30
|
+
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
context "with a user-defined to_html" do
|
33
|
+
setup do
|
34
|
+
@config[:to_html] = lambda do |path, page, binding|
|
35
|
+
ERB.new(File.read("#{path}/#{page}.rhtml")).result(binding)
|
36
|
+
end
|
37
|
+
@ruby_slippers.get('/')
|
33
38
|
end
|
34
|
-
|
39
|
+
|
40
|
+
asserts("returns a 200") { topic.status }.equals 200
|
41
|
+
asserts("body is not empty") { not topic.body.empty? }
|
42
|
+
asserts("content type is set properly") { topic.content_type }.equals "text/html"
|
43
|
+
should("include 3 articles"){ topic.body }.includes_elements("article", 3)
|
44
|
+
asserts("Etag header present") { topic.headers.include? "ETag" }
|
45
|
+
asserts("Etag header has a value") { not topic.headers["ETag"].empty? }
|
35
46
|
end
|
47
|
+
end
|
36
48
|
|
49
|
+
context "GET /about" do
|
50
|
+
setup { @ruby_slippers.get('/about') }
|
37
51
|
asserts("returns a 200") { topic.status }.equals 200
|
38
52
|
asserts("body is not empty") { not topic.body.empty? }
|
39
|
-
asserts("content type is set properly") { topic.content_type }.equals "text/html"
|
40
|
-
should("include a couple of article") { topic.body }.includes_elements("#articles li", 2)
|
41
|
-
should("include an archive") { topic.body }.includes_elements("#archives li", 2)
|
42
|
-
asserts("Etag header present") { topic.headers.include? "ETag" }
|
43
|
-
asserts("Etag header has a value") { not topic.headers["ETag"].empty? }
|
44
53
|
end
|
45
|
-
end
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
55
|
+
context "GET to an unknown route with a custom error" do
|
56
|
+
setup do
|
57
|
+
@config[:error] = lambda {|code| "error: #{code}" }
|
58
|
+
@ruby_slippers.get('/unknown')
|
59
|
+
end
|
53
60
|
|
54
|
-
|
55
|
-
|
56
|
-
@config[:error] = lambda {|code| "error: #{code}" }
|
57
|
-
@ruby_slippers.get('/unknown')
|
61
|
+
should("returns a 404") { topic.status }.equals 404
|
62
|
+
should("return the custom error") { topic.body }.equals "error: 404"
|
58
63
|
end
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
context "Request is invalid" do
|
65
|
-
setup { @ruby_slippers.delete('/invalid') }
|
66
|
-
should("returns a 400") { topic.status }.equals 400
|
67
|
-
end
|
68
|
-
|
69
|
-
context "GET /index?param=testparam (get parameter)" do
|
70
|
-
setup { @ruby_slippers.get('/index?param=testparam') }
|
71
|
-
asserts("returns a 200") { topic.status }.equals 200
|
72
|
-
asserts("content type is set properly") { topic.content_type }.equals "text/html"
|
73
|
-
asserts("contain the env variable") { topic.body }.includes_html("p" => /env passed: true/)
|
74
|
-
asserts("access the http get parameter") { topic.body }.includes_html("p" => /request method type: GET/)
|
75
|
-
asserts("access the http parameter name value pair") { topic.body }.includes_html("p" => /request name value pair: param=testparam/)
|
65
|
+
context "Request is invalid" do
|
66
|
+
setup { @ruby_slippers.delete('/invalid') }
|
67
|
+
should("returns a 400") { topic.status }.equals 400
|
68
|
+
end
|
76
69
|
end
|
77
70
|
end
|
data/test/unit/article_test.rb
CHANGED
@@ -48,7 +48,7 @@ context RubySlippers::Engine::Article do
|
|
48
48
|
:slug => "wizard-of-oz",
|
49
49
|
:author => "toetoe",
|
50
50
|
:tags => "wizards, oz",
|
51
|
-
:image => "
|
51
|
+
:image => "ozma.png"
|
52
52
|
}, @config)
|
53
53
|
end
|
54
54
|
|
@@ -57,7 +57,7 @@ context RubySlippers::Engine::Article do
|
|
57
57
|
should("use the author") { topic.author }.equals "toetoe"
|
58
58
|
should("have tags") { topic.tags }.equals "wizards, oz"
|
59
59
|
should("have tag links") { topic.tag_links }.equals "<a href=\"/tagged/wizards\">wizards</a>, <a href=\"/tagged/oz\">oz</a>"
|
60
|
-
should("have an image") { topic.image_src }.equals "img/articles/
|
60
|
+
should("have an image") { topic.image_src }.equals "/img/articles/1976/october/ozma.png"
|
61
61
|
|
62
62
|
context "and long first paragraph" do
|
63
63
|
should("create a valid summary") { topic.summary }.equals "<p>" + ("a little bit of text." * 5).chop + "…</p>\n"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ruby-slippers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.25
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- dreamr
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-06-
|
14
|
+
date: 2011-06-22 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|