toto 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -142,9 +142,9 @@ you could add `set :author, 'John Galt'` inside the `Toto::Server.new` block. He
142
142
  set :summary, :max => 150, :delim => /~\n/ # length of article summary and delimiter
143
143
  set :ext, 'txt' # file extension for articles
144
144
  set :cache, 28800 # cache site for 8 hours
145
- set :to_html, lambda {|path, page, ctx| # returns an html, from a path & context
145
+ set :to_html do |path, page, ctx| # returns an html, from a path & context
146
146
  ERB.new(File.read("#{path}/#{page}.rhtml")).result(ctx)
147
- }
147
+ end
148
148
 
149
149
  thanks
150
150
  ------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
data/lib/toto.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'yaml'
2
- require 'time'
2
+ require 'date'
3
3
  require 'erb'
4
4
  require 'rack'
5
5
  require 'digest'
@@ -143,7 +143,7 @@ module Toto
143
143
  end
144
144
 
145
145
  def self.articles ext
146
- Dir["#{Paths[:articles]}/*.#{ext}"]
146
+ Dir["#{Paths[:articles]}/*.#{ext}"].sort_by {|entry| File.basename(entry) }
147
147
  end
148
148
 
149
149
  class Context
@@ -228,14 +228,17 @@ module Toto
228
228
  def load
229
229
  data = if @obj.is_a? String
230
230
  meta, self[:body] = File.read(@obj).split(/\n\n/, 2)
231
- YAML.load(meta)
231
+
232
+ # use the date from the filename, or else toto won't find the article
233
+ @obj =~ /\/(\d{4}-\d{2}-\d{2})[^\/]*$/
234
+ ($1 ? {:date => $1} : {}).merge(YAML.load(meta))
232
235
  elsif @obj.is_a? Hash
233
236
  @obj
234
237
  end.inject({}) {|h, (k,v)| h.merge(k.to_sym => v) }
235
238
 
236
239
  self.taint
237
240
  self.update data
238
- self[:date] = Time.parse(self[:date].gsub('/', '-')) rescue Time.now
241
+ self[:date] = Date.parse(self[:date].gsub('/', '-')) rescue Date.today
239
242
  self
240
243
  end
241
244
 
data/test/toto_test.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'test/test_helper'
2
+ require 'date'
2
3
 
3
4
  URL = "http://toto.oz"
4
5
  AUTHOR = "toto"
@@ -136,11 +137,11 @@ context Toto do
136
137
  should("have a title") { topic.title }.equals "Toto & The Wizard of Oz."
137
138
  should("parse the body as markdown") { topic.body }.equals "<h1>Chapter I</h1>\n\n<p>hello, <em>stranger</em>.</p>\n"
138
139
  should("create an appropriate slug") { topic.slug }.equals "toto-and-the-wizard-of-oz"
139
- should("set the date") { topic.date }.equals "the time is #{Time.now.strftime("%Y/%m/%d %H:%M")}"
140
+ should("set the date") { topic.date }.equals "the time is #{Date.today.strftime("%Y/%m/%d %H:%M")}"
140
141
  should("create a summary") { topic.summary == topic.body }
141
142
  should("have an author") { topic.author }.equals AUTHOR
142
- should("have a path") { topic.path }.equals Time.now.strftime("/%Y/%m/%d/toto-and-the-wizard-of-oz/")
143
- should("have a url") { topic.url }.equals Time.now.strftime("#{URL}/%Y/%m/%d/toto-and-the-wizard-of-oz/")
143
+ should("have a path") { topic.path }.equals Date.today.strftime("/%Y/%m/%d/toto-and-the-wizard-of-oz/")
144
+ should("have a url") { topic.url }.equals Date.today.strftime("#{URL}/%Y/%m/%d/toto-and-the-wizard-of-oz/")
144
145
  end
145
146
 
146
147
  context "with a user-defined summary" do
data/toto.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{toto}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
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-02-18}
12
+ s.date = %q{2010-02-26}
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 = [
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.1
4
+ version: 0.4.2
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-02-18 00:00:00 -05:00
12
+ date: 2010-02-26 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency