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 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
- #### To create an article
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.13
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() self[:image] end
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: test/fixtures/images/ozma.png
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
- <span id="count"><%= @articles.length %></span>
1
+ Fill me in with your about info!
@@ -1,5 +1,11 @@
1
1
  <h1><%= @path %></h1>
2
- <% for entry in archives %>
3
- <li class="entry"><%= entry.title %></li>
4
- <% end %>
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
- <h2><%= title %></h2>
2
- <span><%= date %></h2>
3
- <p><%= body %></p>
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
- <ul id="articles">
2
- <% for article in articles[0...2] %>
3
- <li><img src="<%= article.image_src %>" /><%= article %></li>
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 &raquo;</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
- </ul>
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>
@@ -3,7 +3,7 @@
3
3
  <% unless articles.empty? %>
4
4
  <ul>
5
5
  <% for article in articles %>
6
- <li class="entry"><a href="<%= article.url %>"><%= article.title %></a></li>
6
+ <li class="article"><a href="<%= article.url %>"><%= article.title %></a></li>
7
7
  <% end %>
8
8
  </ul>
9
9
  <% end %>
@@ -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
- context "GET to the archive" do
19
- context "through a year" do
20
- setup { @ruby_slippers.get('/2011') }
21
- asserts("returns a 200") { topic.status }.equals 200
22
- should("includes the entries for that year") { topic.body }.includes_elements("li.entry", 1)
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 "through a year & month" do
26
- setup { @ruby_slippers.get('/2011/05') }
27
- asserts("returns a 200") { topic.status }.equals 200
28
- should("includes the entries for that month") { topic.body }.includes_elements("li.entry", 1)
29
- should("includes the year & month") { topic.body }.includes_html("h1" => /2011\/05/)
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 "through /archives" do
33
- setup { @ruby_slippers.get('/archives') }
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
- context "GET the tagged page" do
38
- setup { @ruby_slippers.get('/tagged/wizard') }
39
- asserts("returns a 200") { topic.status }.equals 200
40
- asserts("body is not empty") { not topic.body.empty? }
41
- should("includes only the entries for that tag") { topic.body }.includes_elements("li.entry", 1)
42
- should("has access to @tag") { topic.body }.includes_html("h1" => /wizard/)
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
- context RubySlippers::Engine::Article do
4
- setup do
5
- @config = RubySlippers::Engine::Config.new(:markdown => true, :author => AUTHOR, :url => URL)
6
- @ruby_slippers = Rack::MockRequest.new(RubySlippers::Engine::App.new(@config))
7
- RubySlippers::Engine::Paths[:articles] = "test/fixtures/articles"
8
- RubySlippers::Engine::Paths[:pages] = "test/fixtures/pages"
9
- RubySlippers::Engine::Paths[:templates] = "test/fixtures/templates"
10
- end
11
-
12
- context "GET /index.xml (atom feed)" do
13
- setup { @ruby_slippers.get('/index.xml') }
14
- asserts("content type is set properly") { topic.content_type }.equals "application/xml"
15
- asserts("body should be valid xml") { topic.body }.includes_html("feed > entry" => /.+/)
16
- asserts("summary shouldn't be empty") { topic.body }.includes_html("summary" => /.{10,}/)
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
- context RubySlippers::Engine 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
- RubySlippers::Engine::Paths[:articles] = "test/fixtures/articles"
9
- RubySlippers::Engine::Paths[:pages] = "test/fixtures/pages"
10
- RubySlippers::Engine::Paths[:templates] = "test/fixtures/templates"
11
- end
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
- context "GET /" do
14
- setup { @ruby_slippers.get('/') }
17
+ context "GET /" do
18
+ setup { @ruby_slippers.get('/') }
15
19
 
16
- asserts("returns a 200") { topic.status }.equals 200
17
- asserts("body is not empty") { not topic.body.empty? }
18
- asserts("content type is set properly") { topic.content_type }.equals "text/html"
19
- should("include a couple of articles") { topic.body }.includes_elements("#articles li", 2)
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
- context "with no articles" do
23
- setup { Rack::MockRequest.new(RubySlippers::Engine::App.new(@config.merge(:ext => 'oxo'))).get('/') }
25
+ context "with no articles" do
26
+ setup { Rack::MockRequest.new(RubySlippers::Engine::App.new(@config.merge(:ext => 'oxo'))).get('/') }
24
27
 
25
- asserts("body is not empty") { not topic.body.empty? }
26
- asserts("returns a 200") { topic.status }.equals 200
27
- end
28
+ asserts("body is not empty") { not topic.body.empty? }
29
+ asserts("returns a 200") { topic.status }.equals 200
30
+ end
28
31
 
29
- context "with a user-defined to_html" do
30
- setup do
31
- @config[:to_html] = lambda do |path, page, binding|
32
- ERB.new(File.read("#{path}/#{page}.rhtml")).result(binding)
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
- @ruby_slippers.get('/')
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
- context "GET /about" do
48
- setup { @ruby_slippers.get('/about') }
49
- asserts("returns a 200") { topic.status }.equals 200
50
- asserts("body is not empty") { not topic.body.empty? }
51
- should("have access to @articles") { topic.body }.includes_html("#count" => /4/)
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
- context "GET to an unknown route with a custom error" do
55
- setup do
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
- should("returns a 404") { topic.status }.equals 404
61
- should("return the custom error") { topic.body }.equals "error: 404"
62
- end
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
@@ -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 => "img/articles/2011/may/ozma.png"
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/2011/may/ozma.png"
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 + "&hellip;</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.13
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-21 00:00:00 Z
14
+ date: 2011-06-22 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake