bonsai 1.1.1 → 1.1.2
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 +12 -0
- data/README.md +12 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bonsai.gemspec +15 -10
- data/lib/bonsai/exporter.rb +10 -10
- data/lib/bonsai/page.rb +18 -4
- data/lib/bonsai/webserver.rb +7 -2
- data/spec/bonsai/exporter_spec.rb +25 -14
- data/spec/support/public/stylesheets/{broken.less → brokenless.less} +0 -0
- data/spec/support/public/stylesheets/brokensass.sass +3 -0
- data/spec/support/public/stylesheets/lesscss.css +1 -0
- data/spec/support/public/stylesheets/{base.less → lesscss.less} +0 -0
- data/spec/support/public/stylesheets/sassy.css +2 -0
- data/spec/support/public/stylesheets/sassy.sass +5 -0
- metadata +12 -7
data/CHANGES
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
= 1.1.2 (19/01/2010)
|
2
|
+
|
3
|
+
* Added Sass support
|
4
|
+
- You can use LessCSS or Sass
|
5
|
+
- Sass needs to be installed to work
|
6
|
+
- Thanks to Ryan Tomayko for writing Tilt and accepting my LessCSS addition
|
7
|
+
|
8
|
+
* Removed RDiscount in favour of Maruku.
|
9
|
+
- Still uses RDiscount if you have it
|
10
|
+
- Maruku is pure Ruby, no native extensions required
|
11
|
+
|
12
|
+
* Added support for JRuby and Macruby
|
data/README.md
CHANGED
@@ -30,6 +30,15 @@ The generator will provide you with a .htaccess file that will turn on gzip/defl
|
|
30
30
|
* Run `bonsai --repot`
|
31
31
|
* Upload the contents of `site-root/output` to your producton server
|
32
32
|
* For example: `rsync -ave ssh ./output/ tinytree.info:/var/www/tinytree.info`
|
33
|
+
|
34
|
+
## Ruby implementations
|
35
|
+
|
36
|
+
Bonsai runs under a number of Ruby implementations:
|
37
|
+
|
38
|
+
* 1.8.7 (MRI)
|
39
|
+
* 1.9.1 (MRI)
|
40
|
+
* JRuby
|
41
|
+
* MacRuby
|
33
42
|
|
34
43
|
## Technology used to make your site better
|
35
44
|
|
@@ -48,6 +57,9 @@ When I found something that didn't quite work, was too slow or perhaps not even
|
|
48
57
|
|
49
58
|
* [Anthony Kolber](http://github.com/kolber) for writing, then rewriting [Stacey](http://github.com/kolber/stacey) from scratch. We spent many hours talking about best practice and software UX.
|
50
59
|
* [Lincoln Stoll](http://github.com/lstoll) for reminding me to use the tools that I know best
|
60
|
+
|
61
|
+
## Credits
|
62
|
+
* [Rohit Arondekar][http://github.com/rohit] for figuring out an annoying Ubuntu filesystem issue
|
51
63
|
|
52
64
|
|
53
65
|
## Note on Patches/Pull Requests
|
data/Rakefile
CHANGED
@@ -15,12 +15,12 @@ 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_dependency "tilt", ">= 0.
|
18
|
+
gem.add_dependency "tilt", ">= 0.5"
|
19
19
|
gem.add_dependency "mustache", ">= 0.5.0"
|
20
20
|
gem.add_dependency "builder", ">= 2.1.2"
|
21
21
|
gem.add_dependency "watch", ">= 0.1.0"
|
22
22
|
gem.add_dependency "sinatra", ">= 0.9.4"
|
23
|
-
gem.add_dependency "
|
23
|
+
gem.add_dependency "maruku", ">= 0.6.0"
|
24
24
|
gem.add_dependency "less", ">= 1.2.17"
|
25
25
|
gem.add_dependency "rack", ">= 1.1.0"
|
26
26
|
gem.add_dependency "launchy", ">= 0.3.3"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
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.2"
|
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-16}
|
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}
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
".document",
|
23
23
|
".gitignore",
|
24
24
|
".kick",
|
25
|
+
"CHANGES",
|
25
26
|
"LICENSE",
|
26
27
|
"README.md",
|
27
28
|
"Rakefile",
|
@@ -100,8 +101,12 @@ Gem::Specification.new do |s|
|
|
100
101
|
"spec/support/content/legals/terms-and-conditions/demo-template.yml",
|
101
102
|
"spec/support/public/.htaccess",
|
102
103
|
"spec/support/public/js/script.js",
|
103
|
-
"spec/support/public/stylesheets/
|
104
|
-
"spec/support/public/stylesheets/
|
104
|
+
"spec/support/public/stylesheets/brokenless.less",
|
105
|
+
"spec/support/public/stylesheets/brokensass.sass",
|
106
|
+
"spec/support/public/stylesheets/lesscss.css",
|
107
|
+
"spec/support/public/stylesheets/lesscss.less",
|
108
|
+
"spec/support/public/stylesheets/sassy.css",
|
109
|
+
"spec/support/public/stylesheets/sassy.sass",
|
105
110
|
"spec/support/site.yml",
|
106
111
|
"spec/support/templates/demo-template.mustache",
|
107
112
|
"spec/support/templates/partials/inserted.mustache",
|
@@ -140,24 +145,24 @@ Gem::Specification.new do |s|
|
|
140
145
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
141
146
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
142
147
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
143
|
-
s.add_runtime_dependency(%q<tilt>, [">= 0.
|
148
|
+
s.add_runtime_dependency(%q<tilt>, [">= 0.5"])
|
144
149
|
s.add_runtime_dependency(%q<mustache>, [">= 0.5.0"])
|
145
150
|
s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
|
146
151
|
s.add_runtime_dependency(%q<watch>, [">= 0.1.0"])
|
147
152
|
s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
|
148
|
-
s.add_runtime_dependency(%q<
|
153
|
+
s.add_runtime_dependency(%q<maruku>, [">= 0.6.0"])
|
149
154
|
s.add_runtime_dependency(%q<less>, [">= 1.2.17"])
|
150
155
|
s.add_runtime_dependency(%q<rack>, [">= 1.1.0"])
|
151
156
|
s.add_runtime_dependency(%q<launchy>, [">= 0.3.3"])
|
152
157
|
else
|
153
158
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
154
159
|
s.add_dependency(%q<yard>, [">= 0"])
|
155
|
-
s.add_dependency(%q<tilt>, [">= 0.
|
160
|
+
s.add_dependency(%q<tilt>, [">= 0.5"])
|
156
161
|
s.add_dependency(%q<mustache>, [">= 0.5.0"])
|
157
162
|
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
158
163
|
s.add_dependency(%q<watch>, [">= 0.1.0"])
|
159
164
|
s.add_dependency(%q<sinatra>, [">= 0.9.4"])
|
160
|
-
s.add_dependency(%q<
|
165
|
+
s.add_dependency(%q<maruku>, [">= 0.6.0"])
|
161
166
|
s.add_dependency(%q<less>, [">= 1.2.17"])
|
162
167
|
s.add_dependency(%q<rack>, [">= 1.1.0"])
|
163
168
|
s.add_dependency(%q<launchy>, [">= 0.3.3"])
|
@@ -165,12 +170,12 @@ Gem::Specification.new do |s|
|
|
165
170
|
else
|
166
171
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
167
172
|
s.add_dependency(%q<yard>, [">= 0"])
|
168
|
-
s.add_dependency(%q<tilt>, [">= 0.
|
173
|
+
s.add_dependency(%q<tilt>, [">= 0.5"])
|
169
174
|
s.add_dependency(%q<mustache>, [">= 0.5.0"])
|
170
175
|
s.add_dependency(%q<builder>, [">= 2.1.2"])
|
171
176
|
s.add_dependency(%q<watch>, [">= 0.1.0"])
|
172
177
|
s.add_dependency(%q<sinatra>, [">= 0.9.4"])
|
173
|
-
s.add_dependency(%q<
|
178
|
+
s.add_dependency(%q<maruku>, [">= 0.6.0"])
|
174
179
|
s.add_dependency(%q<less>, [">= 1.2.17"])
|
175
180
|
s.add_dependency(%q<rack>, [">= 1.1.0"])
|
176
181
|
s.add_dependency(%q<launchy>, [">= 0.3.3"])
|
data/lib/bonsai/exporter.rb
CHANGED
@@ -39,7 +39,7 @@ module Bonsai
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def cleanup
|
42
|
-
|
42
|
+
remove_less_sass
|
43
43
|
end
|
44
44
|
|
45
45
|
def write_index
|
@@ -88,11 +88,11 @@ module Bonsai
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def copy_public
|
91
|
-
|
91
|
+
generate_css
|
92
92
|
|
93
93
|
Bonsai.log "Copying public files"
|
94
94
|
# Using system call because fileutils is inadequate
|
95
|
-
system("cp -fR '#{Bonsai.root_dir}/public
|
95
|
+
system("cp -fR '#{Bonsai.root_dir}/public/.' '#{path}/.'")
|
96
96
|
end
|
97
97
|
|
98
98
|
def compress_assets
|
@@ -104,19 +104,19 @@ module Bonsai
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
108
|
-
Dir["#{Bonsai.root_dir}/public/**/*.less"].each do |
|
109
|
-
css =
|
110
|
-
path = "#{File.dirname(
|
107
|
+
def generate_css
|
108
|
+
Dir["#{Bonsai.root_dir}/public/**/*.{less,sass}"].each do |cssfile|
|
109
|
+
css = Tilt.new(cssfile).render
|
110
|
+
path = "#{File.dirname(cssfile)}/#{File.basename(cssfile, ".*")}.css"
|
111
111
|
|
112
112
|
File.open(path, "w") {|file| file.write(css) }
|
113
113
|
end
|
114
114
|
rescue Less::SyntaxError => exception
|
115
|
-
Bonsai.log "
|
115
|
+
Bonsai.log "CSS Syntax error\n\n#{exception.message}"
|
116
116
|
end
|
117
117
|
|
118
|
-
def
|
119
|
-
Dir["#{path}/**/*.less"].each{|f| FileUtils.rm(f) }
|
118
|
+
def remove_less_sass
|
119
|
+
Dir["#{path}/**/*.{less,sass}"].each{|f| FileUtils.rm(f) }
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
data/lib/bonsai/page.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'rdiscount'
|
3
2
|
require 'tilt'
|
4
3
|
|
4
|
+
# Use RDiscount for those who care
|
5
|
+
begin
|
6
|
+
require 'rdiscount'
|
7
|
+
BlueCloth = RDiscount
|
8
|
+
rescue LoadError
|
9
|
+
require 'maruku'
|
10
|
+
end
|
11
|
+
|
5
12
|
module Bonsai
|
6
13
|
class Page
|
7
14
|
class NotFound < StandardError; end;
|
@@ -143,17 +150,24 @@ module Bonsai
|
|
143
150
|
|
144
151
|
private
|
145
152
|
def formatted_content
|
146
|
-
formatted_content = content
|
147
|
-
|
153
|
+
formatted_content = content
|
148
154
|
formatted_content.each do |k,v|
|
149
155
|
if v.is_a?(String) and v =~ /\n/
|
150
|
-
formatted_content[k] =
|
156
|
+
formatted_content[k] = to_markdown(v)
|
151
157
|
end
|
152
158
|
end
|
153
159
|
|
154
160
|
formatted_content
|
155
161
|
end
|
156
162
|
|
163
|
+
def to_markdown(content)
|
164
|
+
if defined? RDiscount
|
165
|
+
RDiscount.new(content, :smart).to_html
|
166
|
+
else
|
167
|
+
Maruku.new(content).to_html
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
157
171
|
# Creates methods for each sub-folder within the page's folder
|
158
172
|
# that isn't a sub-page (a page object)
|
159
173
|
def disk_assets
|
data/lib/bonsai/webserver.rb
CHANGED
@@ -11,13 +11,18 @@ module Bonsai
|
|
11
11
|
set :views, "#{File.dirname(__FILE__)}/webserver"
|
12
12
|
|
13
13
|
get '/' do
|
14
|
-
|
14
|
+
begin
|
15
|
+
Page.find("index").render
|
16
|
+
rescue
|
17
|
+
@error = e.message
|
18
|
+
erb :error
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
get '/*' do
|
18
23
|
begin
|
19
24
|
Page.find(params[:splat].to_s).render
|
20
|
-
rescue
|
25
|
+
rescue
|
21
26
|
@error = e.message
|
22
27
|
erb :error
|
23
28
|
end
|
@@ -15,14 +15,18 @@ describe Bonsai::Exporter do
|
|
15
15
|
Bonsai::Exporter.path = BONSAI_PATH + "/output"
|
16
16
|
end
|
17
17
|
|
18
|
-
shared_examples_for "
|
18
|
+
shared_examples_for "css generators" do
|
19
19
|
it "should process .less files to .css" do
|
20
|
-
File.exists?("#{Bonsai::Exporter.path}/stylesheets/
|
20
|
+
File.exists?("#{Bonsai::Exporter.path}/stylesheets/lesscss.css").should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should process .sass files to .css" do
|
24
|
+
File.exists?("#{Bonsai::Exporter.path}/stylesheets/sassy.css").should be_true
|
21
25
|
end
|
22
26
|
|
23
27
|
it "should log an error when badly formatted less is supplied (and not raise an exception)" do
|
24
28
|
Bonsai.should_receive(:log)
|
25
|
-
lambda { Bonsai::Exporter.send(:
|
29
|
+
lambda { Bonsai::Exporter.send(:generate_css) }.should_not raise_error(Less::SyntaxError)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
@@ -33,17 +37,16 @@ describe Bonsai::Exporter do
|
|
33
37
|
Bonsai::Exporter.process!
|
34
38
|
end
|
35
39
|
|
36
|
-
it_should_behave_like "
|
40
|
+
it_should_behave_like "css generators"
|
37
41
|
|
38
42
|
# Uncompressed CSS
|
39
43
|
it "should be processed with less" do
|
40
|
-
File.read("#{Bonsai::Exporter.path}/stylesheets/
|
44
|
+
File.read("#{Bonsai::Exporter.path}/stylesheets/lesscss.css").should == ".mymixin, #content { display: block; }\n"
|
41
45
|
end
|
42
46
|
|
43
|
-
it "should
|
44
|
-
File.
|
47
|
+
it "should be processed with sass" do
|
48
|
+
File.read("#{Bonsai::Exporter.path}/stylesheets/sassy.css").should == "#content {\n display: block; }\n"
|
45
49
|
end
|
46
|
-
|
47
50
|
end
|
48
51
|
|
49
52
|
describe "expectations" do
|
@@ -60,7 +63,7 @@ describe Bonsai::Exporter do
|
|
60
63
|
end
|
61
64
|
|
62
65
|
it "should generate css via lesscss" do
|
63
|
-
Bonsai::Exporter.should_receive(:
|
66
|
+
Bonsai::Exporter.should_receive(:generate_css)
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
@@ -72,11 +75,15 @@ describe Bonsai::Exporter do
|
|
72
75
|
Bonsai::Exporter.publish!
|
73
76
|
end
|
74
77
|
|
75
|
-
it_should_behave_like "
|
78
|
+
it_should_behave_like "css generators"
|
76
79
|
|
77
80
|
# Compressed CSS
|
78
81
|
it "should be processed with less" do
|
79
|
-
File.read("#{Bonsai::Exporter.path}/stylesheets/
|
82
|
+
File.read("#{Bonsai::Exporter.path}/stylesheets/lesscss.css").should == ".mymixin,#content{display:block;}"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should be processed with sass" do
|
86
|
+
File.read("#{Bonsai::Exporter.path}/stylesheets/sassy.css").should == "#content{display:block;}"
|
80
87
|
end
|
81
88
|
|
82
89
|
it "should not export the base.less file" do
|
@@ -118,7 +125,11 @@ describe Bonsai::Exporter do
|
|
118
125
|
|
119
126
|
describe "asset compression" do
|
120
127
|
it "should compress the css file" do
|
121
|
-
File.read("#{Bonsai::Exporter.path}/stylesheets/
|
128
|
+
File.read("#{Bonsai::Exporter.path}/stylesheets/lesscss.css").should == ".mymixin,#content{display:block;}"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should compress the css file" do
|
132
|
+
File.read("#{Bonsai::Exporter.path}/stylesheets/sassy.css").should == "#content{display:block;}"
|
122
133
|
end
|
123
134
|
|
124
135
|
it "should compress the js file" do
|
@@ -136,8 +147,8 @@ describe Bonsai::Exporter do
|
|
136
147
|
FileUtils.should_receive(:rm_rf).with(Bonsai::Exporter.path)
|
137
148
|
end
|
138
149
|
|
139
|
-
it "should
|
140
|
-
Bonsai::Exporter.should_receive(:
|
150
|
+
it "should process css with less or sass" do
|
151
|
+
Bonsai::Exporter.should_receive(:generate_css)
|
141
152
|
end
|
142
153
|
|
143
154
|
it "should compress assets" do
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
.mymixin, #content { display: block; }
|
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.2
|
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-16 00:00:00 +11:00
|
13
13
|
default_executable: bonsai
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: "0.
|
43
|
+
version: "0.5"
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: mustache
|
@@ -83,14 +83,14 @@ dependencies:
|
|
83
83
|
version: 0.9.4
|
84
84
|
version:
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
86
|
+
name: maruku
|
87
87
|
type: :runtime
|
88
88
|
version_requirement:
|
89
89
|
version_requirements: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: 0.6.0
|
94
94
|
version:
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: less
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- .document
|
136
136
|
- .gitignore
|
137
137
|
- .kick
|
138
|
+
- CHANGES
|
138
139
|
- LICENSE
|
139
140
|
- README.md
|
140
141
|
- Rakefile
|
@@ -213,8 +214,12 @@ files:
|
|
213
214
|
- spec/support/content/legals/terms-and-conditions/demo-template.yml
|
214
215
|
- spec/support/public/.htaccess
|
215
216
|
- spec/support/public/js/script.js
|
216
|
-
- spec/support/public/stylesheets/
|
217
|
-
- spec/support/public/stylesheets/
|
217
|
+
- spec/support/public/stylesheets/brokenless.less
|
218
|
+
- spec/support/public/stylesheets/brokensass.sass
|
219
|
+
- spec/support/public/stylesheets/lesscss.css
|
220
|
+
- spec/support/public/stylesheets/lesscss.less
|
221
|
+
- spec/support/public/stylesheets/sassy.css
|
222
|
+
- spec/support/public/stylesheets/sassy.sass
|
218
223
|
- spec/support/site.yml
|
219
224
|
- spec/support/templates/demo-template.mustache
|
220
225
|
- spec/support/templates/partials/inserted.mustache
|