bonsai 1.0.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.
Files changed (61) hide show
  1. data/.document +5 -0
  2. data/.gitignore +23 -0
  3. data/.kick +26 -0
  4. data/LICENSE +20 -0
  5. data/README.md +65 -0
  6. data/Rakefile +64 -0
  7. data/VERSION +1 -0
  8. data/benchmark/associations.rb +51 -0
  9. data/bin/bonsai +69 -0
  10. data/bonsai.gemspec +142 -0
  11. data/lib/bonsai.rb +60 -0
  12. data/lib/bonsai/console.rb +8 -0
  13. data/lib/bonsai/exporter.rb +103 -0
  14. data/lib/bonsai/generate.rb +24 -0
  15. data/lib/bonsai/navigation.rb +7 -0
  16. data/lib/bonsai/page.rb +192 -0
  17. data/lib/bonsai/template.rb +31 -0
  18. data/lib/bonsai/templates/content/index/default.yml +3 -0
  19. data/lib/bonsai/templates/public/.htaccess +28 -0
  20. data/lib/bonsai/templates/public/docs/css/base.less +1 -0
  21. data/lib/bonsai/templates/templates/default.mustache +14 -0
  22. data/lib/bonsai/webserver.rb +19 -0
  23. data/spec/bonsai/console_spec.rb +12 -0
  24. data/spec/bonsai/exporter_spec.rb +142 -0
  25. data/spec/bonsai/generate_spec.rb +40 -0
  26. data/spec/bonsai/navigation_spec.rb +28 -0
  27. data/spec/bonsai/page_spec.rb +225 -0
  28. data/spec/bonsai/template_spec.rb +19 -0
  29. data/spec/bonsai_spec.rb +21 -0
  30. data/spec/spec.opts +1 -0
  31. data/spec/spec_helper.rb +14 -0
  32. data/spec/support/broken/content/broken_page/demo-template.yml +3 -0
  33. data/spec/support/content/1.about-us/1.contact/1.child/a_file_asset.txt +0 -0
  34. data/spec/support/content/1.about-us/1.contact/1.child/demo-template.yml +1 -0
  35. data/spec/support/content/1.about-us/1.contact/demo-template.yml +7 -0
  36. data/spec/support/content/1.about-us/1.contact/images/image001.jpg +0 -0
  37. data/spec/support/content/1.about-us/1.contact/magic/image001.jpg +0 -0
  38. data/spec/support/content/1.about-us/1.contact/magic/image002.jpg +0 -0
  39. data/spec/support/content/1.about-us/demo-template.yml +1 -0
  40. data/spec/support/content/1.about-us/history/a_file_asset.txt +0 -0
  41. data/spec/support/content/1.about-us/history/child/a_file_asset.txt +0 -0
  42. data/spec/support/content/1.about-us/history/child/demo-template.yml +1 -0
  43. data/spec/support/content/1.about-us/history/demo-template.yml +1 -0
  44. data/spec/support/content/1.about-us/history/image001.jpg +0 -0
  45. data/spec/support/content/1.about-us/history/images/image001.jpg +0 -0
  46. data/spec/support/content/1.about-us/history/magic/image001.jpg +0 -0
  47. data/spec/support/content/1.about-us/history/magic/image002.jpg +0 -0
  48. data/spec/support/content/10.many-pages/demo-template.yml +1 -0
  49. data/spec/support/content/2.products/1.product-a/demo-template.yml +1 -0
  50. data/spec/support/content/2.products/2.product-b/demo-template.yml +1 -0
  51. data/spec/support/content/2.products/demo-template.yml +1 -0
  52. data/spec/support/content/index/demo-template.yml +1 -0
  53. data/spec/support/content/legals/terms-and-conditions/demo-template.yml +1 -0
  54. data/spec/support/public/.htaccess +31 -0
  55. data/spec/support/public/js/script.js +19 -0
  56. data/spec/support/public/stylesheets/base.less +2 -0
  57. data/spec/support/public/stylesheets/broken.less +2 -0
  58. data/spec/support/templates/demo-template.mustache +19 -0
  59. data/spec/support/templates/partials/inserted.mustache +1 -0
  60. data/vendor/yui-compressor/yuicompressor-2.4.2.jar +0 -0
  61. metadata +201 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ spec/support/output
