postview 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +2 -2
- data/lib/postview.rb +5 -6
- data/lib/postview/application.rb +14 -126
- data/lib/postview/application/blog.rb +141 -0
- data/lib/postview/authentication.rb +2 -2
- data/lib/postview/cli.rb +1 -0
- data/lib/postview/cli/server_command.rb +4 -15
- data/lib/postview/settings.rb +9 -1
- data/tasks/documentation.rake +2 -2
- data/test/{application_test.rb → blog_application_test.rb} +15 -15
- data/test/fixtures/blog/config.ru +3 -0
- data/test/fixtures/{application → blog}/config/settings.yml +17 -18
- data/test/fixtures/{application → blog}/posts/20090529-third_article.t1.t2.t3.mkd +0 -0
- data/test/fixtures/{application → blog}/posts/20090602-fourth_article.t1.t2.t3.t4.mkd +0 -0
- data/test/fixtures/{application → blog}/posts/archive/20080529-first_article.t1.mkd +0 -0
- data/test/fixtures/{application → blog}/posts/archive/20080602-second_article.t1.t2.mkd +0 -0
- data/test/fixtures/{application → blog}/posts/drafts/20090730-fifth_article.t1.t2.t3.t4.t5.mkd +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/banners/banner.jpg +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/favicon.ico +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/logo.png +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/navigation-bar.gif +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/postview.png +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/rack.png +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/ruby.png +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/sinatra.png +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/images/trojan.com +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/javascripts/postview.js +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/stylesheets/gemstone.css +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/stylesheets/postview.css +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/about.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/archive/index.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/archive/show.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/drafts/index.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/drafts/show.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/error.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/index.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/layout.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/posts/index.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/posts/show.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/search.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/tags/index.erb +0 -0
- data/test/fixtures/{application → blog}/themes/mytheme/templates/tags/show.erb +0 -0
- data/test/fixtures/site/blog/config.ru +0 -3
- data/test/fixtures/site/blog/config/settings.yml +17 -18
- data/test/fixtures/{application/empty.yml → site/blog/themes/mytheme/images/banners/banner.jpg} +0 -0
- data/test/fixtures/site/blog/themes/mytheme/images/favicon.ico +0 -0
- data/test/fixtures/site/blog/themes/mytheme/images/logo.png +0 -0
- data/test/fixtures/site/blog/themes/mytheme/images/navigation-bar.gif +0 -0
- data/test/fixtures/site/blog/themes/mytheme/images/postview.png +0 -0
- data/test/fixtures/site/blog/themes/mytheme/images/rack.png +0 -0
- data/test/fixtures/site/blog/themes/mytheme/images/ruby.png +0 -0
- data/test/fixtures/site/blog/themes/mytheme/images/sinatra.png +0 -0
- data/test/fixtures/site/blog/{empty.yml → themes/mytheme/images/trojan.com} +0 -0
- data/test/fixtures/site/blog/themes/mytheme/javascripts/postview.js +1 -0
- data/test/fixtures/site/blog/themes/mytheme/stylesheets/gemstone.css +1 -0
- data/test/fixtures/site/blog/themes/mytheme/stylesheets/postview.css +238 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/about.erb +1 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/archive/index.erb +3 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/archive/show.erb +1 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/drafts/index.erb +3 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/drafts/show.erb +1 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/error.erb +1 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/index.erb +3 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/layout.erb +130 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/posts/index.erb +3 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/posts/show.erb +1 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/search.erb +6 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/tags/index.erb +3 -0
- data/test/fixtures/site/blog/themes/mytheme/templates/tags/show.erb +6 -0
- data/test/helpers_test.rb +2 -1
- data/test/settings_test.rb +11 -11
- data/test/site_test.rb +1 -0
- metadata +121 -75
- data/lib/postview/version.rb +0 -27
- data/test/fixtures/application/config.ru +0 -6
data/VERSION
CHANGED
data/lib/postview.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Copyright (c) 2009 Hallison Batista
|
2
1
|
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
|
3
|
-
|
2
|
+
# Copyright (c) 2009 Hallison Batista
|
3
|
+
#
|
4
4
|
# Postview - The minimalist blogware and static page generator.
|
5
5
|
#
|
6
6
|
# == Configuration
|
@@ -34,7 +34,6 @@ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
|
|
34
34
|
# theme. To help for this, read Helpers for more informations.
|
35
35
|
#
|
36
36
|
module Postview
|
37
|
-
|
38
37
|
# RubyGems.
|
39
38
|
require 'rubygems' unless $LOADED_FEATURES.include? 'rubygems.rb'
|
40
39
|
|
@@ -76,7 +75,7 @@ module Postview
|
|
76
75
|
@path = Pathname.new(pathname).expand_path
|
77
76
|
end
|
78
77
|
|
79
|
-
# Version
|
78
|
+
# Version specification loaded from +VERSION+ file.
|
80
79
|
def version_spec
|
81
80
|
@version_spec ||= OpenStruct.new(YAML.load_file(ROOT.join("VERSION")))
|
82
81
|
end
|
@@ -98,9 +97,9 @@ module Postview
|
|
98
97
|
@about_info ||= OpenStruct.new(YAML.load_file(File.join(ROOT, "ABOUT")))
|
99
98
|
end
|
100
99
|
|
101
|
-
# About
|
100
|
+
# About text.
|
102
101
|
def about
|
103
|
-
<<-end_info.gsub(/^[ ]{
|
102
|
+
<<-end_info.gsub(/^[ ]{8}/,'')
|
104
103
|
#{version_summary}
|
105
104
|
|
106
105
|
Copyright (C) #{version_spec.timestamp.year} #{about_info.authors.join(', ')}
|
data/lib/postview/application.rb
CHANGED
@@ -1,137 +1,25 @@
|
|
1
1
|
module Postview
|
2
2
|
|
3
3
|
# Copyright (c) 2009 Hallison Batista
|
4
|
-
|
4
|
+
module Application
|
5
5
|
|
6
|
-
|
6
|
+
autoload :Blog, 'postview/application/blog'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def self.call(env)
|
9
|
+
puts <<-end_msg.gsub(/^[ ]{6}/,'')
|
10
|
+
#{Postview::version_summary}
|
11
|
+
>> DEPRECATION WARNING
|
12
|
+
The run Postview::Application is deprecated. Instead use
|
13
|
+
Postview::Application::Blog to call blogware.
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
set :views, theme.join("templates")
|
20
|
-
|
21
|
-
mapping settings.sections
|
22
|
-
end
|
23
|
-
|
24
|
-
before do
|
25
|
-
@page = options.page
|
26
|
-
@settings ||= options.settings
|
27
|
-
@site ||= options.site
|
28
|
-
@all_tags ||= @site.find_all_tags
|
29
|
-
@all_posts ||= @site.find.all_posts.reverse
|
30
|
-
@all_archived_posts ||= @site.find_in_archive.all_posts.reverse
|
31
|
-
@all_drafted_posts ||= @site.find_in_drafts.all_posts.reverse
|
32
|
-
@current_post ||= @all_posts.last
|
33
|
-
end
|
34
|
-
|
35
|
-
helpers Postview::Helpers
|
36
|
-
|
37
|
-
use Rack::Static, :urls => ["/stylesheets", "/images", "/javascripts"], :root => theme
|
38
|
-
|
39
|
-
# Show all information for site.
|
40
|
-
get root_path do
|
41
|
-
@page.title, @page.keywords = @site.subtitle, "posts"
|
42
|
-
show :index
|
43
|
-
end
|
44
|
-
|
45
|
-
# Show all posts.
|
46
|
-
get posts_path do
|
47
|
-
@page.title, @page.keywords = title_path(:posts), @all_tags.join(' ')
|
48
|
-
show :"posts/index"
|
49
|
-
end
|
50
|
-
|
51
|
-
# Show selected post.
|
52
|
-
get posts_path "/:year/:month/:day/:name" do |year, month, day, name|
|
53
|
-
@current_post = @site.find.post(year, month, day, name)
|
54
|
-
@page.title, @page.keywords = @current_post.title, @current_post.tags.join(' ')
|
55
|
-
show :"posts/show"
|
56
|
-
end
|
57
|
-
|
58
|
-
# Show all tags.
|
59
|
-
get tags_path do
|
60
|
-
@page.title, @page.keywords = title_path(:tags), @all_tags.join(' ')
|
61
|
-
show :"tags/index"
|
62
|
-
end
|
63
|
-
|
64
|
-
# Show all posts by selected tag.
|
65
|
-
get tags_path "/:tag" do |tag|
|
66
|
-
@current_tag = @site.find_tag(tag)
|
67
|
-
@posts_found, @archived_posts_found = @site.find_all_posts_tagged_with(tag)
|
68
|
-
@page.title, @page.keywords = "#{title_path(:tags)} - #{@current_tag.capitalize}", "posts #{@current_tag}"
|
69
|
-
show :"tags/show"
|
70
|
-
end
|
71
|
-
|
72
|
-
# Show archives grouped by year.
|
73
|
-
get archive_path do
|
74
|
-
@page.title, @page.keywords = title_path(:archive), @all_tags.join(' ')
|
75
|
-
show :"archive/index"
|
76
|
-
end
|
77
|
-
|
78
|
-
# Show selected post in archive.
|
79
|
-
get archive_path "/:year/:month/:day/:name" do |year, month, day, name|
|
80
|
-
@current_post = @site.find_in_archive.post(year, month, day, name)
|
81
|
-
@page.title, @page.keywords = @current_post.title, @current_post.tags.join(' ')
|
82
|
-
show :"archive/show"
|
83
|
-
end
|
84
|
-
|
85
|
-
# Show all drafts.
|
86
|
-
get drafts_path do
|
87
|
-
authenticate!
|
88
|
-
if authenticated?
|
89
|
-
@all_tags = @site.find_in_drafts.all_tags.sort
|
90
|
-
@page.title, @page.keywords = title_path(:drafts), "drafts #{@all_tags.join(' ')}"
|
91
|
-
show :"drafts/index"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# Show selected drafted post.
|
96
|
-
get drafts_path "/:year/:month/:day/:name" do |year, month, day, name|
|
97
|
-
authenticate!
|
98
|
-
if authenticated?
|
99
|
-
@current_post = @site.find_in_drafts.post(year, month, day, name)
|
100
|
-
@all_tags = @site.find_in_drafts.all_tags.sort
|
101
|
-
@page.title, @page.keywords = @current_post.title, @current_post.tags.join(' ')
|
102
|
-
show :"drafts/show"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# Show information site.
|
107
|
-
get about_path do
|
108
|
-
show :about
|
109
|
-
end
|
110
|
-
|
111
|
-
# Search posts by title or match file name.
|
112
|
-
get search_path do
|
113
|
-
@posts_found, @archived_posts_found = @site.search_posts(*params.values)
|
114
|
-
@page.title, @page.keywords = title_path(:search), @all_tags.join(' ')
|
115
|
-
show :search
|
116
|
-
end
|
117
|
-
|
118
|
-
get manager_path do
|
119
|
-
authenticate!
|
120
|
-
if authenticated?
|
121
|
-
@page.title, @page.keywords = title_path(:manager, :posts), @all_tags.join(' ')
|
122
|
-
show :"posts/index"
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
private
|
127
|
-
|
128
|
-
include Postview::Authentication
|
129
|
-
|
130
|
-
def show(template, locals = {}, options = {})
|
131
|
-
erb template, options.update(:locals => locals)
|
15
|
+
Thanks.
|
16
|
+
|
17
|
+
Visit http://github.com/hallison/postview/tree/news for more information.
|
18
|
+
end_msg
|
19
|
+
Blog.call(env)
|
132
20
|
end
|
133
21
|
|
134
|
-
end #
|
22
|
+
end # module Application
|
135
23
|
|
136
24
|
end # module Postview
|
137
25
|
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module Postview
|
2
|
+
|
3
|
+
module Application
|
4
|
+
|
5
|
+
# Copyright (c) 2009 Hallison Batista
|
6
|
+
class Blog < Sinatra::Base #:nodoc: all
|
7
|
+
|
8
|
+
register Sinatra::Mapping
|
9
|
+
|
10
|
+
configure do
|
11
|
+
set :settings, Postview::Settings.load
|
12
|
+
set :site, settings.build_site
|
13
|
+
set :page, settings.build_page
|
14
|
+
set :theme, settings.path_to(:themes).join(site.theme)
|
15
|
+
|
16
|
+
enable :static
|
17
|
+
enable :session
|
18
|
+
|
19
|
+
set :root, Postview::path
|
20
|
+
set :public, root.join("public")
|
21
|
+
set :views, theme.join("templates")
|
22
|
+
|
23
|
+
mapping settings.sections
|
24
|
+
end
|
25
|
+
|
26
|
+
before do
|
27
|
+
@page = options.page
|
28
|
+
@settings ||= options.settings
|
29
|
+
@site ||= options.site
|
30
|
+
@all_tags ||= @site.find_all_tags
|
31
|
+
@all_posts ||= @site.find.all_posts.reverse
|
32
|
+
@all_archived_posts ||= @site.find_in_archive.all_posts.reverse
|
33
|
+
@all_drafted_posts ||= @site.find_in_drafts.all_posts.reverse
|
34
|
+
@current_post ||= @all_posts.last
|
35
|
+
end
|
36
|
+
|
37
|
+
helpers Postview::Helpers
|
38
|
+
|
39
|
+
use Rack::Static, :urls => ["/stylesheets", "/images", "/javascripts"], :root => theme
|
40
|
+
|
41
|
+
# Show all information for site.
|
42
|
+
get root_path do
|
43
|
+
@page.title, @page.keywords = @site.subtitle, "posts"
|
44
|
+
show :index
|
45
|
+
end
|
46
|
+
|
47
|
+
# Show all posts.
|
48
|
+
get posts_path do
|
49
|
+
@page.title, @page.keywords = title_path(:posts), @all_tags.join(' ')
|
50
|
+
show :"posts/index"
|
51
|
+
end
|
52
|
+
|
53
|
+
# Show selected post.
|
54
|
+
get posts_path "/:year/:month/:day/:name" do |year, month, day, name|
|
55
|
+
@current_post = @site.find.post(year, month, day, name)
|
56
|
+
@page.title, @page.keywords = @current_post.title, @current_post.tags.join(' ')
|
57
|
+
show :"posts/show"
|
58
|
+
end
|
59
|
+
|
60
|
+
# Show all tags.
|
61
|
+
get tags_path do
|
62
|
+
@page.title, @page.keywords = title_path(:tags), @all_tags.join(' ')
|
63
|
+
show :"tags/index"
|
64
|
+
end
|
65
|
+
|
66
|
+
# Show all posts by selected tag.
|
67
|
+
get tags_path "/:tag" do |tag|
|
68
|
+
@current_tag = @site.find_tag(tag)
|
69
|
+
@posts_found, @archived_posts_found = @site.find_all_posts_tagged_with(tag)
|
70
|
+
@page.title, @page.keywords = "#{title_path(:tags)} - #{@current_tag.capitalize}", "posts #{@current_tag}"
|
71
|
+
show :"tags/show"
|
72
|
+
end
|
73
|
+
|
74
|
+
# Show archives grouped by year.
|
75
|
+
get archive_path do
|
76
|
+
@page.title, @page.keywords = title_path(:archive), @all_tags.join(' ')
|
77
|
+
show :"archive/index"
|
78
|
+
end
|
79
|
+
|
80
|
+
# Show selected post in archive.
|
81
|
+
get archive_path "/:year/:month/:day/:name" do |year, month, day, name|
|
82
|
+
@current_post = @site.find_in_archive.post(year, month, day, name)
|
83
|
+
@page.title, @page.keywords = @current_post.title, @current_post.tags.join(' ')
|
84
|
+
show :"archive/show"
|
85
|
+
end
|
86
|
+
|
87
|
+
# Show all drafts.
|
88
|
+
get drafts_path do
|
89
|
+
authenticate!
|
90
|
+
if authenticated?
|
91
|
+
@all_tags = @site.find_in_drafts.all_tags.sort
|
92
|
+
@page.title, @page.keywords = title_path(:drafts), "drafts #{@all_tags.join(' ')}"
|
93
|
+
show :"drafts/index"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Show selected drafted post.
|
98
|
+
get drafts_path "/:year/:month/:day/:name" do |year, month, day, name|
|
99
|
+
authenticate!
|
100
|
+
if authenticated?
|
101
|
+
@current_post = @site.find_in_drafts.post(year, month, day, name)
|
102
|
+
@all_tags = @site.find_in_drafts.all_tags.sort
|
103
|
+
@page.title, @page.keywords = @current_post.title, @current_post.tags.join(' ')
|
104
|
+
show :"drafts/show"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Show information site.
|
109
|
+
get about_path do
|
110
|
+
show :about
|
111
|
+
end
|
112
|
+
|
113
|
+
# Search posts by title or match file name.
|
114
|
+
get search_path do
|
115
|
+
@posts_found, @archived_posts_found = @site.search_posts(*params.values)
|
116
|
+
@page.title, @page.keywords = title_path(:search), @all_tags.join(' ')
|
117
|
+
show :search
|
118
|
+
end
|
119
|
+
|
120
|
+
get manager_path do
|
121
|
+
authenticate!
|
122
|
+
if authenticated?
|
123
|
+
@page.title, @page.keywords = title_path(:manager, :posts), @all_tags.join(' ')
|
124
|
+
show :"posts/index"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
include Postview::Authentication
|
131
|
+
|
132
|
+
def show(template, locals = {}, options = {})
|
133
|
+
erb template, options.update(:locals => locals)
|
134
|
+
end
|
135
|
+
|
136
|
+
end # class Blog
|
137
|
+
|
138
|
+
end # module Application
|
139
|
+
|
140
|
+
end # module Postview
|
141
|
+
|
@@ -3,7 +3,7 @@ module Postview
|
|
3
3
|
# Copyright (c) 2009 Hallison Batista
|
4
4
|
module Authentication
|
5
5
|
|
6
|
-
#
|
6
|
+
# Returns a HTTP Basic authentication.
|
7
7
|
def authentication
|
8
8
|
@authentication ||= Rack::Auth::Basic::Request.new(request.env)
|
9
9
|
end
|
@@ -16,7 +16,7 @@ module Authentication
|
|
16
16
|
authentication.credentials.last
|
17
17
|
end
|
18
18
|
|
19
|
-
# Run
|
19
|
+
# Run HTTP Basic authentication.
|
20
20
|
def authenticate!
|
21
21
|
headers "WWW-Authenticate" => %(Basic realm="#{@site.title}") and
|
22
22
|
@error_message = "Not authorized\n" and throw(:halt, [401, erb(:error)]) and
|
data/lib/postview/cli.rb
CHANGED
@@ -77,17 +77,6 @@ private
|
|
77
77
|
step { @server ||= "mongrel" }
|
78
78
|
step { @options[:Host] ||= "0.0.0.0" }
|
79
79
|
step { @options[:Port] ||= "9000" }
|
80
|
-
step { @path = Pathname.new(@path) }
|
81
|
-
step { @config = @path.join("config.ru") }
|
82
|
-
step do
|
83
|
-
unless @config.exist?
|
84
|
-
raise "Configuration #{@config} not found"
|
85
|
-
else
|
86
|
-
true
|
87
|
-
end
|
88
|
-
end
|
89
|
-
step { @source = @config.read }
|
90
|
-
step { @source = @source.gsub(/^require[ ]'postview'/,'') }
|
91
80
|
step { @server = Rack::Handler::WEBrick }
|
92
81
|
end
|
93
82
|
end
|
@@ -96,12 +85,12 @@ private
|
|
96
85
|
def start_server
|
97
86
|
init "Postview starting #{@server} on #{@options[:Host]}:#{@options[:Port]}" do
|
98
87
|
ENV['RACK_ENV'] = "production"
|
99
|
-
|
100
|
-
|
101
|
-
@
|
88
|
+
Postview::path = @path
|
89
|
+
puts "PATH: #{Postview::path}"
|
90
|
+
@postview = Rack::Builder.new do |application|
|
102
91
|
use Rack::CommonLogger, STDOUT
|
103
92
|
use Rack::ShowExceptions
|
104
|
-
run
|
93
|
+
run Postview::Application
|
105
94
|
end.to_app
|
106
95
|
end
|
107
96
|
@server.run(@postview, @options)
|
data/lib/postview/settings.rb
CHANGED
@@ -3,6 +3,7 @@ module Postview
|
|
3
3
|
# Copyright (c) 2009 Hallison Batista
|
4
4
|
class Settings
|
5
5
|
|
6
|
+
# Default values that will be used for valid attributes in settings file.
|
6
7
|
DEFAULTS = {
|
7
8
|
:site => {
|
8
9
|
:title => "Postview",
|
@@ -34,7 +35,14 @@ class Settings
|
|
34
35
|
FILE_NAME = "settings.yml"
|
35
36
|
FILE_DIR = "config"
|
36
37
|
|
37
|
-
|
38
|
+
# Site attributes
|
39
|
+
attr_reader :site
|
40
|
+
|
41
|
+
# Directories that be used for load files.
|
42
|
+
attr_reader :directories
|
43
|
+
|
44
|
+
# Section names that be used in mapping routes into application.
|
45
|
+
attr_reader :sections
|
38
46
|
|
39
47
|
# Initialize the settings using attributes passed by arguments.
|
40
48
|
# Only attributes valid are read. See DEFAULTS.
|
data/tasks/documentation.rake
CHANGED
@@ -6,11 +6,11 @@ rescue LoadError
|
|
6
6
|
end
|
7
7
|
|
8
8
|
desc "Generate RDoc API documentation."
|
9
|
-
Rake::RDocTask.new("doc
|
9
|
+
Rake::RDocTask.new("doc") do |doc|
|
10
10
|
doc.title = Postview.name
|
11
11
|
doc.main = %q{README.rdoc}
|
12
12
|
doc.options = %w{--line-numbers --show-hash}
|
13
|
-
doc.rdoc_dir = %q{doc
|
13
|
+
doc.rdoc_dir = %q{doc}
|
14
14
|
doc.rdoc_files.include %w{
|
15
15
|
HISTORY
|
16
16
|
LICENSE
|
@@ -5,23 +5,23 @@ require 'test/unit'
|
|
5
5
|
require 'rack/test'
|
6
6
|
require 'test/customizations'
|
7
7
|
|
8
|
-
class
|
8
|
+
class BlogApplicationTest < Test::Unit::TestCase
|
9
9
|
|
10
10
|
include Rack::Test::Methods
|
11
11
|
|
12
12
|
def setup
|
13
|
-
Postview::path = "test/fixtures/
|
13
|
+
Postview::path = "test/fixtures/blog"
|
14
14
|
end
|
15
15
|
|
16
16
|
def app
|
17
|
-
@app = Postview::Application
|
17
|
+
@app = Postview::Application::Blog
|
18
18
|
|
19
19
|
@app.set :root, "#{File.dirname(__FILE__)}/.."
|
20
20
|
@app.set :environment, :test
|
21
21
|
@app
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
should "return ok for theme resources" do
|
25
25
|
get "/images/favicon.ico" do |response|
|
26
26
|
assert response.ok?
|
27
27
|
assert_equal "http://example.org/images/favicon.ico", last_request.url
|
@@ -43,53 +43,53 @@ class ApplicationTest < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
should "return ok in root path" do
|
47
47
|
get app.root_path do |response|
|
48
48
|
assert response.ok?
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
should "return ok in posts path" do
|
53
53
|
get app.posts_path do |response|
|
54
54
|
assert response.ok?
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
should "return ok in posts path with params" do
|
59
59
|
get app.posts_path "/2009/06/02/fourth_article" do |response|
|
60
60
|
assert response.ok?
|
61
61
|
assert_equal "http://example.org/posts/2009/06/02/fourth_article/", last_request.url
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
should "return ok in tags path" do
|
66
66
|
get app.tags_path do |response|
|
67
67
|
assert response.ok?
|
68
68
|
assert_equal "http://example.org/tags/", last_request.url
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
should "return ok in tags path with params" do
|
73
73
|
get app.tags_path "t1" do |response|
|
74
74
|
assert response.ok?
|
75
75
|
assert_equal "http://example.org/tags/t1/", last_request.url
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
|
79
|
+
should "return ok in archive path" do
|
80
80
|
get app.archive_path do |response|
|
81
81
|
assert response.ok?
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
should "return ok in archive path with params" do
|
86
86
|
get app.archive_path "2008/06/02/second_article" do |response|
|
87
87
|
assert response.ok?
|
88
88
|
assert_equal "http://example.org/archive/2008/06/02/second_article/", last_request.url
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
should "return ok in drafts path" do
|
93
93
|
authorize("Jack Ducklet", "s3kr3t")
|
94
94
|
get app.drafts_path do |response|
|
95
95
|
assert response.ok?
|
@@ -97,7 +97,7 @@ class ApplicationTest < Test::Unit::TestCase
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
should "return ok in drafts path with params" do
|
101
101
|
authorize("Jack Ducklet", "s3kr3t")
|
102
102
|
get app.drafts_path "2009/07/30/fifth_article" do |response|
|
103
103
|
assert response.ok?
|
@@ -105,13 +105,13 @@ class ApplicationTest < Test::Unit::TestCase
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
|
108
|
+
should "return ok in about path" do
|
109
109
|
get app.about_path do |response|
|
110
110
|
assert response.ok?
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
|
114
|
+
should "return ok in search path" do
|
115
115
|
get app.search_path, :anythink => "first" do |response|
|
116
116
|
assert response.ok?
|
117
117
|
assert_equal "first", last_request.params.values.to_s
|