gumdrop 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. data/.gitignore +3 -0
  2. data/ChangeLog.md +13 -0
  3. data/Gemfile +6 -2
  4. data/Gemfile.lock +43 -3
  5. data/Rakefile +37 -21
  6. data/Readme.md +60 -158
  7. data/bin/gumdrop +2 -1
  8. data/gumdrop.gemspec +11 -4
  9. data/lib/gumdrop/builder.rb +164 -0
  10. data/lib/gumdrop/cli/external.rb +14 -9
  11. data/lib/gumdrop/cli/internal.rb +54 -22
  12. data/lib/gumdrop/cli.rb +21 -0
  13. data/lib/gumdrop/content.rb +195 -132
  14. data/lib/gumdrop/data.rb +185 -0
  15. data/lib/gumdrop/data_providers/csv.rb +18 -0
  16. data/lib/gumdrop/data_providers/pstore.rb +25 -0
  17. data/lib/gumdrop/data_providers/sqlite.rb +43 -0
  18. data/lib/gumdrop/data_providers/xml.rb +15 -0
  19. data/lib/gumdrop/data_providers/yaml_and_json.rb +18 -0
  20. data/lib/gumdrop/data_providers/yamldb.rb +18 -0
  21. data/lib/gumdrop/data_providers/yamldoc.rb +12 -0
  22. data/lib/gumdrop/generator.rb +118 -94
  23. data/lib/gumdrop/renderer.rb +272 -0
  24. data/lib/gumdrop/server.rb +36 -27
  25. data/lib/gumdrop/site.rb +283 -338
  26. data/lib/gumdrop/support/compressor.rb +52 -0
  27. data/lib/gumdrop/support/sprockets.rb +14 -23
  28. data/lib/gumdrop/support/stitch.rb +25 -14
  29. data/lib/gumdrop/support/yaml_doc_template.rb +29 -0
  30. data/lib/gumdrop/util/configurable.rb +44 -0
  31. data/lib/gumdrop/util/core_ex.rb +84 -0
  32. data/lib/gumdrop/util/eventable.rb +35 -0
  33. data/lib/gumdrop/util/hash_object.rb +70 -0
  34. data/lib/gumdrop/util/loggable.rb +44 -0
  35. data/lib/gumdrop/util/pager.rb +51 -0
  36. data/lib/gumdrop/{support → util}/proxy_handler.rb +7 -6
  37. data/lib/gumdrop/util/scanner.rb +47 -0
  38. data/lib/gumdrop/util/site_access.rb +16 -0
  39. data/lib/gumdrop/util/view_helpers.rb +50 -0
  40. data/lib/gumdrop/util/yaml_doc.rb +51 -0
  41. data/lib/gumdrop/version.rb +2 -2
  42. data/lib/gumdrop.rb +40 -77
  43. data/specs/content_spec.rb +83 -73
  44. data/specs/fixtures/expected/data-access/from-csv.html +4 -0
  45. data/specs/fixtures/expected/data-access/from-json.html +6 -0
  46. data/specs/fixtures/expected/data-access/from-sqlite.html +5 -0
  47. data/specs/fixtures/expected/data-access/from-xml.html +4 -0
  48. data/specs/fixtures/expected/data-access/from-yaml.html +5 -0
  49. data/specs/fixtures/expected/data-access/from-yamldb.html +5 -0
  50. data/specs/fixtures/expected/data-access/from-yamldoc.html +2 -0
  51. data/specs/fixtures/expected/gen-with-block/as-file.html +1 -0
  52. data/specs/fixtures/expected/gen-with-block/as-plain.html +1 -0
  53. data/specs/fixtures/expected/gen-with-block/layout-nested.html +1 -0
  54. data/specs/fixtures/expected/gen-with-block/layout-nil.html +1 -0
  55. data/specs/fixtures/expected/gen-with-block/layout-wrap.html +1 -0
  56. data/specs/fixtures/expected/gen-with-inline-render/0-as-file.html +4 -0
  57. data/specs/fixtures/expected/gen-with-inline-render/0-as-plain.html +4 -0
  58. data/specs/fixtures/expected/gen-with-inline-render/0-layout-nil.html +4 -0
  59. data/specs/fixtures/expected/gen-with-inline-render/0-layout-sub.html +4 -0
  60. data/specs/fixtures/expected/gen-with-inline-render/0-layout-wrap.html +4 -0
  61. data/specs/fixtures/expected/gen-with-inline-render/1-as-file.html +4 -0
  62. data/specs/fixtures/expected/gen-with-inline-render/1-as-plain.html +4 -0
  63. data/specs/fixtures/expected/gen-with-inline-render/1-layout-nil.html +4 -0
  64. data/specs/fixtures/expected/gen-with-inline-render/1-layout-sub.html +4 -0
  65. data/specs/fixtures/expected/gen-with-inline-render/1-layout-wrap.html +4 -0
  66. data/specs/fixtures/expected/goodbye.html +1 -0
  67. data/specs/fixtures/expected/hello.html +1 -0
  68. data/specs/fixtures/expected/image.png +0 -0
  69. data/specs/fixtures/expected/index.html +47 -0
  70. data/specs/fixtures/expected/js/sprockets-app.js +7 -0
  71. data/specs/fixtures/expected/js/stitch-app.js +65 -0
  72. data/specs/fixtures/expected/js/stitch-app.min.js +5 -0
  73. data/specs/fixtures/expected/js/stitch-app.min.src.js +65 -0
  74. data/specs/fixtures/expected/js/straight.js +8 -0
  75. data/specs/fixtures/expected/js/test-coffee.js +5 -0
  76. data/specs/fixtures/expected/pages/docs/force-abs.html +2 -0
  77. data/specs/fixtures/expected/pages/docs/index.html +2 -0
  78. data/specs/fixtures/expected/partials/hoisted-data.html +3 -0
  79. data/specs/fixtures/expected/partials/nested.html +7 -0
  80. data/specs/fixtures/expected/partials/params.html +1 -0
  81. data/specs/fixtures/expected/partials/with-layouts.html +1 -0
  82. data/specs/fixtures/expected/robots.txt +1 -0
  83. data/specs/fixtures/expected/test-multi-procs.html +4 -0
  84. data/specs/fixtures/expected/test-nested-layout.html +1 -0
  85. data/specs/fixtures/expected/test-no-layout.html +2 -0
  86. data/specs/fixtures/expected/test-yamldoc.html +1 -0
  87. data/specs/fixtures/expected/test.html +2 -0
  88. data/{templates/backbone → specs/fixtures/source}/Gemfile +8 -4
  89. data/specs/fixtures/source/Gemfile.lock +84 -0
  90. data/specs/fixtures/source/Gumdrop +60 -9
  91. data/specs/fixtures/source/data/csv_data.csv +2 -0
  92. data/specs/fixtures/source/data/json_data.json +13 -0
  93. data/specs/fixtures/source/data/sql_data.sqlite +0 -0
  94. data/specs/fixtures/source/data/xml_data.xml +4 -0
  95. data/specs/fixtures/source/data/yaml_db.yamldb +9 -0
  96. data/specs/fixtures/source/data/yaml_items.yaml +2 -0
  97. data/specs/fixtures/source/data/yamldoc.yamldoc +4 -0
  98. data/specs/fixtures/source/data-access/from-csv.html.erb +4 -0
  99. data/specs/fixtures/source/data-access/from-json.html.erb +6 -0
  100. data/specs/fixtures/source/data-access/from-sqlite.html.erb +5 -0
  101. data/specs/fixtures/source/data-access/from-xml.html.erb +5 -0
  102. data/specs/fixtures/source/data-access/from-yaml.html.erb +5 -0
  103. data/specs/fixtures/source/data-access/from-yamldb.html.erb +5 -0
  104. data/specs/fixtures/source/data-access/from-yamldoc.html.erb +2 -0
  105. data/specs/fixtures/source/gen-with-inline-render.generator +7 -0
  106. data/specs/fixtures/source/goodbye.html.erb +1 -0
  107. data/specs/fixtures/source/hello.html +1 -0
  108. data/specs/fixtures/source/image.png +0 -0
  109. data/specs/fixtures/source/index.html.erb +6 -0
  110. data/specs/fixtures/source/js/sprockets/app.js +2 -0
  111. data/specs/fixtures/source/js/sprockets/view.js.coffee +1 -0
  112. data/specs/fixtures/source/js/stitch/app.js +1 -0
  113. data/specs/fixtures/source/js/stitch/view.js.coffee +1 -0
  114. data/specs/fixtures/source/js/straight.js +8 -0
  115. data/specs/fixtures/source/js/test-coffee.js.coffee +1 -0
  116. data/specs/fixtures/source/layouts/site.layout.erb +1 -0
  117. data/specs/fixtures/source/layouts/sub.layout.erb +1 -0
  118. data/specs/fixtures/source/layouts/wrap.layout.erb +1 -0
  119. data/specs/fixtures/source/pages/_users-nested.html.erb +7 -0
  120. data/specs/fixtures/source/pages/docs/force-abs.html.erb +2 -0
  121. data/specs/fixtures/source/pages/docs/index.html.erb +2 -0
  122. data/specs/fixtures/source/partials/_post_entry.html.erb +4 -0
  123. data/specs/fixtures/source/partials/_provides_name.html.erb +1 -0
  124. data/specs/fixtures/source/partials/_user-params.html.erb +1 -0
  125. data/specs/fixtures/source/partials/_user.html.erb +1 -0
  126. data/specs/fixtures/source/partials/_user_sets_layout.html.erb +1 -0
  127. data/specs/fixtures/source/partials/hoisted-data.html.erb +6 -0
  128. data/specs/fixtures/source/partials/nested.html.erb +1 -0
  129. data/specs/fixtures/source/partials/params.html.erb +1 -0
  130. data/specs/fixtures/source/partials/with-layouts.html.erb +1 -0
  131. data/specs/fixtures/source/test-multi-procs.html.markdown.erb +3 -0
  132. data/specs/fixtures/source/test-nested-layout.html.erb +1 -0
  133. data/specs/fixtures/source/test-no-layout.html.erb +2 -0
  134. data/specs/fixtures/source/test-yamldoc.html.erb.yamldoc +4 -0
  135. data/specs/fixtures/source/test.html.erb +2 -0
  136. data/specs/hash_object_spec.rb +53 -8
  137. data/specs/render_spec.rb +10 -0
  138. data/specs/site_spec.rb +79 -0
  139. data/specs/spec_helper.rb +59 -0
  140. data/templates/blank/Gemfile +0 -4
  141. data/templates/blank/Gumdrop +180 -113
  142. data/templates/default/Gemfile +3 -8
  143. data/templates/default/Gumdrop +166 -95
  144. data/templates/default/ReadMe.md +14 -0
  145. data/templates/default/config.ru +1 -0
  146. data/templates/default/data/news/20120703.yamldoc +14 -0
  147. data/templates/default/data/news/20120704.yamldoc +8 -0
  148. data/templates/{backbone/source/feed.xml.builder.txt → default/source/feed.xml.builder} +4 -4
  149. data/templates/default/source/index.html.erb +10 -1
  150. data/templates/default/source/theme/layout/_sidebar.html +1 -0
  151. data/templates/{backbone/source/theme/templates/site.template.slim → default/source/theme/layout/site.layout.slim} +3 -3
  152. metadata +212 -63
  153. data/lib/gumdrop/context.rb +0 -135
  154. data/lib/gumdrop/data_manager.rb +0 -214
  155. data/lib/gumdrop/support/base_packager.rb +0 -60
  156. data/lib/gumdrop/support/callbacks.rb +0 -30
  157. data/lib/gumdrop/support/hash_object.rb +0 -22
  158. data/lib/gumdrop/view_helpers.rb +0 -25
  159. data/notes.md +0 -347
  160. data/specs/deferred_loader_spec.rb +0 -31
  161. data/specs/fixtures/expected/posts/post1.html +0 -1
  162. data/specs/fixtures/expected/posts/post1.js +0 -14
  163. data/specs/fixtures/expected/posts/post2.html +0 -5
  164. data/specs/fixtures/expected/sub/sub/sub/test.html +0 -5
  165. data/specs/fixtures/expected/sub/sub/sub/test2.html +0 -5
  166. data/specs/fixtures/expected/test.js +0 -14
  167. data/specs/fixtures/source/posts/post1.html.slim +0 -6
  168. data/specs/fixtures/source/posts/post1.js.coffee +0 -3
  169. data/specs/fixtures/source/posts/post2.html.erb +0 -5
  170. data/specs/fixtures/source/sub/sub/sub/test.html +0 -5
  171. data/specs/fixtures/source/sub/sub/sub/test2.html.erb +0 -5
  172. data/specs/fixtures/source/test.js.coffee +0 -4
  173. data/specs/fixtures/source/test.js.erb.coffee +0 -3
  174. data/templates/backbone/Gumdrop +0 -123
  175. data/templates/backbone/Rakefile +0 -38
  176. data/templates/backbone/app/app.js.coffee +0 -49
  177. data/templates/backbone/app/init.js.coffee +0 -10
  178. data/templates/backbone/app/models/.gitkeep +0 -0
  179. data/templates/backbone/app/utils/index.js.coffee +0 -27
  180. data/templates/backbone/app/views/home.js.coffee +0 -17
  181. data/templates/backbone/app/views/styles/home.scss +0 -8
  182. data/templates/backbone/app/views/templates/home.mustache +0 -2
  183. data/templates/backbone/config.ru +0 -20
  184. data/templates/backbone/lib/all.js.coffee +0 -18
  185. data/templates/backbone/lib/backbone.js +0 -1158
  186. data/templates/backbone/lib/hogan.js +0 -509
  187. data/templates/backbone/lib/jquery.js +0 -9266
  188. data/templates/backbone/lib/underscore.js +0 -981
  189. data/templates/backbone/powrc +0 -2
  190. data/templates/backbone/source/default.htaccess.erb +0 -27
  191. data/templates/backbone/source/favicon.ico +0 -0
  192. data/templates/backbone/source/index.html.erb +0 -2
  193. data/templates/backbone/source/theme/screen.css.sass +0 -9
  194. data/templates/backbone/source/theme/scripts/app.js.coffee +0 -4
  195. data/templates/backbone/source/theme/styles/_tools.scss +0 -434
  196. data/templates/backbone/source/theme/templates/app.template.slim +0 -14
  197. data/templates/default/Rakefile +0 -38
  198. data/templates/default/powrc +0 -2
  199. data/templates/default/source/default.htaccess.erb +0 -27
  200. data/templates/default/source/feed.xml.builder.txt +0 -23
  201. data/templates/default/source/theme/templates/site.template.slim +0 -33
