postview 0.7.0 → 0.8.0

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.
Files changed (52) hide show
  1. data/HISTORY +34 -9
  2. data/README.rdoc +11 -7
  3. data/Rakefile +4 -0
  4. data/VERSION +4 -4
  5. data/lib/postview.rb +6 -1
  6. data/lib/postview/application.rb +26 -33
  7. data/lib/postview/cli.rb +2 -0
  8. data/lib/postview/extensions.rb +8 -0
  9. data/lib/postview/helpers.rb +67 -9
  10. data/lib/postview/patches.rb +2 -0
  11. data/lib/postview/settings.rb +19 -3
  12. data/lib/postview/site.rb +19 -4
  13. data/tasks/history.rake +2 -2
  14. data/test/application_test.rb +12 -12
  15. data/test/extensions.rb +3 -3
  16. data/test/fixtures/application/posts/{20090529-postview_blogware.ruby.sinatra.mkd → 20090529-third_article.t1.t2.t3.mkd} +0 -0
  17. data/test/fixtures/application/posts/{20090602-postview_blogware.ruby.sinatra.mkd → 20090602-fourth_article.t1.t2.t3.t4.mkd} +0 -0
  18. data/test/fixtures/application/posts/archive/{20080529-postview_blogware.ruby.sinatra.mkd → 20080529-first_article.t1.mkd} +0 -0
  19. data/test/fixtures/application/posts/archive/{20080602-postview_blogware.ruby.sinatra.mkd → 20080602-second_article.t1.t2.mkd} +0 -0
  20. data/test/fixtures/application/posts/drafts/{20090730-draft_postview_blogware.ruby.sinatra.mkd → 20090730-fifth_article.t1.t2.t3.t4.t5.mkd} +0 -0
  21. data/test/fixtures/application/themes/gemstone/about.erb +22 -0
  22. data/test/fixtures/application/themes/gemstone/archive/index.erb +21 -0
  23. data/test/fixtures/application/themes/gemstone/archive/show.erb +4 -4
  24. data/test/fixtures/application/themes/gemstone/error.erb +0 -0
  25. data/test/fixtures/application/themes/gemstone/images/logo.png +0 -0
  26. data/test/fixtures/application/themes/gemstone/images/navigation-bar.gif +0 -0
  27. data/test/fixtures/application/themes/gemstone/images/postview.png +0 -0
  28. data/test/fixtures/application/themes/gemstone/images/rack.png +0 -0
  29. data/test/fixtures/application/themes/gemstone/images/ruby.png +0 -0
  30. data/test/fixtures/application/themes/gemstone/images/sinatra.png +0 -0
  31. data/test/fixtures/application/themes/gemstone/index.erb +38 -0
  32. data/test/fixtures/application/themes/gemstone/layout.erb +124 -0
  33. data/test/fixtures/application/themes/gemstone/posts/index.erb +21 -0
  34. data/test/fixtures/application/themes/gemstone/posts/show.erb +17 -0
  35. data/test/fixtures/application/themes/gemstone/search.erb +40 -0
  36. data/test/fixtures/application/themes/gemstone/stylesheets/postview.css +238 -0
  37. data/test/fixtures/application/themes/gemstone/tags/index.erb +12 -0
  38. data/test/fixtures/application/themes/gemstone/tags/show.erb +40 -0
  39. data/test/helpers_test.rb +70 -0
  40. data/test/settings_test.rb +2 -2
  41. data/test/site_test.rb +15 -14
  42. data/themes/default/about.erb +3 -5
  43. data/themes/default/archive/index.erb +1 -1
  44. data/themes/default/archive/show.erb +4 -4
  45. data/themes/default/index.erb +2 -2
  46. data/themes/default/layout.erb +20 -7
  47. data/themes/default/posts/index.erb +1 -1
  48. data/themes/default/posts/show.erb +4 -4
  49. data/themes/default/search.erb +5 -5
  50. data/themes/default/tags/index.erb +1 -1
  51. data/themes/default/tags/show.erb +6 -6
  52. metadata +27 -8
data/lib/postview/site.rb CHANGED
@@ -28,21 +28,36 @@ class Site
28
28
  attr_accessor :find
29
29
 
30
30
  # Finder for archived posts
31
- attr_accessor :find_archived
31
+ attr_accessor :find_in_archive
32
32
 
33
33
  # Finder for drafted posts
34
- attr_accessor :find_drafted
34
+ attr_accessor :find_in_drafts
35
35
 