23
+ spec/support/public/stylesheets/base.css
data/.kick ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'launchy'
5
+ require 'kicker'
6
+ require 'lib/smeg'
7
+
8
+ Smeg.root_dir = Dir.pwd + "/spec/support"
9
+
10
+ pid = fork {
11
+ app = Rack::Builder.app {
12
+ use Rack::Static, :root => Smeg.root_dir
13
+ run Smeg::DevelopmentServer
14
+ }
15
+ Rack::Handler::Thin.run(app, :Port => 5000)
16
+ }
17
+
18
+ process do
19
+ Smeg::Exporter.publish!
20
+ end
21
+
22
+ sleep 2
23
+ Launchy::Browser.run("http://localhost:5000/")
24
+
25
+
26
+ at_exit { Process.kill("QUIT", pid) }
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ben Schwarz
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,65 @@
1
+ # bonsai
2
+
3
+ Bonsai is a static web site generator, it uses the best tools available for site construction and adheres to best web practices.
4
+
5
+ ## Getting started
6
+
7
+ * Install bonsai
8
+
9
+ `gem install bonsai --source http://gemcutter.org`
10
+
11
+ * Run the generator
12
+
13
+ `bonsai --plant [NAME]`
14
+
15
+ Type `bonsai --help` for any help with commands
16
+
17
+ ## Development server
18
+
19
+ Unlike other static generators, bonsai provides you with a built in web server. Once you've generated the necessary files (generator included) you can simply start developing. Type `bonsai --cultivate` in the root of the generated site, a web server (rack, with thin) will start up.
20
+
21
+ It will also watch for when you save files - taking care of processing your [lesscss](http://lesscss.org/) files - kind of like [autotest](http://www.zenspider.com/ZSS/Products/ZenTest/).
22
+
23
+ ## Production server
24
+
25
+ This is the cool part. Drop a bonsai generated site under pretty much anything. Apache, Nginx, Lighttpd - I don't care.
26
+
27
+ The generator will provide you with a .htaccess file that will turn on gzip/deflate compression for static assets as well as set long standing http caching timestamps and etags.
28
+
29
+ ### Deployment
30
+ * Run `bonsai --repot`
31
+ * Upload the contents of `site-root/output` to your producton server
32
+ * For example: `rsync -ave ssh ./output/ tinytree.info:/var/www/tinytree.info`
33
+
34
+ ## Technology used to make your site better
35
+
36
+ * [Tilt](http://github.com/rtomayko/tilt) - defaulting to [Mustache](http://github.com/defunkt/mustache)
37
+ * [Less CSS](http://lesscss.org/)
38
+ * [YUI CSS/Javascript compressor](http://developer.yahoo.com/yui/compressor/)
39
+
40
+ ## Have you used this for a real job?
41
+
42
+ Yes. I built (and content filled) a web site with around 160 pages in 5 days.
43
+
44
+ When I found something that didn't quite work, was too slow or perhaps not even possible I wrote a spec and implemented it later. Better software from real requirements. (I used every feature I implemented)
45
+
46
+
47
+ ## Thanks
48
+
49
+ * [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
+ * [Lincoln Stoll](http://github.com/lstoll) for reminding me to use the tools that I know best
51
+
52
+
53
+ ## Note on Patches/Pull Requests
54
+
55
+ * Fork the project.
56
+ * Make your feature addition or bug fix.
57
+ * Add tests for it. This is important so I don't break it in a
58
+ future version unintentionally.
59
+ * Commit, do not mess with rakefile, version, or history.
60
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
61
+ * Send me a pull request. Bonus points for topic branches.
62
+
63
+ ## Copyright
64
+
65
+ Copyright (c) 2009 Ben Schwarz. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,64 @@
1
+ $KCODE = "U"
2
+ require 'rubygems'
3
+ require 'rake'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "bonsai"
9
+ gem.summary = %Q{A static site generator that uses the best toolset available}
10
+ gem.description = %Q{A static site generator that uses the best toolset available}
11
+ gem.email = "ben.schwarz@gmail.com"
12
+ gem.homepage = "http://github.com/benschwarz/bonsai"
13
+ gem.authors = ["Ben Schwarz"]
14
+ gem.executables = ['bonsai']
15
+ gem.add_development_dependency "rspec", ">= 1.2.9"
16
+ gem.add_development_dependency "yard", ">= 0"
17
+ gem.add_dependency "tilt", ">= 0.4"
18
+ gem.add_dependency "mustache", ">= 0.5.0"
19
+ gem.add_dependency "thin", ">= 1.0.0"
20
+ gem.add_dependency "watch", ">= 0.1.0"
21
+ gem.add_dependency "sinatra", ">= 0.9.4"
22
+ gem.add_dependency "rdiscount", ">= 1.5.5"
23
+
24
+ gem.post_install_message = %q{
25
+
26
+ 盆栽
27
+ bonsai, tiny and beautiful
28
+
29
+
30
+
31
+ type `bonsai --help` to get started
32
+ }
33
+
34
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
35
+ end
36
+ Jeweler::GemcutterTasks.new
37
+ rescue LoadError
38
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
39
+ end
40
+
41
+ require 'spec/rake/spectask'
42
+ Spec::Rake::SpecTask.new(:spec) do |spec|
43
+ spec.libs << 'lib' << 'spec'
44
+ spec.spec_files = FileList['spec/**/*_spec.rb']
45
+ end
46
+
47
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
48
+ spec.libs << 'lib' << 'spec'
49
+ spec.pattern = 'spec/**/*_spec.rb'
50
+ spec.rcov = true
51
+ end
52
+
53
+ task :spec => :check_dependencies
54
+
55
+ task :default => :spec
56
+
57
+ begin
58
+ require 'yard'
59
+ YARD::Rake::YardocTask.new
60
+ rescue LoadError
61
+ task :yardoc do
62
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
63
+ end
64
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,51 @@
1
+ require 'lib/bonsai'
2
+ require 'benchmark'
3
+
4
+ Bonsai.root_dir = File.dirname(__FILE__) + "/../spec/support"
5
+ Bonsai.configure {|config| config[:enable_logging] = false }
6
+
7
+ page = Bonsai::Page.find("about-us/history")
8
+
9
+ Benchmark.bm do |b|
10
+ b.report "all" do
11
+ 1_000.times do
12
+ Bonsai::Page.all
13
+ end
14
+ end
15
+
16
+ b.report "find" do
17
+ 10_000.times do
18
+ Bonsai::Page.find("about-us/history")
19
+ end
20
+ end
21
+
22
+ b.report "parent" do
23
+ 10_000.times do
24
+ page.parent
25
+ end
26
+ end
27
+
28
+ b.report "children" do
29
+ 10_000.times do
30
+ page.children
31
+ end
32
+ end
33
+
34
+ b.report "siblings" do
35
+ 10_000.times do
36
+ page.siblings
37
+ end
38
+ end
39
+
40
+ b.report "ancestors" do
41
+ 10_000.times do
42
+ page.ancestors
43
+ end
44
+ end
45
+
46
+ b.report "rendering" do
47
+ 1000.times do
48
+ page.render
49
+ end
50
+ end
51
+ end
data/bin/bonsai ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby -KU
2
+
3
+ require 'optparse'
4
+ require 'bonsai'
5
+
6
+ banner = %q{
7
+
8
+ 盆栽
9
+ bonsai, tiny and beautiful
10
+
11
+ }
12
+
13
+ opts = OptionParser.new do |opts|
14
+ opts.banner = banner
15
+
16
+ opts.on("--plant [NAME]", "creates the directory structure for your site") do |name|
17
+ if name.nil?
18
+ Bonsai.log "no site name given check `bonsai --help` for details"
19
+ exit 0
20
+ end
21
+ Bonsai::Generate.new("#{Dir.pwd}/#{name}")
22
+ end
23
+
24
+ opts.on("--cultivate", "run a local web server and process your files on save") do
25
+ Bonsai.log banner
26
+
27
+ require 'rack'
28
+ require 'sinatra'
29
+ require 'watch'
30
+
31
+ Bonsai.root_dir = Dir.pwd
32
+
33
+ server = fork {
34
+ app = Rack::Builder.app {
35
+ use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
36
+ run Bonsai::DevelopmentServer
37
+ }
38
+ Rack::Handler::Thin.run(app, :Port => 5000)
39
+ }
40
+
41
+ trap("SIGINT") do
42
+ Process.kill("QUIT", server)
43
+ exit
44
+ end
45
+
46
+ Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
47
+ end
48
+
49
+ opts.on("--repot", "export your site to #{Dir.pwd}/output") do
50
+ Bonsai.root_dir = Dir.pwd
51
+ Bonsai::Exporter.publish!
52
+ end
53
+
54
+ opts.on("-v", "--version") do
55
+ Bonsai.log "Version: #{Bonsai.version}"
56
+ end
57
+
58
+ opts.on("--console", "start an IRB console session giving you access to your bonsai environment") do
59
+ Bonsai.root_dir = Dir.pwd
60
+ Bonsai::Console.new
61
+ end
62
+ end
63
+
64
+ if ARGV.size == 0
65
+ puts "grow a tiny tree. \ntype --help for a command list"
66
+ exit 1
67
+ end
68
+
69
+ opts.parse!
data/bonsai.gemspec ADDED
@@ -0,0 +1,142 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{bonsai}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ben Schwarz"]
12
+ s.date = %q{2010-01-01}
13
+ s.default_executable = %q{bonsai}
14
+ s.description = %q{A static site generator that uses the best toolset available}
15
+ s.email = %q{ben.schwarz@gmail.com}
16
+ s.executables = ["bonsai"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ ".kick",
25
+ "LICENSE",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "benchmark/associations.rb",
30
+ "bin/bonsai",
31
+ "bonsai.gemspec",
32
+ "lib/bonsai.rb",
33
+ "lib/bonsai/console.rb",
34
+ "lib/bonsai/exporter.rb",
35
+ "lib/bonsai/generate.rb",
36
+ "lib/bonsai/navigation.rb",
37
+ "lib/bonsai/page.rb",
38
+ "lib/bonsai/template.rb",
39
+ "lib/bonsai/templates/content/index/default.yml",
40
+ "lib/bonsai/templates/public/.htaccess",
41
+ "lib/bonsai/templates/public/docs/css/base.less",
42
+ "lib/bonsai/templates/templates/default.mustache",
43
+ "lib/bonsai/webserver.rb",
44
+ "spec/bonsai/console_spec.rb",
45
+ "spec/bonsai/exporter_spec.rb",
46
+ "spec/bonsai/generate_spec.rb",
47
+ "spec/bonsai/navigation_spec.rb",
48
+ "spec/bonsai/page_spec.rb",
49
+ "spec/bonsai/template_spec.rb",
50
+ "spec/bonsai_spec.rb",
51
+ "spec/spec.opts",
52
+ "spec/spec_helper.rb",
53
+ "spec/support/broken/content/broken_page/demo-template.yml",
54
+ "spec/support/content/1.about-us/1.contact/1.child/a_file_asset.txt",
55
+ "spec/support/content/1.about-us/1.contact/1.child/demo-template.yml",
56
+ "spec/support/content/1.about-us/1.contact/demo-template.yml",
57
+ "spec/support/content/1.about-us/1.contact/images/image001.jpg",
58
+ "spec/support/content/1.about-us/1.contact/magic/image001.jpg",
59
+ "spec/support/content/1.about-us/1.contact/magic/image002.jpg",
60
+ "spec/support/content/1.about-us/demo-template.yml",
61
+ "spec/support/content/1.about-us/history/a_file_asset.txt",
62
+ "spec/support/content/1.about-us/history/child/a_file_asset.txt",
63
+ "spec/support/content/1.about-us/history/child/demo-template.yml",
64
+ "spec/support/content/1.about-us/history/demo-template.yml",
65
+ "spec/support/content/1.about-us/history/image001.jpg",
66
+ "spec/support/content/1.about-us/history/images/image001.jpg",
67
+ "spec/support/content/1.about-us/history/magic/image001.jpg",
68
+ "spec/support/content/1.about-us/history/magic/image002.jpg",
69
+ "spec/support/content/10.many-pages/demo-template.yml",
70
+ "spec/support/content/2.products/1.product-a/demo-template.yml",
71
+ "spec/support/content/2.products/2.product-b/demo-template.yml",
72
+ "spec/support/content/2.products/demo-template.yml",
73
+ "spec/support/content/index/demo-template.yml",
74
+ "spec/support/content/legals/terms-and-conditions/demo-template.yml",
75
+ "spec/support/public/.htaccess",
76
+ "spec/support/public/js/script.js",
77
+ "spec/support/public/stylesheets/base.less",
78
+ "spec/support/public/stylesheets/broken.less",
79
+ "spec/support/templates/demo-template.mustache",
80
+ "spec/support/templates/partials/inserted.mustache",
81
+ "vendor/yui-compressor/yuicompressor-2.4.2.jar"
82
+ ]
83
+ s.homepage = %q{http://github.com/benschwarz/bonsai}
84
+ s.post_install_message = %q{
85
+
86
+ 盆栽
87
+ bonsai, tiny and beautiful
88
+
89
+
90
+
91
+ type `bonsai --help` to get started
92
+ }
93
+ s.rdoc_options = ["--charset=UTF-8"]
94
+ s.require_paths = ["lib"]
95
+ s.rubygems_version = %q{1.3.5}
96
+ s.summary = %q{A static site generator that uses the best toolset available}
97
+ s.test_files = [
98
+ "spec/bonsai/console_spec.rb",
99
+ "spec/bonsai/exporter_spec.rb",
100
+ "spec/bonsai/generate_spec.rb",
101
+ "spec/bonsai/navigation_spec.rb",
102
+ "spec/bonsai/page_spec.rb",
103
+ "spec/bonsai/template_spec.rb",
104
+ "spec/bonsai_spec.rb",
105
+ "spec/spec_helper.rb"
106
+ ]
107
+
108
+ if s.respond_to? :specification_version then
109
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
110
+ s.specification_version = 3
111
+
112
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
113
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
114
+ s.add_development_dependency(%q<yard>, [">= 0"])
115
+ s.add_runtime_dependency(%q<tilt>, [">= 0.4"])
116
+ s.add_runtime_dependency(%q<mustache>, [">= 0.5.0"])
117
+ s.add_runtime_dependency(%q<thin>, [">= 1.0.0"])
118
+ s.add_runtime_dependency(%q<watch>, [">= 0.1.0"])
119
+ s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
120
+ s.add_runtime_dependency(%q<rdiscount>, [">= 1.5.5"])
121
+ else
122
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
123
+ s.add_dependency(%q<yard>, [">= 0"])
124
+ s.add_dependency(%q<tilt>, [">= 0.4"])
125
+ s.add_dependency(%q<mustache>, [">= 0.5.0"])
126
+ s.add_dependency(%q<thin>, [">= 1.0.0"])
127
+ s.add_dependency(%q<watch>, [">= 0.1.0"])
128
+ s.add_dependency(%q<sinatra>, [">= 0.9.4"])
129
+ s.add_dependency(%q<rdiscount>, [">= 1.5.5"])
130
+ end
131
+ else
132
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
133
+ s.add_dependency(%q<yard>, [">= 0"])
134
+ s.add_dependency(%q<tilt>, [">= 0.4"])
135
+ s.add_dependency(%q<mustache>, [">= 0.5.0"])
136
+ s.add_dependency(%q<thin>, [">= 1.0.0"])
137
+ s.add_dependency(%q<watch>, [">= 0.1.0"])
138
+ s.add_dependency(%q<sinatra>, [">= 0.9.4"])
139
+ s.add_dependency(%q<rdiscount>, [">= 1.5.5"])
140
+ end
141
+ end
142
+