data/.gitignore CHANGED
@@ -2,3 +2,6 @@
2
2
  *.gem
3
3
  output
4
4
  .sass-cache
5
+ *.log
6
+ old_*
7
+ **/Gemfile.lock
data/ChangeLog.md CHANGED
@@ -1,3 +1,16 @@
1
+ # v1.0.0
2
+ - Complete internel rearchitecture. Good stuff.
3
+ - Gumdrop files are now straight ruby that's loaded by gumdrop. You can do any typical ruby kind of things are the root level without having any scope surprises (Gumdrop will have been loaded).
4
+ - New event system. `Gumdrop.on :event_name {|e| }` Events:
5
+ - `:build`
6
+ - `:scan`
7
+ - `:generate`
8
+ - `:render`
9
+ - `:render_item`
10
+ - All the events have :before_* and :after_* versions too.
11
+ - Removed content filters. You can now listen for the :render_item event and set event.data.return_value to change content post-render (layout will have been applied)
12
+ - New DataProviders: csv, xml and sqlite3
13
+
1
14
  # v0.8.0
2
15
  - Leveraging Thor for new CLI support.
3
16
  - Added watch command to watch filesystem and auto-compile.
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'redcarpet'
7
+ end
data/Gemfile.lock CHANGED
@@ -1,31 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gumdrop (0.7.5)
4
+ gumdrop (1.0.0)
5
5
  active_support
6
6
  bundle
7
7
  i18n
8
+ listen
9
+ onfire
8
10
  sinatra
9
11
  thor
10
12
  tilt
11
13
 
12
14
  GEM
13
- remote: http://rubygems.org/
15
+ remote: https://rubygems.org/
14
16
  specs:
15
17
  active_support (3.0.0)
16
18
  activesupport (= 3.0.0)
17
19
  activesupport (3.0.0)
18
20
  bundle (0.0.1)
19
21
  bundler
22
+ chunky_png (1.2.5)
23
+ compass (0.12.2)
24
+ chunky_png (~> 1.2)
25
+ fssm (>= 0.2.7)
26
+ sass (~> 3.1)
27
+ ffi (1.0.11)
28
+ fssm (0.2.9)
29
+ hike (1.2.1)
20
30
  i18n (0.6.0)
31
+ jsmin (1.0.1)
32
+ listen (0.4.7)
33
+ rb-fchange (~> 0.0.5)
34
+ rb-fsevent (~> 0.9.1)
35
+ rb-inotify (~> 0.8.8)
36
+ minitest (3.2.0)
37
+ multi_json (1.3.6)
38
+ onfire (0.2.0)
21
39
  rack (1.4.1)
22
40
  rack-protection (1.2.0)
23
41
  rack
