bonsai 1.3.1 → 1.3.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/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +8 -4
- data/Gemfile.lock +27 -25
- data/Rakefile +15 -35
- data/VERSION +1 -1
- data/benchmark/associations.rb +3 -1
- data/bin/bonsai +3 -1
- data/bonsai.gemspec +178 -153
- data/lib/bonsai/page.rb +9 -10
- data/lib/bonsai/sitemap.rb +2 -2
- data/lib/bonsai/templates/site.yml +1 -1
- data/spec/bonsai/generate_spec.rb +4 -4
- data/spec/bonsai/page_spec.rb +26 -45
- data/spec/bonsai/template_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- data/spec/support/templates/demo-template.mustache +1 -3
- data/vendor/yui-compressor/yuicompressor-2.4.2.jar +0 -0
- metadata +230 -83
- data/.gitignore +0 -36
- data/vendor/cache/activesupport-2.3.5.gem +0 -0
- data/vendor/cache/builder-2.1.2.gem +0 -0
- data/vendor/cache/configuration-1.1.0.gem +0 -0
- data/vendor/cache/gemcutter-0.5.0.gem +0 -0
- data/vendor/cache/git-1.2.5.gem +0 -0
- data/vendor/cache/jeweler-1.4.0.gem +0 -0
- data/vendor/cache/json_pure-1.2.3.gem +0 -0
- data/vendor/cache/maruku-0.6.0.gem +0 -0
- data/vendor/cache/rake-0.8.7.gem +0 -0
- data/vendor/cache/rspec-1.3.0.gem +0 -0
- data/vendor/cache/rubyforge-2.0.4.gem +0 -0
- data/vendor/cache/syntax-1.0.0.gem +0 -0
- data/vendor/cache/watch-0.1.0.gem +0 -0
- data/vendor/cache/yard-0.2.2.gem +0 -0
data/lib/bonsai/page.rb
CHANGED
|
@@ -68,8 +68,8 @@ module Bonsai
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
# This method is used for the exporter to copy assets
|
|
71
|
-
def assets
|
|
72
|
-
Dir["#{
|
|
71
|
+
def assets
|
|
72
|
+
Dir["#{directory}/**/*"].select{|path| !File.directory?(path) && !File.basename(path).include?("yml") }.map do |file|
|
|
73
73
|
file_to_hash(file)
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -96,8 +96,8 @@ module Bonsai
|
|
|
96
96
|
self.class.all(File.dirname(disk_path[/(.+)\/[^\/]*$/, 1]), "*").delete_if{|p| p == self}
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
def children
|
|
100
|
-
self.class.all((
|
|
99
|
+
def children
|
|
100
|
+
self.class.all(File.dirname(disk_path), "*").delete_if{|p| p.floating? }
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def ancestors
|
|
@@ -170,8 +170,8 @@ module Bonsai
|
|
|
170
170
|
# that isn't itself, a child-page (a page object)
|
|
171
171
|
def disk_assets
|
|
172
172
|
assets = {}
|
|
173
|
-
Dir["#{File.dirname(disk_path)}/**"].select{|p|
|
|
174
|
-
|
|
173
|
+
Dir["#{File.dirname(disk_path)}/**"].select{|p| File.directory?(p)}.reject {|p|
|
|
174
|
+
Dir.entries(p).any?{|e| e.include? "yml"}
|
|
175
175
|
}.each{|asset_path| assets.merge!(map_to_disk(asset_path)) }
|
|
176
176
|
|
|
177
177
|
assets
|
|
@@ -181,10 +181,9 @@ module Bonsai
|
|
|
181
181
|
name = File.basename(path)
|
|
182
182
|
|
|
183
183
|
{
|
|
184
|
-
name.to_sym => {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
184
|
+
name.to_sym => Dir["#{path}/*"].map do |file|
|
|
185
|
+
file_to_hash(file)
|
|
186
|
+
end
|
|
188
187
|
}
|
|
189
188
|
end
|
|
190
189
|
|
data/lib/bonsai/sitemap.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Bonsai
|
|
|
13
13
|
xml.changefreq(change_freq)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
Bonsai::Page.all.delete_if{|p| p.permalink === "/index"}.each do |page|
|
|
16
|
+
Bonsai::Page.all.delete_if{|p| p.permalink === "/index/"}.each do |page|
|
|
17
17
|
xml.url {
|
|
18
18
|
xml.loc(Bonsai.site[:url] + page.permalink)
|
|
19
19
|
xml.lastmod(page.mtime.utc.strftime("%Y-%m-%d"))
|
|
@@ -35,4 +35,4 @@ module Bonsai
|
|
|
35
35
|
exit
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
|
-
end
|
|
38
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# The key value pairs found below are available within the templates.
|
|
2
|
-
# {{site_name}}, {{url}}, {{copyright}} and {{analytics_code}}
|
|
2
|
+
# {{site_name}}, {{url}}, {{copyright}} and {{analytics_code}}
|
|
3
3
|
|
|
4
4
|
:site_name: Your website title
|
|
5
5
|
:url: http://yourdomain.com
|
|
@@ -37,12 +37,12 @@ describe Bonsai::Generate do
|
|
|
37
37
|
File.exists?("#{@path}/site.yml").should be_true
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
it "should generate
|
|
41
|
-
Dir.glob("#{@path}/**/*", File::FNM_DOTMATCH).select{|f| File.file?(f) }.size.should ==
|
|
40
|
+
it "should generate 22 files" do
|
|
41
|
+
Dir.glob("#{@path}/**/*", File::FNM_DOTMATCH).select{|f| File.file?(f) }.size.should == 22
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
it "should generate
|
|
45
|
-
Dir.glob("#{@path}/**/*").select{|f| File.directory?(f) }.size.should ==
|
|
44
|
+
it "should generate 14 directories" do
|
|
45
|
+
Dir.glob("#{@path}/**/*").select{|f| File.directory?(f) }.size.should == 14
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
data/spec/bonsai/page_spec.rb
CHANGED
|
@@ -65,53 +65,12 @@ describe Bonsai::Page do
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "should have the correct disk_path" do
|
|
68
|
-
@page.assets.first[:disk_path].should == "
|
|
68
|
+
@page.assets.first[:disk_path].should == File.join(Dir.pwd, "spec/support/content/1.about-us/history/001.jpg")
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "should titleize the name attribute and remove the file extension" do
|
|
72
72
|
@page.assets[2][:name].should == "A File Asset"
|
|
73
73
|
end
|
|
74
|
-
|
|
75
|
-
describe "disk_assets" do
|
|
76
|
-
before :all do
|
|
77
|
-
@page = Bonsai::Page.find("about-us/contact")
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "should have magic" do
|
|
81
|
-
@page.to_hash.should have_key(:magic)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "should have assets" do
|
|
85
|
-
@page.to_hash[:magic][:files].should be_an_instance_of(Array)
|
|
86
|
-
@page.to_hash[:magic][:files].should_not be_empty
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "it should be a an array of hashes" do
|
|
90
|
-
@page.to_hash[:magic][:files].should be_an_instance_of(Array)
|
|
91
|
-
@page.to_hash[:magic][:files].first.should be_an_instance_of(Hash)
|
|
92
|
-
@page.to_hash[:magic][:files].size.should == 2
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "should have children" do
|
|
96
|
-
@page.to_hash[:magic][:children].should_not be_empty
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
describe "children (pages)" do
|
|
100
|
-
it "should represent the children as pages" do
|
|
101
|
-
@page.to_hash[:magic][:children].first.should be_an_instance_of(Bonsai::Page)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "should contain a single child" do
|
|
105
|
-
@page.to_hash[:magic][:children].size.should == 1
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
%w(slug permalink name page_title children siblings parent ancestors navigation updated_at created_at).each do |key|
|
|
109
|
-
it "should have a to_hash key for #{key}" do
|
|
110
|
-
@page.to_hash[:magic][:children].first.to_hash.keys.should include(key.to_sym)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
74
|
end
|
|
116
75
|
|
|
117
76
|
it "should be equal" do
|
|
@@ -196,7 +155,7 @@ describe Bonsai::Page do
|
|
|
196
155
|
end
|
|
197
156
|
|
|
198
157
|
it "should replace mustache variables with properties from the content file" do
|
|
199
|
-
@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/
|
|
158
|
+
@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 not when there is nothing left to add, but when there is nothing left to take away.”</p>\n\n<p>– Antoine de Saint-Exupery</p>"
|
|
200
159
|
end
|
|
201
160
|
|
|
202
161
|
it "should write in images" do
|
|
@@ -216,11 +175,11 @@ describe Bonsai::Page do
|
|
|
216
175
|
end
|
|
217
176
|
|
|
218
177
|
it "should use markdown for multiple line content" do
|
|
219
|
-
@output.should =~ /<p
|
|
178
|
+
@output.should =~ /<p>“A designer knows he/
|
|
220
179
|
end
|
|
221
180
|
|
|
222
181
|
it "should use smartypants" do
|
|
223
|
-
@output.should =~
|
|
182
|
+
@output.should =~ /“/
|
|
224
183
|
end
|
|
225
184
|
end
|
|
226
185
|
end
|
|
@@ -245,6 +204,28 @@ describe Bonsai::Page do
|
|
|
245
204
|
@page.to_hash[:url].should == "http://tinytree.info"
|
|
246
205
|
@page.to_hash[:copyright].should == 2010
|
|
247
206
|
end
|
|
207
|
+
|
|
208
|
+
describe "disk_assets" do
|
|
209
|
+
before :all do
|
|
210
|
+
@vars = @page.to_hash
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
describe "enum" do
|
|
214
|
+
it "should not have a child" do
|
|
215
|
+
@vars.should_not have_key(:child)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "should have magic" do
|
|
219
|
+
@vars.should have_key(:magic)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it "it should be a an array of hashes" do
|
|
223
|
+
@vars[:magic].should be_an_instance_of(Array)
|
|
224
|
+
@vars[:magic].first.should be_an_instance_of(Hash)
|
|
225
|
+
@vars[:magic].size.should == 2
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
end
|
|
248
229
|
end
|
|
249
230
|
|
|
250
231
|
describe "broken page" do
|
|
@@ -13,7 +13,7 @@ describe Bonsai::Template do
|
|
|
13
13
|
describe "instance" do
|
|
14
14
|
it "should give the template source" do
|
|
15
15
|
@template = Bonsai::Template.find("demo-template")
|
|
16
|
-
File.read(@template.path).should == "Hello from our template, named {{name}}\n\n{{page_title}}\n\n{{#images}}\n {{
|
|
16
|
+
File.read(@template.path).should == "Hello from our template, named {{name}}\n\n{{page_title}}\n\n{{#images}}\n {{path}}\n{{/images}}\n\n{{#children}}\n {{permalink}}\n{{/children}}\n\n{{#magic}}\n {{path}}\n{{/magic}}\n\n{{>partials/inserted}}\n\n{{{body}}}"
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
3
|
require 'bonsai'
|
|
4
|
-
require '
|
|
5
|
-
require '
|
|
4
|
+
require 'rspec'
|
|
5
|
+
require 'rspec/autorun'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
RSpec.configure do |config|
|
|
8
8
|
Bonsai.config = { :enable_logging => false }
|
|
9
9
|
|
|
10
10
|
BONSAI_PATH = "#{File.dirname(__FILE__)}/support" unless defined? BONSAI_PATH
|
|
Binary file
|