bonsai 1.1.2 → 1.1.3
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/CHANGES +17 -0
- data/README.md +4 -2
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/bonsai +3 -3
- data/bonsai.gemspec +6 -2
- data/lib/bonsai/navigation.rb +1 -1
- data/lib/bonsai/page.rb +10 -12
- data/lib/bonsai/webserver/error.erb +10 -1
- data/lib/bonsai/webserver.rb +8 -8
- data/spec/bonsai/page_spec.rb +4 -4
- data/spec/support/broken/public/empty.txt +0 -0
- metadata +13 -2
data/CHANGES
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
= 1.1.3 (23/01/2010)
|
2
|
+
|
3
|
+
* Fixes for UTF-8 url strings under Ruby 1.9
|
4
|
+
- Thanks Ralph (Added to Credits in README.md)
|
5
|
+
|
6
|
+
* Added shortcuts to --plant, --cultivate and --repot
|
7
|
+
- -p for --plant
|
8
|
+
- -c for --cultivate
|
9
|
+
- -r for --repot
|
10
|
+
- Thanks somedumbme91 (Added to Credits in README.md)
|
11
|
+
|
12
|
+
* Permalinks now have a trailing slash to reduce server redirects
|
13
|
+
- Thanks dgoodlad (Added to Credits in README.md)
|
14
|
+
|
15
|
+
* Added an error page for badly formatted YML files or other issues
|
16
|
+
- Rendered during --cultivate sessions for debugging
|
17
|
+
|
1
18
|
= 1.1.2 (19/01/2010)
|
2
19
|
|
3
20
|
* Added Sass support
|
data/README.md
CHANGED
@@ -59,8 +59,10 @@ When I found something that didn't quite work, was too slow or perhaps not even
|
|
59
59
|
* [Lincoln Stoll](http://github.com/lstoll) for reminding me to use the tools that I know best
|
60
60
|
|
61
61
|
## Credits
|
62
|
-
* [Rohit Arondekar]
|
63
|
-
|
62
|
+
* [Rohit Arondekar](http://github.com/rohit)
|
63
|
+
* [Justin Ridgewell](git://github.com/somedumbme91)
|
64
|
+
* [Ralph von der Heyden](http://github.com/ralph)
|
65
|
+
* [David Goodlad](http://github.com/dgoodlad)
|
64
66
|
|
65
67
|
## Note on Patches/Pull Requests
|
66
68
|
|
data/Rakefile
CHANGED
@@ -15,6 +15,7 @@ begin
|
|
15
15
|
gem.executables = ['bonsai']
|
16
16
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
17
17
|
gem.add_development_dependency "yard", ">= 0"
|
18
|
+
gem.add_development_dependency "rdiscount"
|
18
19
|
gem.add_dependency "tilt", ">= 0.5"
|
19
20
|
gem.add_dependency "mustache", ">= 0.5.0"
|
20
21
|
gem.add_dependency "builder", ">= 2.1.2"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
data/bin/bonsai
CHANGED
@@ -14,7 +14,7 @@ banner = %q{
|
|
14
14
|
opts = OptionParser.new do |opts|
|
15
15
|
opts.banner = banner
|
16
16
|
|
17
|
-
opts.on("--plant [NAME]", "creates the directory structure for your site") do |name|
|
17
|
+
opts.on("-p", "--plant [NAME]", "creates the directory structure for your site") do |name|
|
18
18
|
if name.nil?
|
19
19
|
Bonsai.log "no site name given check `bonsai --help` for details"
|
20
20
|
exit 0
|
@@ -22,7 +22,7 @@ opts = OptionParser.new do |opts|
|
|
22
22
|
Bonsai::Generate.new("#{Dir.pwd}/#{name}")
|
23
23
|
end
|
24
24
|
|
25
|
-
opts.on("--cultivate", "run a local web server and process your files on save") do
|
25
|
+
opts.on("-c", "--cultivate", "run a local web server and process your files on save") do
|
26
26
|
begin
|
27
27
|
Bonsai.log banner
|
28
28
|
Bonsai.log "Press Control+C to quit"
|
@@ -51,7 +51,7 @@ opts = OptionParser.new do |opts|
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
opts.on("--repot", "export your site to #{Dir.pwd}/output") do
|
54
|
+
opts.on("-r", "--repot", "export your site to #{Dir.pwd}/output") do
|
55
55
|
Bonsai.root_dir = Dir.pwd
|
56
56
|
Bonsai::Exporter.publish!
|
57
57
|
end
|
data/bonsai.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bonsai}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ben Schwarz"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-23}
|
13
13
|
s.default_executable = %q{bonsai}
|
14
14
|
s.description = %q{A static site generator that uses the best toolset available}
|
15
15
|
s.email = %q{ben.schwarz@gmail.com}
|
@@ -72,6 +72,7 @@ Gem::Specification.new do |s|
|
|
72
72
|
"spec/spec.opts",
|
73
73
|
"spec/spec_helper.rb",
|
74
74
|
"spec/support/broken/content/broken_page/demo-template.yml",
|
75
|
+
"spec/support/broken/public/empty.txt",
|
75
76
|
"spec/support/broken/site.yml",
|
76
77
|
"spec/support/broken/templates/content/index/default.yml",
|
77
78
|
"spec/support/broken/templates/public/.htaccess",
|
@@ -145,6 +146,7 @@ Gem::Specification.new do |s|
|
|
145
146
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
146
147
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
147
148
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
149
|
+
s.add_development_dependency(%q<rdiscount>, [">= 0"])
|
148
150
|
s.add_runtime_dependency(%q<tilt>, [">= 0.5"])
|
149
151
|
s.add_runtime_dependency(%q<mustache>, [">= 0.5.0"])
|
150
152
|
s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
|
@@ -157,6 +159,7 @@ Gem::Specification.new do |s|
|
|
157
159
|
else
|
158
160
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
159
161
|
s.add_dependency(%q<yard>, [">= 0"])
|
162
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
160
163
|
s.add_dependency(%q<tilt>, [">= 0.5"])
|
161
164
|
s.add_dependency(%q<mustache>, [">= 0.5.0"])
|
162
165
|
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
@@ -170,6 +173,7 @@ Gem::Specification.new do |s|
|
|
170
173
|
else
|
171
174
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
172
175
|
s.add_dependency(%q<yard>, [">= 0"])
|
176
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
173
177
|
s.add_dependency(%q<tilt>, [">= 0.5"])
|
174
178
|
s.add_dependency(%q<mustache>, [">= 0.5.0"])
|
175
179
|
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
data/lib/bonsai/navigation.rb
CHANGED
data/lib/bonsai/page.rb
CHANGED
@@ -22,13 +22,13 @@ module Bonsai
|
|
22
22
|
Dir["#{dir_path}/#{pattern}/*.yml"].map {|p| Page.new p }
|
23
23
|
end
|
24
24
|
|
25
|
-
def find(permalink)
|
25
|
+
def find(permalink)
|
26
26
|
@@pages[permalink] ||= find!(permalink)
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
30
|
def find!(permalink)
|
31
|
-
search_path = permalink.gsub(/\//, "/*")
|
31
|
+
search_path = permalink.gsub(/\/$/, '').gsub(/\//, "/*")
|
32
32
|
disk_path = Dir["#{path}/*#{search_path}/*.yml"]
|
33
33
|
if disk_path.any?
|
34
34
|
return new disk_path.first
|
@@ -45,7 +45,7 @@ module Bonsai
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def slug
|
48
|
-
permalink.split('/').pop
|
48
|
+
permalink.gsub(/\/$/, '').split('/').pop
|
49
49
|
end
|
50
50
|
|
51
51
|
def name
|
@@ -53,14 +53,14 @@ module Bonsai
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def permalink
|
56
|
-
web_path(directory)
|
56
|
+
web_path(directory) + '/'
|
57
57
|
end
|
58
58
|
|
59
59
|
def ctime; File.ctime(disk_path); end
|
60
60
|
def mtime; File.mtime(disk_path); end
|
61
61
|
|
62
62
|
def write_path
|
63
|
-
"#{permalink}
|
63
|
+
"#{permalink}index.html"
|
64
64
|
end
|
65
65
|
|
66
66
|
def template
|
@@ -81,9 +81,9 @@ module Bonsai
|
|
81
81
|
def floating?
|
82
82
|
!!(File.dirname(disk_path) =~ /\/[a-zA-z][\w-]+$/)
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
def parent
|
86
|
-
id = permalink[
|
86
|
+
id = permalink[/\/(.+\/)[^\/]*\/$/, 1]
|
87
87
|
return nil if id.nil?
|
88
88
|
|
89
89
|
parent = Page.find(id)
|
@@ -109,7 +109,7 @@ module Bonsai
|
|
109
109
|
|
110
110
|
# Find pages up the permalink tree if possible
|
111
111
|
while(page_ref) do
|
112
|
-
page_ref = page_ref[/(
|
112
|
+
page_ref = page_ref[/(.+\/)[^\/]*\/$/, 1]
|
113
113
|
ancestors << self.class.find(page_ref) rescue NotFound
|
114
114
|
end
|
115
115
|
|
@@ -122,14 +122,12 @@ module Bonsai
|
|
122
122
|
|
123
123
|
def render
|
124
124
|
Tilt.new(template.path, :path => template.class.path).render(self, to_hash)
|
125
|
-
rescue => stack
|
126
|
-
raise "Issue rendering #{permalink}\n\n#{stack}"
|
127
125
|
end
|
128
126
|
|
129
127
|
def content
|
130
128
|
YAML::load(File.read(disk_path)) || {}
|
131
129
|
rescue ArgumentError
|
132
|
-
|
130
|
+
raise "Page '#{permalink}' has badly formatted content"
|
133
131
|
end
|
134
132
|
|
135
133
|
# This hash is available to all templates, it will map common properties,
|
@@ -205,4 +203,4 @@ module Bonsai
|
|
205
203
|
path.gsub(@@path, '').gsub(/\/\d+\./, '/')
|
206
204
|
end
|
207
205
|
end
|
208
|
-
end
|
206
|
+
end
|
@@ -3,8 +3,17 @@
|
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
5
|
<title>Bonsai, an error occurred</title>
|
6
|
+
<style type="text/css" media="screen">
|
7
|
+
body { font-style: Times, "Times New Roman", serif; font-style: italic; text-shadow: white 1px 1px 1px; }
|
8
|
+
h1 { font-size: 1em; text-align: center; font-weight: normal; }
|
9
|
+
#main { width: 580px; margin: 0 auto; display: block; }
|
10
|
+
#circle { width: 145px; height: 145px; -moz-border-radius: 72px; -webkit-border-radius: 72px; border-radius: 72px; background-color: black; margin: 3em auto; }
|
11
|
+
</style>
|
6
12
|
</head>
|
7
13
|
<body id="error">
|
8
|
-
<
|
14
|
+
<section id="main">
|
15
|
+
<div id="circle"></div>
|
16
|
+
<h1><%= @error.to_s %></h1>
|
17
|
+
</section>
|
9
18
|
</body>
|
10
19
|
</html>
|
data/lib/bonsai/webserver.rb
CHANGED
@@ -6,24 +6,24 @@ module Bonsai
|
|
6
6
|
@app.call(env)
|
7
7
|
end
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
class DevelopmentServer < Sinatra::Base
|
11
11
|
set :views, "#{File.dirname(__FILE__)}/webserver"
|
12
|
-
|
12
|
+
|
13
13
|
get '/' do
|
14
14
|
begin
|
15
15
|
Page.find("index").render
|
16
|
-
rescue
|
17
|
-
@error = e
|
16
|
+
rescue Exception => e
|
17
|
+
@error = e
|
18
18
|
erb :error
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
get '/*' do
|
23
23
|
begin
|
24
|
-
Page.find(params[:splat].
|
25
|
-
rescue
|
26
|
-
@error = e
|
24
|
+
Page.find(params[:splat].join).render
|
25
|
+
rescue Exception => e
|
26
|
+
@error = e
|
27
27
|
erb :error
|
28
28
|
end
|
29
29
|
end
|
data/spec/bonsai/page_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe Bonsai::Page do
|
|
13
13
|
|
14
14
|
describe "instance" do
|
15
15
|
before :all do
|
16
|
-
@page = Bonsai::Page.find("about-us/history")
|
16
|
+
@page = Bonsai::Page.find("about-us/history/")
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should have a slug" do
|
@@ -135,8 +135,8 @@ describe Bonsai::Page do
|
|
135
135
|
@output.should_not be_nil
|
136
136
|
end
|
137
137
|
|
138
|
-
it "should replace
|
139
|
-
@output.should == "Hello from our template, named Contact\n\nGet in touch\n\n/about-us/contact/images/image001.jpg\n/about-us/contact/child
|
138
|
+
it "should replace mustache variables with properties from the content file" do
|
139
|
+
@output.should == "Hello from our template, named Contact\n\nGet in touch\n\n/about-us/contact/images/image001.jpg\n/about-us/contact/child/\n/about-us/contact/magic/image001.jpg\n/about-us/contact/magic/image002.jpg\nThis content should be inserted!\n\n<p>“A designer knows he has achieved perfection\nnot when there is nothing left to add,\nbut when there is nothing left to take away.”</p>\n\n<p>– Antoine de Saint-Exupery</p>\n"
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should write in images" do
|
@@ -233,4 +233,4 @@ describe Bonsai::Page do
|
|
233
233
|
end
|
234
234
|
end
|
235
235
|
end
|
236
|
-
end
|
236
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bonsai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Schwarz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-23 00:00:00 +11:00
|
13
13
|
default_executable: bonsai
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +32,16 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rdiscount
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
35
45
|
- !ruby/object:Gem::Dependency
|
36
46
|
name: tilt
|
37
47
|
type: :runtime
|
@@ -185,6 +195,7 @@ files:
|
|
185
195
|
- spec/spec.opts
|
186
196
|
- spec/spec_helper.rb
|
187
197
|
- spec/support/broken/content/broken_page/demo-template.yml
|
198
|
+
- spec/support/broken/public/empty.txt
|
188
199
|
- spec/support/broken/site.yml
|
189
200
|
- spec/support/broken/templates/content/index/default.yml
|
190
201
|
- spec/support/broken/templates/public/.htaccess
|