42
+ rb-fchange (0.0.5)
43
+ ffi
44
+ rb-fsevent (0.9.1)
45
+ rb-inotify (0.8.8)
46
+ ffi (>= 0.5.0)
47
+ redcarpet (2.1.1)
48
+ sass (3.2.0.alpha.261)
24
49
  sinatra (1.3.2)
25
50
  rack (~> 1.3, >= 1.3.6)
26
51
  rack-protection (~> 1.2)
27
52
  tilt (~> 1.3, >= 1.3.3)
28
- thor (0.15.3)
53
+ sprockets (2.4.3)
54
+ hike (~> 1.2)
55
+ multi_json (~> 1.0)
56
+ rack (~> 1.0)
57
+ tilt (~> 1.1, != 1.3.0)
58
+ sqlite3 (1.3.6)
59
+ stitch (0.1.6)
60
+ compass
61
+ sass (~> 3.2.0.alpha)
62
+ thor (0.15.4)
29
63
  tilt (1.3.3)
30
64
 
31
65
  PLATFORMS
@@ -33,3 +67,9 @@ PLATFORMS
33
67
 
34
68
  DEPENDENCIES
35
69
  gumdrop!
70
+ jsmin
71
+ minitest
72
+ redcarpet
73
+ sprockets
74
+ sqlite3
75
+ stitch
data/Rakefile CHANGED
@@ -1,30 +1,46 @@
1
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
- require "gumdrop/version"
1
+ #!/usr/bin/env rake
2
+
3
3
  require 'rake/testtask'
4
+ require "bundler/gem_tasks"
4
5
 
5
- desc "builds gem"
6
- task :build do
7
- system "gem build gumdrop.gemspec"
8
- end
9
-
10
- desc "releases gem"
11
- task :release => :build do
12
- system "gem push gumdrop-#{Gumdrop::VERSION}.gem"
6
+ Rake::TestTask.new do |t|
7
+ t.libs.push "lib"
8
+ t.test_files = FileList['specs/*_spec.rb']
9
+ t.verbose = false
13
10
  end
14
11
 
