glinda 0.1.0

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 ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour --format Fuubar
2
+
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'rspec'
5
+ gem 'capybara'
6
+ end
7
+
8
+ gem 'rdiscount'
9
+ gem 'builder'
10
+
11
+ group :development do
12
+ gem 'fuubar'
13
+ gem 'rake'
14
+ gem 'jeweler'
15
+ gem 'gemcutter'
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,71 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.2)
5
+ builder (3.0.0)
6
+ capybara (1.1.2)
7
+ mime-types (>= 1.16)
8
+ nokogiri (>= 1.3.3)
9
+ rack (>= 1.0.0)
10
+ rack-test (>= 0.5.4)
11
+ selenium-webdriver (~> 2.0)
12
+ xpath (~> 0.1.4)
13
+ childprocess (0.3.5)
14
+ ffi (~> 1.0, >= 1.0.6)
15
+ diff-lcs (1.1.3)
16
+ ffi (1.1.5)
17
+ fuubar (1.0.0)
18
+ rspec (~> 2.0)
19
+ rspec-instafail (~> 0.2.0)
20
+ ruby-progressbar (~> 0.0.10)
21
+ gemcutter (0.7.1)
22
+ git (1.2.5)
23
+ jeweler (1.8.4)
24
+ bundler (~> 1.0)
25
+ git (>= 1.2.5)
26
+ rake
27
+ rdoc
28
+ json (1.7.5)
29
+ libwebsocket (0.1.5)
30
+ addressable
31
+ mime-types (1.19)
32
+ multi_json (1.3.6)
33
+ nokogiri (1.5.5)
34
+ rack (1.4.1)
35
+ rack-test (0.6.1)
36
+ rack (>= 1.0)
37
+ rake (0.9.2.2)
38
+ rdiscount (1.6.8)
39
+ rdoc (3.12)
40
+ json (~> 1.4)
41
+ rspec (2.11.0)
42
+ rspec-core (~> 2.11.0)
43
+ rspec-expectations (~> 2.11.0)
44
+ rspec-mocks (~> 2.11.0)
45
+ rspec-core (2.11.1)
46
+ rspec-expectations (2.11.3)
47
+ diff-lcs (~> 1.1.3)
48
+ rspec-instafail (0.2.4)
49
+ rspec-mocks (2.11.2)
50
+ ruby-progressbar (0.0.10)
51
+ rubyzip (0.9.9)
52
+ selenium-webdriver (2.25.0)
53
+ childprocess (>= 0.2.5)
54
+ libwebsocket (~> 0.1.3)
55
+ multi_json (~> 1.0)
56
+ rubyzip
57
+ xpath (0.1.4)
58
+ nokogiri (~> 1.3)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ builder
65
+ capybara
66
+ fuubar
67
+ gemcutter
68
+ jeweler
69
+ rake
70
+ rdiscount
71
+ rspec
data/Glinda.gemspec ADDED
@@ -0,0 +1,91 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "glinda"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["rschmukler"]
12
+ s.date = "2012-09-05"
13
+ s.description = "Toto, expanded"
14
+ s.email = "ryan@slingingcode.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "Glinda.gemspec",
25
+ "LICENSE",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/ext/ext.rb",
30
+ "lib/glinda.rb",
31
+ "spec/articles/1900-05-17-the-wonderful-wizard-of-oz.txt",
32
+ "spec/articles/2001-01-01-two-thousand-and-one.txt",
33
+ "spec/articles/2009-04-01-tilt-factor.txt",
34
+ "spec/articles/2009-12-04-some-random-article.txt",
35
+ "spec/articles/2009-12-11-the-dichotomy-of-design.txt",
36
+ "spec/glinda_spec.rb",
37
+ "spec/spec_helper.rb",
38
+ "spec/templates/about.rhtml",
39
+ "spec/templates/archives.rhtml",
40
+ "spec/templates/article.rhtml",
41
+ "spec/templates/feed.builder",
42
+ "spec/templates/index.builder",
43
+ "spec/templates/index.rhtml",
44
+ "spec/templates/layout.rhtml",
45
+ "spec/templates/repo.rhtml"
46
+ ]
47
+ s.homepage = "http://github.com/rschmukler/glinda"
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = "1.8.24"
50
+ s.summary = "Toto, expanded"
51
+
52
+ if s.respond_to? :specification_version then
53
+ s.specification_version = 3
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ s.add_runtime_dependency(%q<rdiscount>, [">= 0"])
57
+ s.add_runtime_dependency(%q<builder>, [">= 0"])
58
+ s.add_development_dependency(%q<fuubar>, [">= 0"])
59
+ s.add_development_dependency(%q<rake>, [">= 0"])
60
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
61
+ s.add_development_dependency(%q<gemcutter>, [">= 0"])
62
+ s.add_development_dependency(%q<rspec>, [">= 0"])
63
+ s.add_runtime_dependency(%q<builder>, [">= 0"])
64
+ s.add_runtime_dependency(%q<rack>, [">= 0"])
65
+ s.add_runtime_dependency(%q<rdiscount>, [">= 0"])
66
+ else
67
+ s.add_dependency(%q<rdiscount>, [">= 0"])
68
+ s.add_dependency(%q<builder>, [">= 0"])
69
+ s.add_dependency(%q<fuubar>, [">= 0"])
70
+ s.add_dependency(%q<rake>, [">= 0"])
71
+ s.add_dependency(%q<jeweler>, [">= 0"])
72
+ s.add_dependency(%q<gemcutter>, [">= 0"])
73
+ s.add_dependency(%q<rspec>, [">= 0"])
74
+ s.add_dependency(%q<builder>, [">= 0"])
75
+ s.add_dependency(%q<rack>, [">= 0"])
76
+ s.add_dependency(%q<rdiscount>, [">= 0"])
77
+ end
78
+ else
79
+ s.add_dependency(%q<rdiscount>, [">= 0"])
80
+ s.add_dependency(%q<builder>, [">= 0"])
81
+ s.add_dependency(%q<fuubar>, [">= 0"])
82
+ s.add_dependency(%q<rake>, [">= 0"])
83
+ s.add_dependency(%q<jeweler>, [">= 0"])
84
+ s.add_dependency(%q<gemcutter>, [">= 0"])
85
+ s.add_dependency(%q<rspec>, [">= 0"])
86
+ s.add_dependency(%q<builder>, [">= 0"])
87
+ s.add_dependency(%q<rack>, [">= 0"])
88
+ s.add_dependency(%q<rdiscount>, [">= 0"])
89
+ end
90
+ end
91
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Ryan Schmukler
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,166 @@
1
+ Glinda
2
+ ====
3
+
4
+ Everyones favorite good witch
5
+
6
+ introduction
7
+ ------------
8
+
9
+ Glinda is built to extend the functionality of [Toto](https://github.com/cloudhead/toto) to offer a more
10
+ complete feature set, while staying true to the original:
11
+
12
+ - git powered
13
+ - minimalistic
14
+ - easily customized
15
+
16
+ blog in 10 seconds
17
+ ------------------
18
+
19
+ $ git clone git://github.com/rschmukler/dorothy-with-glinda.git myblog
20
+ $ cd myblog
21
+ $ heroku create myblog
22
+ $ git push heroku master
23
+
24
+ philosophy
25
+ ----------
26
+
27
+ Glinda follows the same philosophy as Toto
28
+
29
+ Everything that can be done better with another tool should be, but one should not have too much pie to stay fit.
30
+ In other words, toto does away with web frameworks or DSLs such as sinatra, and is built right on top of **rack**.
31
+ There is no database or ORM either, we use plain text files.
32
+
33
+ Toto was designed to be used with a reverse-proxy cache, such as [Varnish](http://varnish-cache.org).
34
+ This makes it an ideal candidate for [heroku](http://heroku.com).
35
+
36
+ Oh, and everything that can be done with git, _is_.
37
+
38
+ how it works
39
+ ------------
40
+
41
+ - content is entirely managed through **git**; you get full fledged version control for free.
42
+ - articles are stored as _.txt_ files, with embeded metadata (in yaml format).
43
+ - articles are processed through a markdown converter (rdiscount) by default.
44
+ - templating is done through **ERB**.
45
+ - toto is built right on top of **Rack**.
46
+ - toto was built to take advantage of _HTTP caching_.
47
+ - toto was built with heroku in mind.
48
+ - comments are handled by [disqus](http://disqus.com)
49
+ - individual articles can be accessed through urls such as _/2009/11/21/blogging-with-toto_
50
+ - the archives can be accessed by year, month or day, wih the same format as above.
51
+ - arbitrary metadata can be included in articles files, and accessed from the templates.
52
+ - summaries are generated intelligently by toto, following the `:max` setting you give it.
53
+ - you can also define how long your summary is, by adding `~` at the end of it (`:delim`).
54
+
55
+ dorothy-with-glinda
56
+ -------------------
57
+
58
+ Dorothy-with-glinda is glinda's default template, you can get it at <http://github.com/rschmukler/dorothy-with-glinda>. It
59
+ comes with a very minimalistic but functional template, and a _config.ru_ file to get you started.
60
+ It also includes a Gemfile file, for heroku and bundler.
61
+
62
+ synopsis
63
+ --------
64
+
65
+ One would start by installing _glinda_, with `sudo gem install glinda`, and then forking or
66
+ cloning the `dorothy-with-glinda` repo, to get a basic skeleton:
67
+
68
+ $ git clone git://github.com/rschmukler/dorothy-with-glinda.git weblog
69
+ $ cd weblog/
70
+
71
+ One would then edit the template at will, it has the following structure:
72
+
73
+ templates/
74
+ |
75
+ +- layout.rhtml # the main site layout, shared by all pages
76
+ |
77
+ +- index.builder # the builder template for the atom feed
78
+ |
79
+ +- pages/ # pages, such as home, about, etc go here
80
+ |
81
+ +- index.rhtml # the default page loaded from `/`, it displays the list of articles
82
+ |
83
+ +- article.rhtml # the article (post) partial and page
84
+ |
85
+ +- about.rhtml
86
+
87
+ One could then create a .txt article file in the `articles/` folder, and make sure it has the following format:
88
+
89
+ title: The Wonderful Wizard of Oz
90
+ author: Lyman Frank Baum
91
+ date: 1900/05/17
92
+
93
+ Dorothy lived in the midst of the great Kansas prairies, with Uncle Henry,
94
+ who was a farmer, and Aunt Em, who was the farmer's wife.
95
+
96
+ If one is familiar with webby or aerial, this shouldn't look funny. Basically the top of the file is in YAML format,
97
+ and the rest of it is the blog post. They are delimited by an empty line `/\n\n/`, as you can see above.
98
+ None of the information is compulsory, but it's strongly encouraged you specify it.
99
+ Note that one can also use `rake` to create an article stub, with `rake new`.
100
+
101
+ Once he finishes writing his beautiful tale, one can push to the git repo, as usual:
102
+
103
+ $ git add articles/wizard-of-oz.txt
104
+ $ git commit -m 'wrote the wizard of oz.'
105
+ $ git push remote master
106
+
107
+ Where `remote` is the name of your remote git repository. The article is now published.
108
+
109
+ ### deployment
110
+
111
+ Toto is built on top of **Rack**, and hence has a **rackup** file: _config.ru_.
112
+
113
+ #### on your own server
114
+
115
+ Once you have created the remote git repo, and pushed your changes to it, you can run toto with any Rack compliant web server,
116
+ such as **thin**, **mongrel** or **unicorn**.
117
+
118
+ With thin, you would do something like:
119
+
120
+ $ thin start -R config.ru
121
+
122
+ With unicorn, you can just do:
123
+
124
+ $ unicorn
125
+
126
+ #### on heroku
127
+
128
+ Toto, and subsequently Glinda, was designed to work well with [heroku](http://heroku.com), it makes the most out of it's state-of-the-art caching,
129
+ by setting the _Cache-Control_ and _Etag_ HTTP headers. Deploying on Heroku is really easy, just get the heroku gem,
130
+ create a heroku app with `heroku create`, and push with `git push heroku master`.
131
+
132
+ $ heroku create weblog
133
+ $ git push heroku master
134
+ $ heroku open
135
+
136
+ ### configuration
137
+
138
+ You can configure toto, by modifying the _config.ru_ file. For example, if you want to set the blog author to 'John Galt',
139
+ you could add `set :author, 'John Galt'` inside the `Toto::Server.new` block. Here are the defaults, to get you started:
140
+
141
+ set :author, ENV['USER'] # blog author
142
+ set :title, Dir.pwd.split('/').last # site title
143
+ set :url, 'http://example.com' # site root URL
144
+ set :prefix, '' # common path prefix for all pages
145
+ set :root, "index" # page to load on /
146
+ set :date, lambda {|now| now.strftime("%d/%m/%Y") } # date format for articles
147
+ set :markdown, :smart # use markdown + smart-mode
148
+ set :disqus, false # disqus id, or false
149
+ set :summary, :max => 150, :delim => /~\n/ # length of article summary and delimiter
150
+ set :ext, 'txt' # file extension for articles
151
+ set :cache, 28800 # cache site for 8 hours
152
+
153
+ set :to_html do |path, page, ctx| # returns an html, from a path & context
154
+ ERB.new(File.read("#{path}/#{page}.rhtml")).result(ctx)
155
+ end
156
+
157
+ set :error do |code| # The HTML for your error page
158
+ "<font style='font-size:300%'>toto, we're not in Kansas anymore (#{code})</font>"
159
+ end
160
+
161
+ thanks
162
+ ------
163
+
164
+ To cloudhead for the awesome Toto platform
165
+
166
+ Copyright (c) 2012
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 = "glinda"
8
+ gem.summary = %Q{Toto, expanded}
9
+ gem.description = %Q{Toto, expanded}
10
+ gem.email = "ryan@slingingcode.com"
11
+ gem.homepage = "http://github.com/rschmukler/glinda"
12
+ gem.authors = ["rschmukler"]
13
+ gem.add_development_dependency "rspec"
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 'rspec/core/rake_task'
28
+
29
+ RSpec::Core::RakeTask.new(:spec)
30
+
31
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/lib/ext/ext.rb ADDED
@@ -0,0 +1,52 @@
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
+
18
+ if RUBY_VERSION < "1.9"
19
+ def bytesize
20
+ size
21
+ end
22
+ end
23
+ end
24
+
25
+ class Fixnum
26
+ def ordinal
27
+ # 1 => 1st
28
+ # 2 => 2nd
29
+ # 3 => 3rd
30
+ # ...
31
+ case self % 100
32
+ when 11..13; "#{self}th"
33
+ else
34
+ case self % 10
35
+ when 1; "#{self}st"
36
+ when 2; "#{self}nd"
37
+ when 3; "#{self}rd"
38
+ else "#{self}th"
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ class Date
45
+ # This check is for people running Toto with ActiveSupport, avoid a collision
46
+ unless respond_to? :iso8601
47
+ # Return the date as a String formatted according to ISO 8601.
48
+ def iso8601
49
+ ::Time.utc(year, month, day, 0, 0, 0, 0).iso8601
50
+ end
51
+ end
52
+ end