toto 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
@@ -66,17 +66,10 @@ module Toto
66
66
  end
67
67
 
68
68
  def index type = :html
69
- case type
70
- when :html
71
- {:articles => self.articles.reverse.map do |article|
72
- Article.new article, @config
73
- end }.merge archives
74
- when :xml, :json
75
- return :articles => self.articles.map do |article|
76
- Article.new article, @config
77
- end
78
- else return {}
79
- end
69
+ articles = type == :html ? self.articles.reverse : self.articles
70
+ {:articles => articles.map do |article|
71
+ Article.new article, @config
72
+ end}.merge archives
80
73
  end
81
74
 
82
75
  def archives filter = ""
@@ -135,7 +128,7 @@ module Toto
135
128
  protected
136
129
 
137
130
  def http code
138
- return ["<font style='font-size:300%'>toto, we're not in Kansas anymore (#{code})</font>", code]
131
+ return [@config[:error_page].call(code), code]
139
132
  end
140
133
 
141
134
  def articles
@@ -165,7 +158,8 @@ module Toto
165
158
  end
166
159
 
167
160
  def render page, type
168
- type == :html ? to_html(:layout, @config, &Proc.new { to_html page, @config }) : send(:"to_#{type}", :feed)
161
+ content = to_html page, @config
162
+ type == :html ? to_html(:layout, @config, &Proc.new { content }) : send(:"to_#{type}", page)
169
163
  end
170
164
 
171
165
  def to_xml page
@@ -175,7 +169,7 @@ module Toto
175
169
  alias :to_atom to_xml
176
170
 
177
171
  def method_missing m, *args, &blk
178
- @context.respond_to?(m) ? @context.send(m) : super
172
+ @context.respond_to?(m) ? @context.send(m, *args, &blk) : super
179
173
  end
180
174
  end
181
175
  end
@@ -295,6 +289,9 @@ module Toto
295
289
  :github => {:user => "", :repos => [], :ext => 'md'}, # Github username and list of repos
296
290
  :to_html => lambda {|path, page, ctx| # returns an html, from a path & context
297
291
  ERB.new(File.read("#{path}/#{page}.rhtml")).result(ctx)
292
+ },
293
+ :error_page => lambda {|code| # The HTML for your error page
294
+ "<font style='font-size:300%'>toto, we're not in Kansas anymore (#{code})</font>"
298
295
  }
299
296
  }
300
297
  def initialize obj
@@ -0,0 +1,21 @@
1
+ xml.instruct!
2
+ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
3
+ xml.title @config[:title]
4
+ xml.id @config[:url]
5
+ xml.updated articles.first[:date].iso8601 unless articles.empty?
6
+ xml.author { xml.name @config[:author] }
7
+
8
+ articles.each do |article|
9
+ xml.entry do
10
+ xml.title article.title
11
+ xml.link "rel" => "alternate", "href" => article.url
12
+ xml.id article.url
13
+ xml.published article[:date].iso8601
14
+ xml.updated article[:date].iso8601
15
+ xml.author { xml.name @config[:author] }
16
+ xml.summary article.summary, "type" => "html"
17
+ xml.content article.body, "type" => "html"
18
+ end
19
+ end
20
+ end
21
+
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{toto}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["cloudhead"]
12
- s.date = %q{2010-03-01}
12
+ s.date = %q{2010-03-17}
13
13
  s.description = %q{the tiniest blog-engine in Oz.}
14
14
  s.email = %q{self@cloudhead.net}
15
15
  s.extra_rdoc_files = [
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  "test/templates/archives.rhtml",
36
36
  "test/templates/article.rhtml",
37
37
  "test/templates/feed.builder",
38
+ "test/templates/index.builder",
38
39
  "test/templates/index.rhtml",
39
40
  "test/templates/layout.rhtml",
40
41
  "test/templates/repo.rhtml",
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.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloudhead
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-01 00:00:00 -05:00
12
+ date: 2010-03-17 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -80,6 +80,7 @@ files:
80
80
  - test/templates/archives.rhtml
81
81
  - test/templates/article.rhtml
82
82
  - test/templates/feed.builder
83
+ - test/templates/index.builder
83
84
  - test/templates/index.rhtml
84
85
  - test/templates/layout.rhtml
85
86
  - test/templates/repo.rhtml