36
+ # Initialize site with attributes passed by arguments.
36
37
  def initialize(attributes = {})
37
38
  attributes.instance_variables_set_to(self)
38
39
  end
39
40
 
41
+ # Find all tags from all posts and archived posts.
40
42
  def find_all_tags
41
- (find.all_tags + find_archived.all_tags).uniq.sort
43
+ (find.all_tags + find_in_archive.all_tags).uniq.sort
42
44
  end
43
45
 
46
+ # Find a specific tag from posts and archived posts.
44
47
  def find_tag(tag)
45
- find.tag(tag) || find_archived.tag(tag)
48
+ find.tag(tag) || find_in_archive.tag(tag)
49
+ end
50
+
51
+ # Find all posts tagged with a specific tag.
52
+ # Returns two lists: posts and archived posts.
53
+ def find_all_posts_tagged_with(tag)
54
+ [ find.all_posts_by_tag(tag), find_in_archive.all_posts_by_tag(tag) ]
55
+ end
56
+
57
+ # Find posts using any string values.
58
+ # Returns two lists: posts and archived posts.
59
+ def search_posts(*values)
60
+ [ find.posts(*values), find_in_archive.posts(*values) ]
46
61
  end
47
62
 
48
63
  end # class Site
data/tasks/history.rake CHANGED
@@ -1,7 +1,7 @@
1
1
  desc "Creates/updates history file."
2
2
  task :history, [:branch] do |spec, args|
3
- File.open(spec.name.upcase, "w+") do |history|
4
- history << `git log #{args[:branch] || :master} --format="== %ai - %s%n%n%b"`
3
+ File.open("#{spec.name.upcase}.new", "w+") do |history|
4
+ history << `git log #{args[:branch] || :master} --date=short --format="== %ci%n%n=== %s%n%n%b"`
5
5
  end
6
6
  end
7
7
 
@@ -5,7 +5,7 @@ require 'test/unit'
5
5
  require 'rack/test'
6
6
  require 'test/helper'
7
7
 
8
- class TestApplication < Test::Unit::TestCase
8
+ class ApplicationTest < Test::Unit::TestCase
9
9
 
10
10
  include Rack::Test::Methods
11
11
 
@@ -57,9 +57,9 @@ class TestApplication < Test::Unit::TestCase
57
57
  end
58
58
 
59
59
  def test_should_return_ok_in_posts_path_with_params
60
- get app.posts_path "/2009/06/02/postview_blogware" do |response|
60
+ get app.posts_path "/2009/06/02/fourth_article" do |response|
61
61
  assert response.ok?
62
- assert_equal "http://example.org/posts/2009/06/02/postview_blogware/", last_request.url
62
+ assert_equal "http://example.org/posts/2009/06/02/fourth_article/", last_request.url
63
63
  end
64
64
  end
65
65
 
@@ -71,9 +71,9 @@ class TestApplication < Test::Unit::TestCase
71
71
  end
72
72
 
73
73
  def test_should_return_ok_in_tags_path_with_params
74
- get app.tags_path "ruby" do |response|
74
+ get app.tags_path "t1" do |response|
75
75
  assert response.ok?
76
- assert_equal "http://example.org/tags/ruby/", last_request.url
76
+ assert_equal "http://example.org/tags/t1/", last_request.url
77
77
  end
78
78
  end
79
79
 
@@ -84,9 +84,9 @@ class TestApplication < Test::Unit::TestCase
84
84
  end
85
85
 
86
86
  def test_should_return_ok_in_archive_path_with_params
87
- get app.archive_path "2008/06/02/postview_blogware" do |response|
87
+ get app.archive_path "2008/06/02/second_article" do |response|
88
88
  assert response.ok?
89
- assert_equal "http://example.org/archive/2008/06/02/postview_blogware/", last_request.url
89
+ assert_equal "http://example.org/archive/2008/06/02/second_article/", last_request.url
90
90
  end
91
91
  end
92
92
 
@@ -98,9 +98,9 @@ class TestApplication < Test::Unit::TestCase
98
98
  end
99
99
 
100
100
  def test_should_return_ok_in_drafts_path_with_params
101
- get app.drafts_path "2009/07/30/draft_postview_blogware" do |response|
101
+ get app.drafts_path "2009/07/30/fifth_article" do |response|
102
102
  assert response.ok?
103
- assert_equal "http://example.org/drafts/2009/07/30/draft_postview_blogware/", last_request.url
103
+ assert_equal "http://example.org/drafts/2009/07/30/fifth_article/", last_request.url
104
104
  end
105
105
  end
106
106
 
@@ -111,10 +111,10 @@ class TestApplication < Test::Unit::TestCase
111
111
  end
112
112
 
113
113
  def test_should_return_ok_in_search_path
114
- get app.search_path, :anythink => "postview" do |response|
114
+ get app.search_path, :anythink => "first" do |response|
115
115
  assert response.ok?
116
- assert_equal "postview", last_request.params.values.to_s
117
- assert_equal "http://example.org/search/?anythink=postview", last_request.url
116
+ assert_equal "first", last_request.params.values.to_s
117
+ assert_equal "http://example.org/search/?anythink=first", last_request.url
118
118
  end
119
119
  end
120
120
 
data/test/extensions.rb CHANGED
@@ -6,15 +6,15 @@ module Test::Unit
6
6
 
7
7
  class TestCase
8
8
 
9
- def self.must(name, &block)
10
- test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
9
+ def self.should(description, &block)
10
+ test_name = "test_#{description.gsub(/\s+/,'_')}".to_sym
11
11
  defined = instance_method(test_name) rescue false
12
12
  raise "#{test_name} is already defined in #{self}" if defined
13
13
  if block_given?
14
14
  define_method(test_name, &block)
15
15
  else
16
16
  define_method(test_name) do
17
- flunk "No implementation provided for #{name}"
17
+ flunk "No implementation provided for #{description}"
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,22 @@
1
+ <div class="entry">
2
+
3
+ <h1><%= link_to title_path(:about, site.title), :about %></h1>
4
+
5
+ <div class="text">
6
+
7
+ <%=Postview::About.to_html%>
8
+
9
+ <p>
10
+ <%=Postview.name%> uses the following libraries/projects:
11
+ </p>
12
+
13
+ <ul>
14
+ <li><%=link_to "#{Sinatra}", "http://www.sinatrarb.com/"%></li>
15
+ <li><%=link_to "#{Sinatra::Mapping}", "http://sinatra-mapping.rubyforge.org/"%></li>
16
+ <li><%=link_to "#{Postage}", "http://postage.rubyforge.org/"%></li>
17
+ </ul>
18
+
19
+ </div><!--text-->
20
+
21
+ </div><!--entry-->
22
+
@@ -0,0 +1,21 @@
1
+ <div class="entry">
2
+
3
+ <h1><%=title_path :archive%></h1>
4
+
5
+ <div class="text">
6
+
7
+ <dl>
8
+ <% for post in all_archived_posts %>
9
+ <dt>
10
+ <b><%=link_to "#{post.publish_date} - #{post.title}", archive_path, post, :title => post.title%></b>
11
+ (<%= post.tags.map{ |tag| link_to tag.capitalize, tags_path, tag, :title => tag.capitalize }.join(', ') %>)
12
+ </dt>
13
+
14
+ <dd>
15
+ <%=post.summary%>
16
+ </dd>
17
+ <% end %>
18
+ </dl>
19
+ </div><!--text-->
20
+ </div><!--entry-->
21
+
@@ -1,15 +1,15 @@
1
1
  <div class="entry">
2
2
 
3
- <h1><%= link_to post.title, posts_path, post %></h1>
3
+ <h1><%= link_to current_post.title, posts_path, current_post %></h1>
4
4
 
5
5
  <span class="entry-meta">
6
- Published at <%= post.publish_date.strftime('%A, %B %d, %Y') %>,
7
- tagged with <%= post.tags.map{ |tag| link_to tag.capitalize, tags_path, tag, :title => tag.capitalize }.join(', ') %>.
6
+ Published at <%= current_post.publish_date.strftime('%A, %B %d, %Y') %>,
7
+ tagged with <%= current_post.tags.map{ |tag| link_to tag.capitalize, tags_path, tag, :title => tag.capitalize }.join(', ') %>.
8
8
  </span>
9
9
 
10
10
  <div class="text">
11
11
 
12
- <%= post.content %>
12
+ <%= current_post.content %>
13
13
 
14
14
  </div><!--text-->
15
15
 
