robb-toto 0.4.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 cloudhead
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,208 @@
1
+ toto
2
+ ====
3
+
4
+ the tiniest blogging engine in Oz!
5
+
6
+ introduction
7
+ ------------
8
+
9
+ toto is a git-powered, minimalist blog engine for the hackers of Oz. The
10
+ engine weighs around ~300 sloc at its worse. There is no toto client,
11
+ at least for now; everything goes through git.
12
+
13
+ blog in 10 seconds
14
+ ------------------
15
+
16
+ $ git clone git://github.com/cloudhead/dorothy.git myblog
17
+ $ cd myblog
18
+ $ heroku create myblog
19
+ $ git push heroku master
20
+
21
+ philosophy
22
+ ----------
23
+
24
+ Everything that can be done better with another tool should be, but one
25
+ should not have too much pie to stay fit. In other words, toto does away
26
+ with web frameworks or DSLs such as sinatra, and is built right on top
27
+ of **rack**. There is no database or ORM either, we use plain text files.
28
+
29
+ Toto was designed to be used with a reverse-proxy cache, such as
30
+ [Varnish](http://varnish-cache.org). This makes it an ideal candidate
31
+ for [heroku](http://heroku.com).
32
+
33
+ Oh, and everything that can be done with git, _is_.
34
+
35
+ how it works
36
+ ------------
37
+
38
+ - content is entirely managed through **git**; you get full fledged version
39
+ control for free.
40
+ - articles are stored as _.txt_ files, with embeded metadata (in yaml format).
41
+ - articles are processed through a markdown converter (rdiscount) by default.
42
+ - templating is done through **ERB**.
43
+ - toto is built right on top of **Rack**.
44
+ - toto was built to take advantage of _HTTP caching_.
45
+ - toto was built with heroku in mind.
46
+ - comments are handled by [disqus](http://disqus.com)
47
+ - individual articles can be accessed through urls such as
48
+ _/2009/11/21/blogging-with-toto_
49
+ - the archives can be accessed by year, month or day, wih the same format as
50
+ above.
51
+ - arbitrary metadata can be included in articles files, and accessed from the
52
+ templates.
53
+ - summaries are generated intelligently by toto, following the `:max` setting
54
+ you give it.
55
+ - you can also define how long your summary is, by adding `~` at the end of it
56
+ (`:delim`).
57
+
58
+ dorothy
59
+ -------
60
+
61
+ Dorothy is toto's default template, you can get it at
62
+ <http://github.com/cloudhead/dorothy>. It comes with a very minimalistic
63
+ but functional template, and a _config.ru_ file to get you started.
64
+ It also includes a _.gems_ file, for heroku.
65
+
66
+ synopsis
67
+ --------
68
+
69
+ One would start by installing _toto_, with `sudo gem install toto`,
70
+ and then forking or cloning the `dorothy` repo, to get a basic skeleton:
71
+
72
+ $ git clone git://github.com/cloudhead/dorothy.git weblog
73
+ $ cd weblog/
74
+
75
+ One would then edit the template at will, it has the following structure:
76
+
77
+ templates/
78
+ |
79
+ +- layout.rhtml # the main site layout, shared by all pages
80
+ |
81
+ +- index.builder # the builder template for the atom feed
82
+ |
83
+ +- pages/ # pages, such as home, about, etc go here
84
+ |
85
+ +- index.rhtml # the default page loaded from `/`, it displays the list of articles
86
+ |
87
+ +- article.rhtml # the article (post) partial and page
88
+ |
89
+ +- about.rhtml
90
+
91
+ One could then create a .txt article file in the `articles/` folder,
92
+ and make sure it has the following format:
93
+
94
+ title: The Wonderful Wizard of Oz
95
+ author: Lyman Frank Baum
96
+ date: 1900/05/17
97
+
98
+ Dorothy lived in the midst of the great Kansas prairies, with Uncle Henry,
99
+ who was a farmer, and Aunt Em, who was the farmer's wife.
100
+
101
+ If one is familiar with webby or aerial, this shouldn't look
102
+ funny. Basically the top of the file is in YAML format, and the rest
103
+ of it is the blog post. They are delimited by an empty line `/\n\n/`,
104
+ as you can see above. None of the information is compulsory, but it's
105
+ strongly encouraged you specify it. Note that one can also use `rake`
106
+ to create an article stub, with `rake new`.
107
+
108
+ Once he finishes writing his beautiful tale, one can push to the git repo,
109
+ as usual:
110
+
111
+ $ git add articles/wizard-of-oz.txt
112
+ $ git commit -m 'wrote the wizard of oz.'
113
+ $ git push remote master
114
+
115
+ Where `remote` is the name of your remote git repository. The article
116
+ is now published.
117
+
118
+ ### deployment
119
+
120
+ Toto is built on top of **Rack**, and hence has a **rackup** file: _config.ru_.
121
+
122
+ #### on your own server
123
+
124
+ Once you have created the remote git repo, and pushed your changes to it,
125
+ you can run toto with any Rack compliant web server, such as **thin**,
126
+ **mongrel** or **unicorn**.
127
+
128
+ With thin, you would do something like:
129
+
130
+ $ thin start -R config.ru
131
+
132
+ With unicorn, you can just do:
133
+
134
+ $ unicorn
135
+
136
+ #### on heroku
137
+
138
+ Toto was designed to work well with [heroku](http://heroku.com), it
139
+ makes the most out of it's state-of-the-art caching, by setting the
140
+ _Cache-Control_ and _Etag_ HTTP headers. Deploying on Heroku is really
141
+ easy, just get the heroku gem, create a heroku app with `heroku create`,
142
+ and push with `git push heroku master`.
143
+
144
+ $ heroku create weblog
145
+ $ git push heroku master
146
+ $ heroku open
147
+
148
+ ### configuration
149
+
150
+ You can configure toto, by modifying the _config.ru_ file. For example,
151
+ if you want to set the blog author to 'John Galt', you could add `set
152
+ :author, 'John Galt'` inside the `Toto::Server.new` block. Here are the
153
+ defaults, to get you started:
154
+
155
+ set :author, ENV['USER'] # blog author
156
+ set :title, Dir.pwd.split('/').last # site title
157
+ set :url, 'http://example.com' # site root URL
158
+ set :prefix, '' # common path prefix for all pages
159
+ set :permalink, '/:year/:month/:day/:title' # structure of article's URLs
160
+ set :root, "index" # page to load on /
161
+ set :date, lambda {|now| now.strftime("%d/%m/%Y") } # date format for articles
162
+ set :markdown, :smart # use markdown + smart-mode
163
+ set :disqus, false # disqus id, or false
164
+ set :summary, :max => 150, :delim => /~\n/ # length of article summary and delimiter
165
+ set :ext, 'txt' # file extension for articles
166
+ set :cache, 28800 # cache site for 8 hours
167
+ set :github, :user => "", :repos => [], :ext => 'md' # get READMEs from this user's repositories
168
+
169
+ set :to_html do |path, page, ctx| # returns an html, from a path & context
170
+ ERB.new(File.read("#{path}/#{page}.rhtml")).result(ctx)
171
+ end
172
+
173
+ set :error do |code| # The HTML for your error page
174
+ "<font style='font-size:300%'>toto, we're not in Kansas anymore (#{code})</font>"
175
+ end
176
+
177
+
178
+ #### permalinks
179
+
180
+ Toto includes supports for custom URLs for the articles. Prior
181
+ to the inclusion of this feature, all article's URLs were
182
+ forced to have the structure "/year/month/day/title". Now,
183
+ you can modify that path, to include (or exclude) whatever
184
+ data you want. The custom permalink's syntax follows that of
185
+ [Jekyll's](http://wiki.github.com/mojombo/jekyll/permalinks), so anyone
186
+ familiar with it should feel right at home with Toto's permalinks. Toto
187
+ provides 4 preexisting variables:
188
+
189
+
190
+ * `:year` - The year the article was made, derived from the date
191
+ * `:month` - The month the article was made, derived from the date
192
+ * `:day` - The day the article was made, derived from the date
193
+ * `:title` - The title of the article, with URL un-safe characters removed.
194
+ (The slug)
195
+
196
+ Also, any extra YAML front matter can be used in the structure. If
197
+ you define one of the pre-existing variables in the front matter
198
+ (excluding title), the value in the front-matter will override the
199
+ derived variable. `:title` will always be the slug.
200
+
201
+ thanks
202
+ ------
203
+
204
+ To heroku for making this easy as pie.
205
+ To adam wiggins, as I stole a couple of ideas from Scanty.
206
+ To the developpers of Rack, for making such an awesome platform.
207
+
208
+ Copyright (c) 2009-2010 cloudhead. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "robb-toto"
8
+ gem.summary = %Q{the tiniest blog-engine in Oz}
9
+ gem.description = %Q{the tiniest blog-engine in Oz. Build of evaryont's branch with better permalink choices}
10
+ gem.email = "self@cloudhead.net"
11
+ gem.homepage = "http://github.com/cloudhead/toto"
12
+ gem.authors = ["cloudhead", "evaryont"]
13
+ gem.add_development_dependency "riot"
14
+ gem.add_dependency "builder"
15
+ gem.add_dependency "rack"
16
+ if RUBY_PLATFORM =~ /win32/
17
+ gem.add_dependency "maruku"
18
+ else
19
+ gem.add_dependency "rdiscount"
20
+ end
21
+ end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
25
+ end
26
+
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |test|
29
+ test.libs << 'lib' << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+
34
+ task :test => :check_dependencies
35
+ task :default => :test
data/TODO ADDED
@@ -0,0 +1,2 @@
1
+ TODO
2
+ ====
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.6.1
data/lib/ext/ext.rb ADDED
@@ -0,0 +1,46 @@
1
+ class Object
2
+ def meta_def name, &blk
3
+ (class << self; self; end).instance_eval do
4
+ define_method(name, &blk)
5
+ end
6
+ end
7
+ end
8
+
9
+ class String
10
+ def slugize
11
+ self.downcase.gsub(/&/, 'and').gsub(/\s+/, '-').gsub(/[^a-z0-9-]/, '')
12
+ end
13
+
14
+ def humanize
15
+ self.capitalize.gsub(/[-_]+/, ' ')
16
+ end
17
+ end
18
+
19
+ class Fixnum
20
+ def ordinal
21
+ # 1 => 1st
22
+ # 2 => 2nd
23
+ # 3 => 3rd
24
+ # ...
25
+ case self % 100
26
+ when 11..13; "#{self}th"
27
+ else
28
+ case self % 10
29
+ when 1; "#{self}st"
30
+ when 2; "#{self}nd"
31
+ when 3; "#{self}rd"
32
+ else "#{self}th"
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ class Date
39
+ # This check is for people running Toto with ActiveSupport, avoid a collision
40
+ unless respond_to? :iso8601
41
+ # Return the date as a String formatted according to ISO 8601.
42
+ def iso8601
43
+ ::Time.utc(year, month, day, 0, 0, 0, 0).iso8601
44
+ end
45
+ end
46
+ end