toto 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -14
- data/VERSION +1 -1
- data/lib/toto.rb +10 -12
- data/test/toto_test.rb +7 -1
- data/toto.gemspec +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -22,18 +22,19 @@ how it works
|
|
22
22
|
- articles are processed through a markdown converter (rdiscount) by default.
|
23
23
|
- templating is done through **ERB**.
|
24
24
|
- toto is built right on top of **Rack**.
|
25
|
-
- comments are handled by disqus
|
25
|
+
- comments are handled by [disqus](http://disqus.com)
|
26
26
|
- individual articles can be accessed through urls such as _/2009/11/21/blogging-with-toto_
|
27
27
|
- the archives can be accessed by year, month or day, wih the same format as above.
|
28
|
+
- arbitrary metadata can be included in articles files, and accessed from the templates.
|
28
29
|
|
29
30
|
synopsis
|
30
31
|
--------
|
31
32
|
|
32
|
-
One would start by forking or cloning the
|
33
|
+
One would start by forking or cloning the `dorothy` repo, to get a basic skeleton:
|
33
34
|
|
34
35
|
$ mkdir weblog/
|
35
36
|
$ cd weblog/
|
36
|
-
$ git clone git://github.com/cloudhead/
|
37
|
+
$ git clone git://github.com/cloudhead/dorothy.git .
|
37
38
|
|
38
39
|
One would then edit the template at will, it has the following structure:
|
39
40
|
|
@@ -92,7 +93,7 @@ With unicorn, you can just do:
|
|
92
93
|
|
93
94
|
#### on heroku
|
94
95
|
|
95
|
-
Toto was designed to work well with heroku
|
96
|
+
Toto was designed to work well with [heroku](http://heroku.com), it makes the most out of it's state-of-the-art caching,
|
96
97
|
by setting the _Cache-Control_ and _Etag_ HTTP headers. Deploying on Heroku is really easy, just get the heroku gem,
|
97
98
|
create a heroku app with `heroku create`, and push with `git push heroku master`.
|
98
99
|
|
@@ -104,15 +105,15 @@ create a heroku app with `heroku create`, and push with `git push heroku master`
|
|
104
105
|
### configuration
|
105
106
|
|
106
107
|
You can configure toto, by modifying the _config.ru_ file. For example, if you want to set the blog author to 'John Galt',
|
107
|
-
you could add `set :author, 'John Galt'` inside the `Toto::Server.new` block. Here
|
108
|
-
|
109
|
-
:author
|
110
|
-
:title
|
111
|
-
:root
|
112
|
-
:date
|
113
|
-
:markdown
|
114
|
-
:disqus
|
115
|
-
:summary
|
116
|
-
:ext
|
108
|
+
you could add `set :author, 'John Galt'` inside the `Toto::Server.new` block. Here are the defaults, to get you started:
|
109
|
+
|
110
|
+
set :author, ENV['USER'] # blog author
|
111
|
+
set :title, Dir.pwd.split('/').last # site title
|
112
|
+
set :root, "index" # page to load on /
|
113
|
+
set :date, lambda {|now| now.strftime("%d/%m/%Y") } # date format for articles
|
114
|
+
set :markdown, :smart # use markdown + smart-mode
|
115
|
+
set :disqus, false # disqus id, or false
|
116
|
+
set :summary, 150 # length of article summary
|
117
|
+
set :ext, 'txt' # file extension for articles
|
117
118
|
|
118
119
|
Copyright (c) 2009 cloudhead. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/toto.rb
CHANGED
@@ -83,27 +83,25 @@ module Toto
|
|
83
83
|
|
84
84
|
body, status = if Context.new.respond_to?(:"to_#{type}")
|
85
85
|
if route.first =~ /\d{4}/
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
else http 400
|
93
|
-
end
|
94
|
-
rescue Errno::ENOENT => e
|
95
|
-
$stderr.puts e
|
96
|
-
http 404
|
86
|
+
case route.size
|
87
|
+
when 1..3
|
88
|
+
[Context.new(archives(route * '-'), @config).render(:archives, type), 200]
|
89
|
+
when 4
|
90
|
+
[Context.new(article(route), @config).render(:article, type), 200]
|
91
|
+
else http 400
|
97
92
|
end
|
98
93
|
elsif respond_to?(route = route.first.to_sym)
|
99
94
|
[Context.new(send(route, type), @config).render(route, type), 200]
|
100
95
|
else
|
101
|
-
|
96
|
+
[Context.new({}, @config).render(route.to_sym, type), 200]
|
102
97
|
end
|
103
98
|
else
|
104
99
|
http 400
|
105
100
|
end
|
106
101
|
|
102
|
+
rescue Errno::ENOENT => e
|
103
|
+
body, status = http 404
|
104
|
+
ensure
|
107
105
|
return :body => body, :type => type, :status => status
|
108
106
|
end
|
109
107
|
|
data/test/toto_test.rb
CHANGED
@@ -29,6 +29,12 @@ context Toto do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
context "GET /about" do
|
33
|
+
setup { @toto.get('/about') }
|
34
|
+
asserts("returns a 200") { topic.status }.equals 200
|
35
|
+
asserts("body is not empty") { not topic.body.empty? }
|
36
|
+
end
|
37
|
+
|
32
38
|
context "GET a single article" do
|
33
39
|
setup { @toto.get("/1900/05/17/the-wonderful-wizard-of-oz") }
|
34
40
|
asserts("returns a 200") { topic.status }.equals 200
|
@@ -56,7 +62,7 @@ context Toto do
|
|
56
62
|
|
57
63
|
context "GET to an unknown route" do
|
58
64
|
setup { @toto.get('/unknown') }
|
59
|
-
should("returns a
|
65
|
+
should("returns a 404") { topic.status }.equals 404
|
60
66
|
end
|
61
67
|
|
62
68
|
context "Request is invalid" do
|
data/toto.gemspec
CHANGED