toto-bongo 1.0.1
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.
- data/.document +5 -0
- data/LICENSE +23 -0
- data/README.md +186 -0
- data/Rakefile +31 -0
- data/VERSION +1 -0
- data/lib/ext/ext.rb +46 -0
- data/lib/toto-bongo.rb +543 -0
- data/test/articles/1900-05-17-the-wonderful-wizard-of-oz.txt +5 -0
- data/test/articles/2001-01-01-two-thousand-and-one.txt +5 -0
- data/test/articles/2009-04-01-tilt-factor.txt +5 -0
- data/test/articles/2009-12-04-some-random-article.txt +5 -0
- data/test/articles/2009-12-11-the-dichotomy-of-design.txt +5 -0
- data/test/autotest.rb +34 -0
- data/test/templates/about.html.haml +0 -0
- data/test/templates/archives.html.haml +7 -0
- data/test/templates/article.html.haml +16 -0
- data/test/templates/feed.builder +21 -0
- data/test/templates/index.builder +21 -0
- data/test/templates/index.html.haml +14 -0
- data/test/templates/layout.html.haml +14 -0
- data/test/test_helper.rb +44 -0
- data/test/toto_test.rb +285 -0
- data/toto-bongo.gemspec +75 -0
- metadata +140 -0
data/.document
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Copyright (c) 2011 Daniel Palacio
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2009 cloudhead
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
toto bongo
|
|
2
|
+
====
|
|
3
|
+
|
|
4
|
+
Minimal blog forked from toto to use for your existing app's.
|
|
5
|
+
This is very useful for SEO optimization
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
introduction
|
|
9
|
+
------------
|
|
10
|
+
|
|
11
|
+
toto-bongo is a git-powered, minimalist blog engine forked from toto.
|
|
12
|
+
There is no toto client, and there probably will never be, everything goes through git.
|
|
13
|
+
From the security stand point, this makes toto-bongo very secure. By
|
|
14
|
+
reducing the attack surface( we don't handle any user input) we've made
|
|
15
|
+
a blog you can trust.
|
|
16
|
+
Other blogs have administration panels, sessions, cookies etc, that lead
|
|
17
|
+
to security vulnerabilities, toto-bongo has non of that.
|
|
18
|
+
|
|
19
|
+
blog in your app in 10 seconds
|
|
20
|
+
------------------
|
|
21
|
+
|
|
22
|
+
Toto-bongo was designed to be used with a reverse-proxy cache, such as [Varnish](http://varnish-cache.org).
|
|
23
|
+
This makes it an ideal candidate for **[heroku](http://heroku.com)**.
|
|
24
|
+
|
|
25
|
+
This is how to deploy in your existing app:
|
|
26
|
+
|
|
27
|
+
1. git clone git@github.com:danpal/toto-bongo-blog.git
|
|
28
|
+
2. Look at toto-bongo-blog Gemfile, add the following gems to your
|
|
29
|
+
Gemfile.
|
|
30
|
+
|
|
31
|
+
gem 'toto-bongo'
|
|
32
|
+
gem 'builder'
|
|
33
|
+
gem 'RedCloth'
|
|
34
|
+
gem 'haml'
|
|
35
|
+
|
|
36
|
+
3. Toto-bongo runs on rack, you need to modify your existing config.ru
|
|
37
|
+
we provide you with an already existing config.ru, take a look at
|
|
38
|
+
toto-bongo-blog config.ru
|
|
39
|
+
(note this file might be outdated here, look at the one in the
|
|
40
|
+
toto-bongo-blog)
|
|
41
|
+
<pre><code>
|
|
42
|
+
# This file is used by Rack-based servers to start the application.
|
|
43
|
+
require 'toto-bongo'
|
|
44
|
+
require ::File.expand_path('../config/environment', __FILE__)
|
|
45
|
+
|
|
46
|
+
#point to your rails apps /public directory
|
|
47
|
+
use Rack::Static, :urls => ['/stylesheets', '/javascripts', '/images', '/favicon.ico'], :root => 'public'
|
|
48
|
+
|
|
49
|
+
use Rack::ShowExceptions
|
|
50
|
+
use Rack::CommonLogger
|
|
51
|
+
|
|
52
|
+
#run the toto application
|
|
53
|
+
toto_bongo = TotoBongo::Server.new do
|
|
54
|
+
|
|
55
|
+
#override the default location for the toto directories
|
|
56
|
+
TotoBongo::Paths = {
|
|
57
|
+
:templates => "blog/templates",
|
|
58
|
+
:pages => "blog/templates/pages",
|
|
59
|
+
:articles => "blog/articles"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# set your config variables here
|
|
63
|
+
set :title, 'toto-bongo blog'
|
|
64
|
+
set :date, lambda {|now| now.strftime("%B #{now.day.ordinal} %Y") }
|
|
65
|
+
set :summary, :max => 500
|
|
66
|
+
set :root, 'index'
|
|
67
|
+
set :prefix, 'blog'
|
|
68
|
+
|
|
69
|
+
if RAILS_ENV != 'production'
|
|
70
|
+
set :url, "http://localhost:3000/blog/"
|
|
71
|
+
else
|
|
72
|
+
set :url, "http://toto-bongo.heroku.com/blog/" #EDIT THIS TO ADD YOUR OWN URL
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
#create a rack app
|
|
77
|
+
app = Rack::Builder.new do
|
|
78
|
+
use Rack::CommonLogger
|
|
79
|
+
|
|
80
|
+
#map requests to /blog to toto
|
|
81
|
+
map '/blog' do
|
|
82
|
+
run toto_bongo
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
#map all the other requests to rails
|
|
86
|
+
map '/' do
|
|
87
|
+
if Rails.version.to_f >= 3.0
|
|
88
|
+
ActionDispatch::Static
|
|
89
|
+
#run [ApplicationName]::Application
|
|
90
|
+
run TotoBongoBlog::Application #change for your application name
|
|
91
|
+
else # Rails 2
|
|
92
|
+
use Rails::Rack::Static
|
|
93
|
+
run ActionController::Dispatcher.new
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end.to_app
|
|
97
|
+
|
|
98
|
+
</code></pre>
|
|
99
|
+
|
|
100
|
+
Then make the following changes
|
|
101
|
+
1. Change :title
|
|
102
|
+
2. Run TotoBongoBlog::Application #change for your application name
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
how it works
|
|
110
|
+
------------
|
|
111
|
+
|
|
112
|
+
- content is entirely managed through **git**; you get full fledged version control for free.
|
|
113
|
+
- articles are stored as _.txt_ files, with embeded metadata (in yaml format).
|
|
114
|
+
- articles are processed through a textile converter(RedCloth) by default.
|
|
115
|
+
- templating is done through **HAML**.
|
|
116
|
+
- toto is built right on top of **Rack**.
|
|
117
|
+
- toto was built to take advantage of _HTTP caching_.
|
|
118
|
+
- toto was built with heroku in mind.
|
|
119
|
+
- comments are handled by [disqus](http://disqus.com)
|
|
120
|
+
- individual articles can be accessed through urls such as _/2009/11/21/blogging-with-toto_
|
|
121
|
+
- the archives can be accessed by year, month or day, wih the same format as above.
|
|
122
|
+
- arbitrary metadata can be included in articles files, and accessed from the templates.
|
|
123
|
+
- summaries are generated intelligently by toto, following the `:max` setting you give it.
|
|
124
|
+
- you can also define how long your summary is, by adding `~` at the end of it (`:delim`).
|
|
125
|
+
|
|
126
|
+
toto-blog
|
|
127
|
+
-------
|
|
128
|
+
|
|
129
|
+
### deployment
|
|
130
|
+
|
|
131
|
+
Toto is built on top of **Rack**, and hence has a **rackup** file: _config.ru_.
|
|
132
|
+
|
|
133
|
+
#### on your own server
|
|
134
|
+
|
|
135
|
+
Once you have created the remote git repo, and pushed your changes to it, you can run toto with any Rack compliant web server,
|
|
136
|
+
such as **thin**, **mongrel** or **unicorn**.
|
|
137
|
+
|
|
138
|
+
With thin, you would do something like:
|
|
139
|
+
|
|
140
|
+
$ thin start -R config.ru
|
|
141
|
+
|
|
142
|
+
With unicorn, you can just do:
|
|
143
|
+
|
|
144
|
+
$ unicorn
|
|
145
|
+
|
|
146
|
+
### configuration
|
|
147
|
+
|
|
148
|
+
You can configure toto, by modifying the _config.ru_ file. For example, if you want to set the blog author to 'John Galt',
|
|
149
|
+
you could add `set :author, 'John Galt'` inside the `Toto::Server.new` block. Here are the defaults, to get you started:
|
|
150
|
+
|
|
151
|
+
set :author, ENV['USER'] # blog author
|
|
152
|
+
set :title, Dir.pwd.split('/').last # site title
|
|
153
|
+
set :url, 'http://example.com' # site root URL
|
|
154
|
+
set :prefix, 'blog' # common path prefix for all pages
|
|
155
|
+
set :root, "index" # page to load on /
|
|
156
|
+
set :date, lambda {|now| now.strftime("%d/%m/%Y") } # date format for articles
|
|
157
|
+
set :disqus, false # disqus id, or false
|
|
158
|
+
set :summary, :max => 150, :delim => /~\n/ # length of article summary and delimiter
|
|
159
|
+
set :ext, 'txt' # file extension for articles
|
|
160
|
+
set :cache, 28800 # cache site for 8 hours
|
|
161
|
+
|
|
162
|
+
set :to_html do |path, page, ctx| # returns an html, from a path & context
|
|
163
|
+
ERB.new(File.read("#{path}/#{page}.rhtml")).result(ctx)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
set :error do |code| # The HTML for your error page
|
|
167
|
+
"<font style='font-size:300%'>toto-bongo, error (#{code})</font>"
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
### Development
|
|
171
|
+
|
|
172
|
+
rake gemspec: To generate the gemspec
|
|
173
|
+
gem build toto-bongo.gemspec to build
|
|
174
|
+
|
|
175
|
+
If you are developing use the following enviromental variable to get
|
|
176
|
+
some debugging output
|
|
177
|
+
export TOTODEBUG=true
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
thanks
|
|
182
|
+
------
|
|
183
|
+
|
|
184
|
+
To toto team, as they are the real developers behind toto.
|
|
185
|
+
|
|
186
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'jeweler'
|
|
6
|
+
Jeweler::Tasks.new do |gem|
|
|
7
|
+
gem.name = "toto-bongo"
|
|
8
|
+
gem.summary = %Q{Tiny blog for your existing app}
|
|
9
|
+
gem.description = %Q{Minimal blog to use with your existing app}
|
|
10
|
+
gem.homepage = "https://github.com/danpal/toto-bongo"
|
|
11
|
+
gem.authors = ["Daniel Palacio"]
|
|
12
|
+
gem.add_development_dependency "riot"
|
|
13
|
+
gem.add_dependency "builder"
|
|
14
|
+
gem.add_dependency "rack"
|
|
15
|
+
gem.add_dependency "RedCloth"
|
|
16
|
+
end
|
|
17
|
+
Jeweler::GemcutterTasks.new
|
|
18
|
+
rescue LoadError
|
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
require 'rake/testtask'
|
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
|
24
|
+
test.libs << 'lib' << 'test'
|
|
25
|
+
test.pattern = 'test/**/*_test.rb'
|
|
26
|
+
test.verbose = true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
task :test => :check_dependencies
|
|
30
|
+
task :default => :test
|
|
31
|
+
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.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 Bongo 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
|