15
- desc "installs gem"
16
- task :install => :build do
17
- system "gem install gumdrop-#{Gumdrop::VERSION}"
12
+ task :default do
13
+ puts `rake -T`
18
14
  end
19
15
 
20
- desc "uninstalls gem"
21
- task :uninstall do
22
- system "gem uninstall gumdrop"
16
+ desc 'clears fixture generated output'
17
+ task :test_output_clear do
18
+ require 'fileutils'
19
+ here= File.dirname __FILE__
20
+ FileUtils.rm_rf File.join( here, 'specs', 'fixtures', 'output' )
23
21
  end
24
22
 
23
+ desc "generates fixture site then tests output against expected fixture data"
24
+ task :test_output => :test_output_clear do
25
+ sh "cd specs/fixtures/source && bundle exec gumdrop build -f"
26
+ diff_results= `diff -w -r -y -N -q --suppress-common-lines specs/fixtures/output specs/fixtures/expected`
27
+ if diff_results.empty?
28
+ puts "\n\nPASS: All files matched!"
29
+ puts "#{ diff_results }"
30
+ diff_results.split("\n")
31
+ else
32
+ puts "\n\nFAIL: Not all files matched:\n\n"
33
+ puts "#{ diff_results }"
34
+ matcher= Regexp.new('Files (.*) and', 'i')
35
+ diff_results.scan(matcher).flatten.each do |fname|
36
+ puts "\n\n"
37
+ puts `diff -w -C 3 #{fname} #{fname.gsub('fixtures/output', 'fixtures/expected')}`
38
+ end
39
+ end
40
+ puts ""
41
+ end
25
42
 
26
- Rake::TestTask.new do |t|
27
- t.libs.push "lib"
28
- t.test_files = FileList['specs/*_spec.rb']
29
- t.verbose = true
30
- end
43
+ desc "test generated output > OpenDiff"
44
+ task :test_output_ui do
45
+ sh "cd specs/fixtures/source && bundle exec gumdrop build -f && opendiff ../output ../expected"
46
+ end
data/Readme.md CHANGED
@@ -1,191 +1,93 @@
1
1
  # Gumdrop
2
2
 
3
- Gumdrop is a small and sweet cms/prototype tool. It can generate static html with relative paths, and includes a dev server that can be run via any rack server (including POW!).
3
+ Gumdrop; The sweet cms/prototyping tool.
4
4
 
5
- ## Install
6
-
7
- gem install gumdrop
8
-
9
- # CLI Quick Ref
10
-
11
- ### Create New Site
12
-
13
- gumdrop --create my_new_site
14
-
15
- Shorter syntax:
16
-
17
- gumdrop -c my_new_site
18
-
19
- ### Create New Site From Template
5
+ It generates static html and includes a dev server that can be run via any
6
+ rack server (including POW!).
20
7
 
21
- gumdrop -c my_new_site -t backbone
22
8
 
9
+ ## Install
23
10
 
24
- ### Build Static HTML
25
-
26
- gumdrop -b
27
-
28
- Or, you can use Rake:
29
-
30
- rake build
31
-
32
-
33
- ### Start Dev Server
34
-
35
- gumdrop -s
36
-
37
- Or, using Rake again:
11
+ ```bash
12
+ $ gem install gumdrop
13
+ ```
38
14
 
39
- rake serve
40
15
 
41
- ### Saving The Current Site As A Local Template
16
+ ## Quick Start
42
17
 
43
- gumdrop -t my_template
18
+ ```bash
19
+ $ gumdrop new SITE_NAME
20
+ ```
44
21
 
45
- You can then create new sites based on your local template:
22
+ *(You can run `gumdrop help` to see a list of commands and their supported flags.)*
46
23
 
47
- gumdrop -c my_new_from_my_template -t my_template
24
+ Gumdrop will spit out a default Gumdrop project site for you, which you can then
25
+ build by running:
48
26
 
49
- Local templates are stored under `~/.gumdrop/templates/`.
27
+ ```bash
28
+ $ cd SITE_NAME
29
+ $ gumdrop build
30
+ ```
50
31
 
32
+ Bam! A static version of the site is now available in a newly created `./output`
33
+ folder.
51
34
 
35
+ Don't want the output there? Maybe you want it to put it in `./public` instead?
36
+ No problem. Open up the `Gumdrop` project file:
52
37
 
53
- # Gumdrop File
38
+ ```bash
39
+ $ $EDITOR Gumdrop
40
+ ```
54
41
 
55
- Gumdrop looks for a file named `Gumdrop` to indicate the root folder of your project. It'll walk up the directory structure looking for one, so you can run Gumdrop commands from sub-folders.
42
+ At the top of the file you'll find a `Gumdrop.configure` block. Add this to the
43
+ top of that block:
56
44
 
57
- The `Gumdrop` file is where you configure your site, generate dynamic content, assign view_helpers and more.
45
+ ```ruby
46
+ Gumdrop.configure do |config|
58
47
 
59
- Here's the `Gumdrop` file created by the default template:
48
+ config.output_dir= "./public"
60
49
 
61
- puts "Gumdrop v#{Gumdrop::VERSION} building..."
50
+ # ... Other stuff
62
51
 
63
- configure do
52
+ end
53
+ ```
64
54
 
65
- set :site_title, "My Site"
66
- set :site_tagline, "My home on thar intarwebs!"
67
- set :site_author, "Me"
68
- set :site_url, "http://www.mysite.com"
69
-
70
- # All the supported build configuration settings and their defaults:
71
- # set :relative_paths, true
72
- # set :proxy_enabled, true
73
- # set :output_dir, "./output"
74
- # set :source_dir, "./source"
75
- # set :data_dir, './data'
76
- # set :log, './logs/build.log'
77
- # set :ignore, %w(.DS_Store .gitignore .git .svn .sass-cache)
78
- # set :server_timeout, 15
79
- # set :server_port, 4567
55
+ Now, when you run `gumdrop build` again, it'll generate all the output into
56
+ the `./public` folder (creating it, if it doesn't exist).
80
57
 
81
- end
82
58
 
59
+ ## Lots More
83
60
 
84
- # Skipping files entirely from build process... Like they don't exist.
85
- # skip 'file-to-ignore.html'
86
- # skip 'dont-show/**/*'
61
+ That's enough to get you started! Poke around the code it generated to see how
62
+ it works. You can also start with a blank slate by running:
87
63
 
88
- # Ignores source file(s) from compilation, but does load the content into memory
89
- # ignore 'pages/**/*.*'
64
+ ```bash
65
+ $ gumdrop new -t blank MY_BLANK_SITE
66
+ ```
90
67
 
91
- # NOTE: Skipping and ignoring matches like a file glob (it use File.fnmatch in fact)
92
- # (this doesn't work for files detected by stitch)
68
+ Gumdrop can do quite a lot and is very configurable. Be sure and read the wiki
69
+ for documentation and more examples!
93
70
 
71
+ [https://github.com/darthapo/gumdrop/wiki](https://github.com/darthapo/gumdrop/wiki)
94
72
 
95
- # Example site-level generator
96
- generate do
97
-
98
- # Requires a about.template.XX file
99
- # page "about.html",
100
- # :template=>'about',
101
- # :passthru=>'Available in the template'
73
+ ## By The Power of...
102
74
 
103
- # page 'robots.txt' do
104
- # # And content returned will be put in the file
105
- # """
106
- # User-Agent: *
107
- # Disallow: /
108
- # """
109
- # end
75
+ Greyskull? Well, not so much. But Gumdrop core is powered by these excellent
76
+ open source projects (in alphabetical order):
110
77
 
111
- # Maybe for a tumblr-like pager
112
- # pager= Gumdrop.data.pager_for :posts, base_path:'posts/page', page_size:5
78
+ * ActiveSupport
79
+ * Bundle
80
+ * Listen
81
+ * Onfire
82
+ * Sinatra
83
+ * Tilt
84
+ * Thor
113
85
 
114
- # pager.each do |page|
115
- # page "#{page.uri}.html",
116
- # template:'post_page',
117
- # posts:page.items,
118
- # pager:pager,
119
- # current_page:pager.current_page
120
- # end
86
+ And will, optionally, leverage these in building your site:
121
87
 
122
- # Assemble javscript files in a CommonJS-like way with stitch-rb
123
- # stitch 'app.js', # JavaScript to assemble
124
- # :identifier=>'app', # variable name for the library
125
- # :paths=>['./app'],
126
- # :root=>'./app',
127
- # :dependencies=>[], # List of scripts to prepend to top of file (non moduled)
128
- # :prune=>false, # If true, removes the source files from Gumdrop.site hash
129
- # :compress=>:jsmin, # Options are :jsmin, :yuic, :uglify
130
- # :obfuscate=>false, # For compressors that support munging/mangling
131
- # :keep_src=>true # Creates another file, ex: app-src.js
132
-
133
- end
88
+ * sqlite3
89
+ * sprockets
90
+ * stitch
91
+ * jsmin
92
+ * and many, many more! (todo: gotta document 'em all!)
134
93
 
135
- # Example of using a content filter to compress CSS output
136
- # require 'yui/compressor'
137
- # content_filter do |content, info|
138
- # if info.ext == '.css'
139
- # puts " Compress: #{info.filename}"
140
- # compressor= YUI::CssCompressor.new
141
- # compressor.compress( content )
142
- # else
143
- # content
144
- # end
145
- # end
146
-
147
-
148
- # View helpers (available in rendering context):
149
- view_helpers do
150
-
151
- # Calculate the years for a copyright
152
- def copyright_years(start_year, divider="–")
153
- end_year = Date.today.year
154
- if start_year == end_year
155
- "#{start_year}"
156
- else
157
- "#{start_year}#{divider}#{end_year}"
158
- end
159
- end
160
-
161
- #
162
- # Your custom helpers go here!
163
- #
164
-
165
- end
166
-
167
- # Any specialized code for your site goes here...
168
-
169
- require 'slim'
170
- Slim::Engine.set_default_options pretty:true
171
-
172
-
173
- # Need To Document:
174
-
175
- - Proxy support
176
- - Stitch
177
- - "Dynamic" pages
178
- - Data support
179
- - Content filters
180
- - Partials
181
- - Config and using in pages
182
- - Project Templates
183
-
184
- # Todo / Ideas / Changes
185
- - Create guard-gumdrop.
186
- - Add automatic sqlite loading to `data_manager`?
187
- - New/Update Doc site.
188
- - Need test coverage.
189
- - Some kind of admin? What would that even do?
190
- - If you could specify a 'prototype' for data collections, could be cool.
191
- - Add YamlDoc support for nodes? (Tilt compiler? or in Content)
data/bin/gumdrop CHANGED
@@ -2,7 +2,6 @@
2
2
  # encoding: utf-8
3
3
  # Copyright (c) 2011 M@ McCray. All rights reserved.
4
4
 
5
- # $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
6
5
  require 'rubygems'
7
6
  require 'bundler/setup'
8
7
  require 'gumdrop'
@@ -10,6 +9,8 @@ Bundler.require if File.exists?('Gemfile')
10
9
 
11
10
  begin
12
11
  if Gumdrop.in_site_folder?
12
+ # Pre-Fetch Site and load Gumdrop file
13
+ Gumdrop.site()
13
14
  Gumdrop::CLI::Internal.start
14
15
  else
15
16
  Gumdrop::CLI::External.start
data/gumdrop.gemspec CHANGED
@@ -15,21 +15,28 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.authors = ["Matt McCray"]
17
17
  s.email = %q{matt@elucidata.net}
18
- s.summary = %q{The sweet 'n simple cms/prototyping tool.}
18
+ s.summary = %q{The sweet 'n simple cms and prototyping tool.}
19
19
  s.homepage = %q{https://github.com/darthapo/gumdrop}
20
- s.description = %q{The sweet 'n simple cms/prototyping tool for creating static html websites and webapps.}
20
+ s.description = %q{The sweet 'n simple cms and prototyping tool for creating static html websites and webapps.}
21
21
 
22
22
  s.files = `git ls-files`.split("\n")
23
23
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
25
  s.require_paths = ["lib"]
26
26
 
27
- s.add_dependency 'sinatra'
27
+ s.add_dependency 'thor'
28
28
  s.add_dependency 'tilt'
29
29
  s.add_dependency 'active_support'
30
+ s.add_dependency 'onfire'
31
+ s.add_dependency 'sinatra'
30
32
  s.add_dependency 'listen'
31
- s.add_dependency 'thor'
32
33
  s.add_dependency 'i18n'
33
34
  s.add_dependency 'bundle'
34
35
 
36
+ s.add_development_dependency 'minitest'
37
+ s.add_development_dependency 'sqlite3'
38
+ s.add_development_dependency 'sprockets'
39
+ s.add_development_dependency 'stitch'
40
+ s.add_development_dependency 'jsmin'
41
+
35
42
  end
@@ -0,0 +1,164 @@
1
+ require 'fileutils'
2
+ require 'digest/md5'
3
+
4
+ module Gumdrop
5
+
6
+ class Builder
7
+ include Util::SiteAccess
8
+
9
+ attr_reader :renderer, :checksums, :options
10
+
11
+ def initialize(opts={})
12
+ site.active_builder= self
13
+ opts= opts.to_symbolized_hash
14
+ @renderer= opts[:renderer] || Renderer.new
15
+ @copy_files=[]
16
+ @write_files=[]
17
+ @checksums={}
18
+ @options= opts
19
+ @use_checksum= if opts[:force]
20
+ false
21
+ else
22
+ site.config.file_change_test == :checksum
23
+ end
24
+ end
25
+
26
+ def execute
27
+ fire :start
28
+ event_block :build do
29
+ log.debug "[Building Site]"
30
+ log.debug "(Rendering)"
31
+ event_block :render do
32
+ if @options[:assets]
33
+ _build_assets @options[:assets], true
34
+ else
35
+ _build_assets site.contents.keys.sort
36
+ end
37
+ end
38
+ # All files rendered without exception, write them to disc
39
+ log.info "(Writing to #{ site.output_path })"
40
+ event_block :write do
41
+ @write_files.each {|files| _write files }
42
+ @copy_files.each {|files| _copy files }
43
+ end
44
+ end
45
+ fire :end
46
+ rescue => ex
47
+ log.error _exception_message ex
48
+ $stderr.puts _exception_message ex, true
49
+ exit 1 unless site.options[:resume]
50
+ end
51
+
52
+ private
53
+
54
+ def _build_assets(uris, fuzzy_match=false)
55
+ uris.each do |uri|
56
+ if fuzzy_match
57
+ content= site.resolve uri
58
+ else
59
+ content= site.contents[uri]
60
+ end
61
+ log.error "Content not found! #{ uri }" and next if content.nil?
62
+ log.debug " blackout: #{ uri }" and next if site.in_blacklist? uri
63
+ output_path= site.output_path / content.uri
64
+ if content.binary?
65
+ @copy_files << { content.source_path => output_path }
66
+ else
67
+ rendered_content= renderer.draw content
68
+ @write_files << { rendered_content => output_path }
69
+ end
70
+ end
71
+ end
72
+
73
+ def _copy(files)
74
+ files.each do |from,to|
75
+ event_block :copy_file do
76
+ if _file_changed? from, to
77
+ log.info " copying: #{ _rel_path to }"
78
+ _ensure_path to
79
+ FileUtils.cp_r from, to
80
+ else
81
+ log.info " unchanged: #{ _rel_path to }"
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ def _write(files)
88
+ files.each do |rendered_content, to|
89
+ event_block :write_file do
90
+ if _file_changed? rendered_content, to, true
91
+ log.info " writing: #{ _rel_path to }"
92
+ _ensure_path to
93
+ File.open to, 'w' do |f|
94
+ f.write rendered_content
95
+ end
96
+ else
97
+ log.info " unchanged: #{ _rel_path to }"
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ def _file_changed?(from, to, from_is_text=false)
104
+ return true if @options[:force]
105
+ return true if !File.exists? to
106
+ if @use_checksum
107
+ digest= from_is_text ? _checksum_for(from) : _checksum_for_file(from)
108
+ digest_to = _checksum_for_file to #@checksums[_rel_path to]
109
+ # puts "CHECKSUM #{digest_to} == #{digest} #{digest_to == digest}"
110
+ digest_to != digest
111
+ else
112
+ return true if from_is_text
113
+ !FileUtils.identical? from, to
114
+ end
115
+ end
116
+
117
+ def _ensure_path(to)
118
+ FileUtils.mkdir_p File.dirname(to)
119
+ end
120
+
121
+ def _checksum_for(string)
122
+ Digest::MD5.hexdigest( string )
123
+ end
124
+
125
+ def _checksum_for_file(path)
126
+ _checksum_for File.read( path )
127
+ end
128
+
129
+ def _rel_path(path)
130
+ path.gsub( site.output_path, '' )[1..-1]
131
+ end
132
+
133
+ def _exception_message(ex, short=false)
134
+ class_name= ex.class.to_s
135
+ backtrace= short ? ex.backtrace[0] : ex.backtrace
136
+ "{Exception: #{class_name}}\n#{[ex.to_s, backtrace].flatten.join("\n")}"
137
+ end
138
+
139
+ end
140
+
141
+ class << self
142
+
143
+ def build(opts={})
144
+ opts= opts.to_symbolized_hash
145
+ site.scan
146
+ Builder.new(opts).execute
147
+ end
148
+
149
+ def rebuild
150
+ site.scan true
151
+ Builder.new.execute
152
+ end
153
+
154
+ # Kicks off the build process!
155
+ def run(opts={})
156
+ opts= opts.to_symbolized_hash
157
+ site.options= opts
158
+ Gumdrop.build opts
159
+ end
160
+
161
+
162
+ end
163
+
164
+ end
@@ -10,7 +10,7 @@ module Gumdrop::CLI
10
10
  end
11
11
 
12
12
  desc 'new [NAME]', 'Create new gumdrop project'
13
- method_option :template, aliases:'-t', desc:'Template to start from', required:true
13
+ method_option :template, aliases:'-t', desc:'Template to start from', required:true, default:'default'
14
14
  def new(name)
15
15
  template= options[:template] || 'default'
16
16
 
@@ -36,20 +36,25 @@ module Gumdrop::CLI
36
36
  say " - #{File.basename name}" if File.directory?(name)
37
37
  end
38
38
  say "Local templates:"
39
- Dir[ home_template_path t].each do |name|
39
+ Dir[ home_template_path ].each do |name|
40
40
  say " - #{File.basename name}" if File.directory?(name)
41
41
  end
42
42
  end
43
43
 
44
- private
44
+ desc "version", "Displays Gumdrop version"
45
+ def version
46
+ say "Gumdrop v#{ Gumdrop::VERSION }"
47
+ end
45
48
 
46
- def gem_template_path(template='*')
47
- File.join(self.class.source_root, 'templates', template)
48
- end
49
+ private
49
50
 
50
- def home_template_path(template='*')
51
- File.expand_path File.join( "~", ".gumdrop", 'templates', template)
52
- end
51
+ def gem_template_path(template='*')
52
+ self.class.source_root / 'templates' / template
53
+ end
54
+
55
+ def home_template_path(template='*')
56
+ File.expand_path "~" / '.gumdrop' / 'templates' / template
57
+ end
53
58
 
54
59
  end
55
60
  end