@@ -0,0 +1,38 @@
1
+ <% unless latest_posts.empty? %>
2
+ <% for post in latest_posts %>
3
+ <div class="entry">
4
+
5
+ <h1><%= link_to post.title, posts_path, post %></h1>
6
+
7
+ <span class="entry-meta">
8
+ Published at <%= post.publish_date.strftime('%A, %B %d, %Y') %>,
9
+ tagged with <%= post.tags.map{ |tag| link_to tag.capitalize, tags_path, tag, :title => tag.capitalize }.join(', ') %>.
10
+ </span>
11
+
12
+ <div class="text">
13
+
14
+ <%= post.summary %>
15
+
16
+ <p>
17
+ <%= link_to "Read more ...", posts_path, post %>
18
+ </p>
19
+
20
+ </div><!--text-->
21
+
22
+ </div><!--entry-->
23
+ <% end %>
24
+ <% else %>
25
+ <div class="entry">
26
+
27
+ <h1>No posts</h1>
28
+
29
+ <div class="text">
30
+
31
+ <p>
32
+ Please, check your posts directory.
33
+ </p>
34
+
35
+ </div><!--text-->
36
+
37
+ </div><!-- entry -->
38
+ <% end %>
@@ -0,0 +1,124 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+
4
+ <head>
5
+
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title><%=site.title%> :: <%=page.title%></title>
8
+ <meta name="generator" content="<%=Postview::Version%>" />
9
+ <meta name="description" content="<%=site.subtitle%>" />
10
+ <meta name="keywords" content="<%=page.keywords%>" />
11
+ <link rel="shortcut icon" href="<%=path_to :images, "favicon.ico"%>" />
12
+ <link rel="stylesheet" type="text/css" href="<%=path_to :stylesheets, "postview.css"%>" />
13
+
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="header">
19
+
20
+ <h1><%=link_to site.title, :root, :title => "#{site.title}"%></h1>
21
+
22
+ <h2><%=page.title || site.subtitle%></h2>
23
+
24
+ <span>By <%=link_to site.author, "mailto:#{site.email}", :title => "Send mail to #{site.author}"%></span>
25
+
26
+ <img src="<%=path_to "/images/logo.png"%>" id="logo" alt="Postview" />
27
+
28
+ </div><!-- header -->
29
+
30
+ <br/>
31
+
32
+ <div id="navigation-bar">
33
+
34
+ <address>
35
+
36
+ <%=link_to "Home", :root, :title => site.title%>
37
+ <%=link_to title_path(:posts), :posts, :title => title_path(:posts)%>
38
+ <%=link_to title_path(:archive), :archive, :title => title_path(:archive)%>
39
+ <%=link_to title_path(:about), :about, :title => title_path(:about)%>
40
+
41
+ </address>
42
+
43
+ <form action="<%=path_to :search%>" method="get">
44
+ <input type="text" name="keyword" value="<%=title_path :search%>" onfocus="this.value=''" onblur="this.value='<%=title_path :search%>'" title="<%=title_path :search%>"/>
45
+ </form>
46
+
47
+ </div><!-- navigation-bar -->
48
+
49
+ <br/>
50
+
51
+ <div id="content">
52
+
53
+ <%=yield%>
54
+
55
+ </div>
56
+
57
+ <div id="options">
58
+
59
+ <div class="entry">
60
+
61
+ <h1>Related Posts</h1>
62
+
63
+ <h2>Published</h2>
64
+ <ul>
65
+ <% for post in related_posts_in :posts %>
66
+ <li><%= link_to "#{post.publish_date} - #{post.title}", :posts, post, :title => post.title %></li>
67
+ <% end %>
68
+ </ul>
69
+
70
+ <h2>Archived</h2>
71
+ <ul>
72
+ <% for post in related_posts_in :archive %>
73
+ <li><%= link_to "#{post.publish_date} - #{post.title}", :archive, post, :title => post.title %></li>
74
+ <% end %>
75
+ </ul>
76
+ </div>
77
+
78
+ <div class="entry">
79
+
80
+ <h1>Related Tags</h1>
81
+
82
+ <ul>
83
+ <% for tag in all_related_tags %>
84
+ <li><%= link_to "#{tag.capitalize} (#{count_posts_by_tag(tag)})", :tags, tag, :title => tag.capitalize %></li>
85
+ <% end %>
86
+ </ul>
87
+
88
+ </div>
89
+
90
+ <div class="entry">
91
+
92
+ <div class="text">
93
+
94
+ <p>
95
+ <span><a href="http://github.com/hallison/postview" title="Project hosted by Github"><img alt="Project hosted by Github" src="http://github.com/images/modules/header/logov3.png" border="0" /></a></span>
96
+ <span><a href="http://www.pledgie.com/campaigns/5600" title="Donations"><img alt="Click here to lend your support to: postview and make a donation at www.pledgie.com !" src="http://www.pledgie.com/campaigns/5600.png?skin_name=chrome" border="0" /></a></span>
97
+ </p>
98
+
99
+ <p>
100
+ <span><a href="http://www.ruby-lang.org/" title="Ruby programming language"><img alt="Ruby programming language" src="<%=path_to "/images/ruby.png"%>" border="0" /></a></span>
101
+ <span><a href="http://rack.rubyforge.org/" title="Powers Web Applications"><img alt="Rack"src="<%=path_to "/images/rack.png"%>" border="0" /></a></span>
102
+ <span><a href="http://www.sinatrarb.com/" title="Sinatra DSL"><img alt="Sinatra DSL"src="<%=path_to "/images/sinatra.png"%>" border="0" /></a></span>
103
+ </p>
104
+
105
+ </div>
106
+
107
+ </div>
108
+
109
+ </div><!-- options -->
110
+
111
+ <br/>
112
+
113
+ <div id="footer">
114
+
115
+ <p>
116
+ <small><%=site.title%> &copy; 2009 <%=site.author%>. Powered by <%=link_to Postview::Version, "http://github.com/hallison/postview"%>.</small>
117
+ </p>
118
+
119
+ </div><!-- footer -->
120
+
121
+ </body>
122
+
123
+ </html>
124
+
@@ -0,0 +1,21 @@
1
+ <div class="entry">
2
+
3
+ <h1><%=title_path :posts%></h1>
4
+
5
+ <div class="text">
6
+
7
+ <dl>
8
+ <% for post in all_posts %>
9
+ <dt>
10
+ <b><%=link_to "#{post.publish_date} - #{post.title}", posts_path, post%></b>
11
+ (<%= post.tags.map{ |tag| link_to tag.capitalize, tags_path, tag, :title => tag.capitalize }.join(', ') %>)
12
+ </dt>
13
+
14
+ <dd>
15
+ <%=post.summary%>
16
+ </dd>
17
+ <% end %>
18
+ </dl>
19
+ </div><!--text-->
20
+ </div><!--entry-->
21
+
@@ -0,0 +1,17 @@
1
+ <div class="entry">
2
+
3
+ <h1><%= link_to current_post.title, posts_path, current_post %></h1>
4
+
5
+ <span class="entry-meta">
6
+ Published at <%= current_post.publish_date.strftime('%A, %B %d, %Y') %>,
7
+ tagged with <%= current_post.tags.map{ |tag| link_to tag.capitalize, tags_path, tag, :title => tag.capitalize }.join(', ') %>.
8
+ </span>
9
+
10
+ <div class="text">
11
+
12
+ <%= current_post.content %>
13
+
14
+ </div><!--text-->
15
+
16
+ </div><!--entry-->
17
+
@@ -0,0 +1,40 @@
1
+ <div class="entry">
2
+
3
+ <h1><%= title_path :search %> - Results for <%= params.values.to_s.split.join(', ') %></h1>
4
+
5
+ <div class="text">
6
+
7
+ <p>
8
+ <%= posts_found.size %> found in posts and <%= archived_posts_found.size %> found in archive.
9
+ </p>
10
+
11
+ <% unless posts_found.empty? %>
12
+ <h2><%= title_path :posts %></h2>
13
+
14
+ <ul>
15
+ <% for post in posts_found %>
16
+ <li>
17
+ <%= post.publish_date.strftime('%Y-%m-%d') %> - <strong><%= link_to post.title, posts_path, post, :title => post.title %></strong>
18
+ <span>(<%= post.tags.map{ |tag| link_to tag.capitalize, tags_path, tag, :title => tag.capitalize }.join(', ') %>)</span>
19
+ </li>
20
+ <% end %>
21
+ </ul>
22
+ <% end %>
23
+
24
+ <% unless archived_posts_found.empty? %>
25
+ <h2><%= title_path :archive %></h2>
26
+
27
+ <ul>
28
+ <% for post in archived_posts_found %>
29
+ <li>
30
+ <b><%= link_to "#{post.publish_date} - #{post.title}", archive_path, post, :title => post.title %></b>
31
+ <span>(<%= post.tags.map{ |tag| link_to tag.capitalize, tags_path, tag, :title => tag.capitalize }.join(', ') %>)</span>
32
+ </li>
33
+ <% end %>
34
+ </ul>
35
+ <% end %>
36
+
37
+ </div><!--text-->
38
+
39
+ </div><!--entry-->
40
+