toto 0.1.6 → 0.2.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 (6) hide show
  1. data/README.md +15 -14
  2. data/VERSION +1 -1
  3. data/lib/toto.rb +10 -12
  4. data/test/toto_test.rb +7 -1
  5. data/toto.gemspec +1 -1
  6. 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:(http://disqus.com)
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 toto-skeleton repo, to get a basic skeleton:
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/toto-skeleton.git .
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:(http://heroku.com), it makes the most out of it's state-of-the-art caching,
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's the options hash with the defaults:
108
-
109
- :author => ENV['USER'], # blog author
110
- :title => Dir.pwd.split('/').last, # site title
111
- :root => "index", # page to load on /
112
- :date => lambda {|now| now.strftime("%d/%m/%Y") }, # date format for articles
113
- :markdown => :smart, # use markdown + smart-mode
114
- :disqus => false, # disqus id, or false
115
- :summary => 150, # length of article summary
116
- :ext => 'txt' # file extension for articles
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.6
1
+ 0.2.0
@@ -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
- begin
87
- case route.size
88
- when 1..3
89
- [Context.new(archives(route * '-'), @config).render(:archives, type), 200]
90
- when 4
91
- [Context.new(article(route), @config).render(:article, type), 200]
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
- http 401
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
 
@@ -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 401") { topic.status }.equals 401
65
+ should("returns a 404") { topic.status }.equals 404
60
66
  end
61
67
 
62
68
  context "Request is invalid" do
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{toto}
8
- s.version = "0.1.6"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["cloudhead"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloudhead