toto 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -1
- data/VERSION +1 -1
- data/lib/toto.rb +9 -3
- data/test/toto_test.rb +11 -0
- data/toto.gemspec +2 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -26,6 +26,8 @@ how it works
|
|
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
28
|
- arbitrary metadata can be included in articles files, and accessed from the templates.
|
29
|
+
- summaries are generated intelligently by toto, following the `:max` setting you give it.
|
30
|
+
- you can also define how long your summary is, by adding `~` at the end of it (`:delim`).
|
29
31
|
|
30
32
|
synopsis
|
31
33
|
--------
|
@@ -113,7 +115,7 @@ you could add `set :author, 'John Galt'` inside the `Toto::Server.new` block. He
|
|
113
115
|
set :date, lambda {|now| now.strftime("%d/%m/%Y") } # date format for articles
|
114
116
|
set :markdown, :smart # use markdown + smart-mode
|
115
117
|
set :disqus, false # disqus id, or false
|
116
|
-
set :summary, 150
|
118
|
+
set :summary, :max => 150, :delim => /~\n/ # length of article summary and delimiter
|
117
119
|
set :ext, 'txt' # file extension for articles
|
118
120
|
|
119
121
|
Copyright (c) 2009 cloudhead. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/toto.rb
CHANGED
@@ -187,8 +187,14 @@ module Toto
|
|
187
187
|
self[:title].downcase.gsub(/&/, 'and').gsub(/\s+/, '-').gsub(/[^a-z0-9-]/, '')
|
188
188
|
end
|
189
189
|
|
190
|
-
def summary length =
|
191
|
-
|
190
|
+
def summary length = nil
|
191
|
+
length ||= (config = @config[:summary]).is_a?(Hash) ? config[:max] : config
|
192
|
+
|
193
|
+
if self[:body] =~ config[:delim]
|
194
|
+
markdown self[:body].split(config[:delim]).first
|
195
|
+
else
|
196
|
+
markdown self[:body].match(/(.{1,#{length}}.*?)(\n|\Z)/m).to_s
|
197
|
+
end
|
192
198
|
end
|
193
199
|
|
194
200
|
def url
|
@@ -228,7 +234,7 @@ module Toto
|
|
228
234
|
:date => lambda {|now| now.strftime("%d/%m/%Y") }, # date function
|
229
235
|
:markdown => :smart, # use markdown
|
230
236
|
:disqus => false, # disqus name
|
231
|
-
:summary => 150,
|
237
|
+
:summary => {:max => 150, :delim => /~\n/}, # length of summary and delimiter
|
232
238
|
:ext => 'txt' # extension for articles
|
233
239
|
}
|
234
240
|
def initialize obj
|
data/test/toto_test.rb
CHANGED
@@ -102,6 +102,17 @@ context Toto do
|
|
102
102
|
should("have a url") { topic.url }.equals Time.now.strftime("#{URL}/%Y/%m/%d/toto-and-the-wizard-of-oz/")
|
103
103
|
end
|
104
104
|
|
105
|
+
context "with a user-defined summary" do
|
106
|
+
setup do
|
107
|
+
Toto::Article.new({
|
108
|
+
:title => "Toto & The Wizard of Oz.",
|
109
|
+
:body => "Well,\nhello ~\n, *stranger*."
|
110
|
+
}, @config.merge(:markdown => false, :summary => {:max => 150, :delim => /~\n/}))
|
111
|
+
end
|
112
|
+
|
113
|
+
should("split the article at the delimiter") { topic.summary }.equals "Well,\nhello"
|
114
|
+
end
|
115
|
+
|
105
116
|
context "with everything specified" do
|
106
117
|
setup do
|
107
118
|
Toto::Article.new({
|
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.2.
|
8
|
+
s.version = "0.2.1"
|
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-01-
|
12
|
+
s.date = %q{2010-01-18}
|
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.2.
|
4
|
+
version: 0.2.1
|
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-01-
|
12
|
+
date: 2010-01-18 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|