Files changed (252) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +0 -38
  3. data/LICENSE.txt +0 -18
  4. data/Rakefile +0 -96
  5. data/awestruct.gemspec +0 -57
  6. data/lib/awestruct/astruct.rb +0 -30
  7. data/lib/awestruct/astruct_mixin.rb +0 -83
  8. data/lib/awestruct/cli/auto.rb +0 -104
  9. data/lib/awestruct/cli/deploy.rb +0 -44
  10. data/lib/awestruct/cli/generate.rb +0 -31
  11. data/lib/awestruct/cli/init.rb +0 -84
  12. data/lib/awestruct/cli/invoker.rb +0 -192
  13. data/lib/awestruct/cli/manifest.rb +0 -282
  14. data/lib/awestruct/cli/options.rb +0 -180
  15. data/lib/awestruct/cli/server.rb +0 -59
  16. data/lib/awestruct/compatibility.rb +0 -5
  17. data/lib/awestruct/config.rb +0 -57
  18. data/lib/awestruct/config/default-site.yml +0 -50
  19. data/lib/awestruct/context.rb +0 -40
  20. data/lib/awestruct/context_helper.rb +0 -76
  21. data/lib/awestruct/dependencies.rb +0 -201
  22. data/lib/awestruct/deploy/base_deploy.rb +0 -111
  23. data/lib/awestruct/deploy/github_pages_deploy.rb +0 -61
  24. data/lib/awestruct/deploy/rsync_deploy.rb +0 -62
  25. data/lib/awestruct/deploy/s3_deploy.rb +0 -61
  26. data/lib/awestruct/deployers.rb +0 -14
  27. data/lib/awestruct/engine.rb +0 -578
  28. data/lib/awestruct/extensions/assets.rb +0 -35
  29. data/lib/awestruct/extensions/atomizer.rb +0 -48
  30. data/lib/awestruct/extensions/cachebuster.rb +0 -15
  31. data/lib/awestruct/extensions/data_dir.rb +0 -31
  32. data/lib/awestruct/extensions/disqus.rb +0 -63
  33. data/lib/awestruct/extensions/extend_string.rb +0 -97
  34. data/lib/awestruct/extensions/flattr.rb +0 -42
  35. data/lib/awestruct/extensions/google_analytics.rb +0 -91
  36. data/lib/awestruct/extensions/gsub.rb +0 -34
  37. data/lib/awestruct/extensions/indexifier.rb +0 -21
  38. data/lib/awestruct/extensions/intense_debate.rb +0 -38
  39. data/lib/awestruct/extensions/minify.rb +0 -140
  40. data/lib/awestruct/extensions/obfuscate.rb +0 -42
  41. data/lib/awestruct/extensions/paginator.rb +0 -110
  42. data/lib/awestruct/extensions/partial.rb +0 -49
  43. data/lib/awestruct/extensions/pipeline.rb +0 -86
  44. data/lib/awestruct/extensions/posts.rb +0 -120
  45. data/lib/awestruct/extensions/relative.rb +0 -26
  46. data/lib/awestruct/extensions/remotePartial.rb +0 -41
  47. data/lib/awestruct/extensions/sitemap.rb +0 -101
  48. data/lib/awestruct/extensions/sitemap.xml.haml +0 -17
  49. data/lib/awestruct/extensions/tag_cloud.html.haml +0 -7
  50. data/lib/awestruct/extensions/tag_cloud.rb +0 -39
  51. data/lib/awestruct/extensions/tagger.rb +0 -109
  52. data/lib/awestruct/extensions/template.atom.haml +0 -42
  53. data/lib/awestruct/frameworks/960/base_layout.html.haml +0 -10
  54. data/lib/awestruct/frameworks/base_Gemfile +0 -60
  55. data/lib/awestruct/frameworks/base_Rakefile +0 -223
  56. data/lib/awestruct/frameworks/base_awestruct_ignore +0 -2
  57. data/lib/awestruct/frameworks/base_index.html.haml +0 -5
  58. data/lib/awestruct/frameworks/base_pipeline.rb +0 -7
  59. data/lib/awestruct/frameworks/base_site.yml +0 -4
  60. data/lib/awestruct/frameworks/blueprint/base_layout.html.haml +0 -12
  61. data/lib/awestruct/frameworks/bootstrap/base_index.html.haml +0 -29
  62. data/lib/awestruct/frameworks/bootstrap/base_layout.html.haml +0 -31
  63. data/lib/awestruct/frameworks/foundation/base_index.html.haml +0 -34
  64. data/lib/awestruct/frameworks/foundation/base_layout.html.haml +0 -58
  65. data/lib/awestruct/frameworks/foundation/humans.txt +0 -7
  66. data/lib/awestruct/handler_chain.rb +0 -27
  67. data/lib/awestruct/handler_chains.rb +0 -50
  68. data/lib/awestruct/handlers/asciidoctor_handler.rb +0 -154
  69. data/lib/awestruct/handlers/base_handler.rb +0 -114
  70. data/lib/awestruct/handlers/base_tilt_handler.rb +0 -158
  71. data/lib/awestruct/handlers/css_tilt_handler.rb +0 -44
  72. data/lib/awestruct/handlers/file_handler.rb +0 -65
  73. data/lib/awestruct/handlers/front_matter_handler.rb +0 -101
  74. data/lib/awestruct/handlers/interpolation_handler.rb +0 -34
  75. data/lib/awestruct/handlers/javascript_handler.rb +0 -46
  76. data/lib/awestruct/handlers/layout_handler.rb +0 -65
  77. data/lib/awestruct/handlers/no_op_handler.rb +0 -33
  78. data/lib/awestruct/handlers/page_delegating_handler.rb +0 -54
  79. data/lib/awestruct/handlers/redirect_handler.rb +0 -53
  80. data/lib/awestruct/handlers/string_handler.rb +0 -29
  81. data/lib/awestruct/handlers/template/asciidoc.rb +0 -69
  82. data/lib/awestruct/handlers/template/mustache.rb +0 -25
  83. data/lib/awestruct/handlers/template/sassc.rb +0 -21
  84. data/lib/awestruct/handlers/tilt_handler.rb +0 -74
  85. data/lib/awestruct/handlers/verbatim_file_handler.rb +0 -12
  86. data/lib/awestruct/handlers/yaml_handler.rb +0 -24
  87. data/lib/awestruct/layouts.rb +0 -14
  88. data/lib/awestruct/page.rb +0 -194
  89. data/lib/awestruct/page_loader.rb +0 -84
  90. data/lib/awestruct/pipeline.rb +0 -135
  91. data/lib/awestruct/rack/app.rb +0 -74
  92. data/lib/awestruct/rack/debug.rb +0 -141
  93. data/lib/awestruct/rack/generate.rb +0 -43
  94. data/lib/awestruct/rack/trace.html +0 -885
  95. data/lib/awestruct/scm/git.rb +0 -14
  96. data/lib/awestruct/site.rb +0 -53
  97. data/lib/awestruct/util/COPYING +0 -19
  98. data/lib/awestruct/util/default_inflections.rb +0 -45
  99. data/lib/awestruct/util/exception_helper.rb +0 -44
  100. data/lib/awestruct/util/inflector.rb +0 -242
  101. data/lib/awestruct/version.rb +0 -3
  102. data/man/awestruct.1 +0 -175
  103. data/man/awestruct.adoc +0 -135
  104. data/spec/awestruct/astruct_spec.rb +0 -59
  105. data/spec/awestruct/cli/init_spec.rb +0 -22
  106. data/spec/awestruct/cli/invoker_spec.rb +0 -87
  107. data/spec/awestruct/cli/options_spec.rb +0 -134
  108. data/spec/awestruct/cli/server_spec.rb +0 -15
  109. data/spec/awestruct/config_spec.rb +0 -28
  110. data/spec/awestruct/context_helper_spec.rb +0 -113
  111. data/spec/awestruct/deploy/base_deploy_spec.rb +0 -30
  112. data/spec/awestruct/deploy/deploy_spec.rb +0 -138
  113. data/spec/awestruct/deploy/github_pages_deploy_spec.rb +0 -69
  114. data/spec/awestruct/deploy/rsync_deploy_spec.rb +0 -9
  115. data/spec/awestruct/engine_spec.rb +0 -277
  116. data/spec/awestruct/extensions/disqus_spec.rb +0 -43
  117. data/spec/awestruct/extensions/minify_spec.rb +0 -63
  118. data/spec/awestruct/extensions/posts_spec.rb +0 -108
  119. data/spec/awestruct/extensions/relative_spec.rb +0 -22
  120. data/spec/awestruct/handler_chain_spec.rb +0 -43
  121. data/spec/awestruct/handler_chains_spec.rb +0 -25
  122. data/spec/awestruct/handlers/asciidoc_handler_spec.rb +0 -130
  123. data/spec/awestruct/handlers/coffeescript_handler_spec.rb +0 -21
  124. data/spec/awestruct/handlers/erb_handler_spec.rb +0 -52
  125. data/spec/awestruct/handlers/file_handler_spec.rb +0 -74
  126. data/spec/awestruct/handlers/front_matter_handler_spec.rb +0 -74
  127. data/spec/awestruct/handlers/haml_handler_spec.rb +0 -93
  128. data/spec/awestruct/handlers/interpolation_handler_spec.rb +0 -31
  129. data/spec/awestruct/handlers/javascript_handler_spec.rb +0 -23
  130. data/spec/awestruct/handlers/layout_handler_spec.rb +0 -77
  131. data/spec/awestruct/handlers/less_handler_spec.rb +0 -33
  132. data/spec/awestruct/handlers/markdown_handler_spec.rb +0 -39
  133. data/spec/awestruct/handlers/mustache_handler_spec.rb +0 -31
  134. data/spec/awestruct/handlers/orgmode_handler_spec.rb +0 -22
  135. data/spec/awestruct/handlers/page_delegating_handler_spec.rb +0 -77
  136. data/spec/awestruct/handlers/redirect_handler_spec.rb +0 -32
  137. data/spec/awestruct/handlers/sass_handler_spec.rb +0 -20
  138. data/spec/awestruct/handlers/scss_handler_spec.rb +0 -20
  139. data/spec/awestruct/handlers/slim_handler_spec.rb +0 -80
  140. data/spec/awestruct/handlers/textile_handler_spec.rb +0 -44
  141. data/spec/awestruct/handlers/tilt_handler_spec.rb +0 -145
  142. data/spec/awestruct/handlers/yaml_handler_spec.rb +0 -21
  143. data/spec/awestruct/layouts_spec.rb +0 -32
  144. data/spec/awestruct/page_loader_spec.rb +0 -95
  145. data/spec/awestruct/pipeline_spec.rb +0 -37
  146. data/spec/awestruct/rack/app_spec.rb +0 -61
  147. data/spec/awestruct/rack/debug_spec.rb +0 -92
  148. data/spec/awestruct/scm/git_spec.rb +0 -29
  149. data/spec/spec_helper.rb +0 -10
  150. data/spec/support/awestruct_setup.rb +0 -30
  151. data/spec/support/emmet_matchers.rb +0 -55
  152. data/spec/support/nokogiri_matchers.rb +0 -25
  153. data/spec/support/shared_handler_example.rb +0 -104
  154. data/spec/support/test-config/_config/site.yml +0 -1
  155. data/spec/support/test-data/.awestruct_ignore +0 -2
  156. data/spec/support/test-data/engine-compass/_config/arbitrary.yml +0 -2
  157. data/spec/support/test-data/engine-compass/_config/compass.rb +0 -4
  158. data/spec/support/test-data/engine-compass/_config/other.yml +0 -1
  159. data/spec/support/test-data/engine-compass/_config/site.yml +0 -26
  160. data/spec/support/test-data/engine-generate-no-errors/_config/site.yml +0 -26
  161. data/spec/support/test-data/engine-generate-no-errors/_ext/pipeline.rb +0 -8
  162. data/spec/support/test-data/engine-generate-no-errors/_layouts/base.html.slim +0 -6
  163. data/spec/support/test-data/engine-generate-no-errors/index.html.slim +0 -5
  164. data/spec/support/test-data/engine-generate-with-errors/_config/site.yml +0 -26
  165. data/spec/support/test-data/engine-generate-with-errors/_ext/pipeline.rb +0 -8
  166. data/spec/support/test-data/engine-generate-with-errors/_layouts/base.html.slim +0 -6
  167. data/spec/support/test-data/engine-generate-with-errors/index.html.slim +0 -6
  168. data/spec/support/test-data/engine-yaml/_config/site.yml +0 -9
  169. data/spec/support/test-data/engine/_config/arbitrary.yml +0 -2
  170. data/spec/support/test-data/engine/_config/other.yml +0 -1
  171. data/spec/support/test-data/engine/_config/site.yml +0 -26
  172. data/spec/support/test-data/front-matter-empty.txt +0 -3
  173. data/spec/support/test-data/front-matter-file-no-content.txt +0 -3
  174. data/spec/support/test-data/front-matter-file-no-front.txt +0 -1
  175. data/spec/support/test-data/front-matter-file-utf8.txt +0 -5
  176. data/spec/support/test-data/front-matter-file.txt +0 -4
  177. data/spec/support/test-data/front-matter-looking.txt +0 -9
  178. data/spec/support/test-data/front-matter-middle.txt +0 -12
  179. data/spec/support/test-data/gzip/no.html.gz +0 -0
  180. data/spec/support/test-data/gzip/no.txt +0 -0
  181. data/spec/support/test-data/gzip/subdir/yes.css +0 -3
  182. data/spec/support/test-data/gzip/yes.html +0 -10
  183. data/spec/support/test-data/gzip/yes.js +0 -1
  184. data/spec/support/test-data/handlers/asciidoc-page.ad +0 -3
  185. data/spec/support/test-data/handlers/asciidoc-page.adoc +0 -3
  186. data/spec/support/test-data/handlers/asciidoc-page.asciidoc +0 -3
  187. data/spec/support/test-data/handlers/asciidoc_with_attributes.ad +0 -3
  188. data/spec/support/test-data/handlers/asciidoc_with_interpolation.ad +0 -4
  189. data/spec/support/test-data/handlers/asciidoc_without_interpolation.ad +0 -3
  190. data/spec/support/test-data/handlers/asciidoctor_with_front_matter.ad +0 -6
  191. data/spec/support/test-data/handlers/asciidoctor_with_headers.ad +0 -12
  192. data/spec/support/test-data/handlers/coffeescript-page.coffee +0 -8
  193. data/spec/support/test-data/handlers/empty-layout.haml +0 -1
  194. data/spec/support/test-data/handlers/erb-page.html.erb +0 -6
  195. data/spec/support/test-data/handlers/erb-page.xml.erb +0 -2
  196. data/spec/support/test-data/handlers/erb-utf-page.html.erb +0 -2
  197. data/spec/support/test-data/handlers/haml-error.html.haml +0 -4
  198. data/spec/support/test-data/handlers/haml-layout-two.html.haml +0 -7
  199. data/spec/support/test-data/handlers/haml-layout.html.haml +0 -4
  200. data/spec/support/test-data/handlers/haml-page.atom.haml +0 -4
  201. data/spec/support/test-data/handlers/haml-page.html.haml +0 -2
  202. data/spec/support/test-data/handlers/haml-page.xml.haml +0 -1
  203. data/spec/support/test-data/handlers/haml-with-markdown-page.html.haml +0 -6
  204. data/spec/support/test-data/handlers/haml-with-textile-page.html.haml +0 -6
  205. data/spec/support/test-data/handlers/haml-with-utf.html.haml +0 -2
  206. data/spec/support/test-data/handlers/haml-with-variables.html.haml +0 -2
  207. data/spec/support/test-data/handlers/hello.bogus +0 -1
  208. data/spec/support/test-data/handlers/inner-page.html.haml +0 -4
  209. data/spec/support/test-data/handlers/javascript-page.js +0 -1
  210. data/spec/support/test-data/handlers/less-page-include.less +0 -1
  211. data/spec/support/test-data/handlers/less-page-with-import.less +0 -4
  212. data/spec/support/test-data/handlers/less-page.less +0 -4
  213. data/spec/support/test-data/handlers/markdown-page.markdown +0 -2
  214. data/spec/support/test-data/handlers/markdown-page.md +0 -2
  215. data/spec/support/test-data/handlers/markdown-page.mkd +0 -2
  216. data/spec/support/test-data/handlers/mustache-page.html.mustache +0 -2
  217. data/spec/support/test-data/handlers/mustache-page.xml.mustache +0 -1
  218. data/spec/support/test-data/handlers/orgmode-page.org +0 -6
  219. data/spec/support/test-data/handlers/outer-layout.html.haml +0 -2
  220. data/spec/support/test-data/handlers/outside_relative/git_keep +0 -3
  221. data/spec/support/test-data/handlers/redirect-page.redirect +0 -1
  222. data/spec/support/test-data/handlers/restructuredtext-page.rst +0 -8
  223. data/spec/support/test-data/handlers/sass-page-include.sass +0 -1
  224. data/spec/support/test-data/handlers/sass-page.sass +0 -4
  225. data/spec/support/test-data/handlers/scss-page-include.scss +0 -1
  226. data/spec/support/test-data/handlers/scss-page.scss +0 -5
  227. data/spec/support/test-data/handlers/simple-redirect-page.redirect +0 -1
  228. data/spec/support/test-data/handlers/slim-page.atom.slim +0 -4
  229. data/spec/support/test-data/handlers/slim-page.html.slim +0 -1
  230. data/spec/support/test-data/handlers/slim-page.xml.slim +0 -1
  231. data/spec/support/test-data/handlers/slim-with-markdown-page.html.slim +0 -5
  232. data/spec/support/test-data/handlers/slim-with-utf.html.slim +0 -2
  233. data/spec/support/test-data/handlers/slim-with-variables.html.slim +0 -1
  234. data/spec/support/test-data/handlers/textile-empty-page.textile +0 -0
  235. data/spec/support/test-data/handlers/textile-page.textile +0 -3
  236. data/spec/support/test-data/images/logo.png +0 -0
  237. data/spec/support/test-data/index.html +0 -242
  238. data/spec/support/test-data/javascript/bootstrap-dropdown.js +0 -92
  239. data/spec/support/test-data/out-of-site/page-three.html.haml +0 -2
  240. data/spec/support/test-data/page-loader/.awestruct_ignore +0 -2
  241. data/spec/support/test-data/page-loader/_layouts/layout-one.md +0 -2
  242. data/spec/support/test-data/page-loader/_layouts/layout-two.html.haml +0 -2
  243. data/spec/support/test-data/page-loader/page-draft.md +0 -5
  244. data/spec/support/test-data/page-loader/page-one.md +0 -2
  245. data/spec/support/test-data/page-loader/page-two.html.haml +0 -2
  246. data/spec/support/test-data/pipeline/_ext/extensions.rb +0 -26
  247. data/spec/support/test-data/pipeline/_ext/pipeline.rb +0 -12
  248. data/spec/support/test-data/simple-data.yaml +0 -1
  249. data/spec/support/test-data/simple-file.txt +0 -1
  250. data/spec/support/test-data/stylesheets/screen.css +0 -688
  251. data/spec/support/test-data/subdir/index.html +0 -10
  252. metadata +3 -298
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
- SHA1:
3
- metadata.gz: 6c6be05537489d0dde74527315af3f2490df09a9
4
- data.tar.gz: ac53c8b5c359f8214743bddab97e0af09fbe13da
2
+ SHA256:
3
+ metadata.gz: b2fe39f0f5a9a59d12d893e49576ba97bd371c5a4c8333d76300ba8d5ca51ff6
4
+ data.tar.gz: 56903022c6889b1cf2626748fa86d6f84d76383ae6de173394cd8471399b392f
5
5
SHA512:
6
- metadata.gz: 3aef7394e9c084710473ad3537f3ce9b0211e9defa04174341d4c14010c1a71bd1ece132c28516a0e8bc09e88aa53778d46a200c9782cd08e7b94b96bec3e6ed
7
- data.tar.gz: 36508eb8d76bf9c6c94306242ffe822affadebae953490d683241595946c48e152899084405fcbed6efa8034f12f270c8ebd8b468e664b20680ad2b5401df439
6
+ metadata.gz: 7ee2c1afc4ac81277f2a840ab228153434a8aabe3ac82e5f0ef44628fb028fbfea2983e899385922ba2491ec5b58e036b8b10cce386643de782182c1ad4c4418
7
+ data.tar.gz: e48abe2be6fb9acb8a2e3e5755c22a868a62857dc598ac839ad6b385392c598a55bdee7c5480d283dc98dbfdee60e1b8846d55d56946b8c3e965bbabd98a2e8f
data/Gemfile DELETED
@@ -1,38 +0,0 @@
1
- source 'https://rubygems.org'
2
- ruby '~> 2.4.0'
3
-
4
- group :development do
5
- gem 'hashery', '~> 2.1.1'
6
- gem 'pry', :require => false
7
- gem 'rake', :require => false
8
- #gem 'pry-byebug', :require => false
9
- end
10
-
11
- group :test do
12
- gem 'rb-inotify', '~> 0.9.3'
13
- gem 'rack-test', '~> 0.6.2'
14
- gem 'tilt', '~> 2.0.1'
15
- gem 'coffee-script', '~> 2.2.0'
16
- gem 'asciidoctor', '1.5.2'
17
- gem 'compass', '>= 1.0.1'
18
- gem 'sassc', '~> 1.6'
19
- gem 'slim', '~> 3.0'
20
- gem 'kramdown', '~> 1.3.3'
21
- gem 'therubyracer', '~> 0.12.1', :platforms => :ruby
22
- gem 'therubyrhino', '~> 2.0.3', :platforms => :jruby
23
- gem 'less', '~> 2.5.0'
24
- gem 'org-ruby', '~> 0.9.3'
25
- gem 'RedCloth', '~> 4.2.9'
26
- gem 'mustache', '~> 0.99.5'
27
- gem 'uglifier', '~> 2.5.0'
28
- gem 'htmlcompressor', '~> 0.0.7'
29
- gem 'haml-contrib', '~> 1.0.0'
30
- gem 'sass'
31
- gem 'bootstrap-sass'
32
- gem 'zurb-foundation'
33
- gem 'rspec'
34
- gem 'rspec_runner'
35
- gem "win32-open3-19", :platforms => :mingw # htmlcompressor depends on old yui compressor, that needs this on win32
36
- end
37
-
38
- gemspec
data/LICENSE.txt DELETED
@@ -1,18 +0,0 @@
1
- Copyright (c) 2010-2014 Bob McWhirter and contributors (see git log)
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to
5
- deal in the Software without restriction, including without limitation the
6
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- sell copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
- THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,96 +0,0 @@
1
- require 'rubygems'
2
- require 'date'
3
- require 'bundler/setup'
4
- require 'rspec/core/rake_task'
5
-
6
- def gem_name
7
- @gem_name ||= Dir['*.gemspec'].first.split('.').first
8
- end
9
-
10
- def gem_version
11
- line = File.read("lib/#{gem_name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
12
- line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
13
- end
14
-
15
- def date
16
- Date.today.to_s
17
- end
18
-
19
- def gemspec_file
20
- "#{gem_name}.gemspec"
21
- end
22
-
23
- def gem_file
24
- "#{gem_name}-#{gem_version}.gem"
25
- end
26
-
27
- def version_tag
28
- "v#{gem_version}"
29
- end
30
-
31
- def replace_header(head, header_name)
32
- head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
33
- end
34
-
35
- task :default => :build
36
-
37
- if !defined?(RSpec)
38
- puts 'spec targets require RSpec'
39
- else
40
- desc 'Run all specs'
41
- RSpec::Core::RakeTask.new(:spec) do |t|
42
- t.pattern = 'spec/**/*_spec.rb'
43
- t.rspec_opts = ['-c']
44
- end
45
- end
46
-
47
- desc "Run all specs and build #{gem_file} into the pkg directory"
48
- task :build => [:spec, :gemspec] do
49
- sh "gem build #{gemspec_file}"
50
- sh 'mkdir -p pkg'
51
- sh "mv #{gem_file} pkg"
52
- end
53
-
54
- desc "Build #{gem_file} and install it locally"
55
- task :install => :build do
56
- sh "gem install -l -f pkg/#{gem_file}"
57
- end
58
-
59
- desc "Update #{gemspec_file}"
60
- task :gemspec do
61
- spec = File.read(gemspec_file)
62
-
63
- # replace name version and date
64
- replace_header(spec, :gem_name)
65
- replace_header(spec, :date)
66
-
67
- File.open(gemspec_file, 'w') { |io| io.write spec }
68
- puts "Updated #{gemspec_file}"
69
- end
70
-
71
- desc "Create tag #{version_tag} and push repository to origin"
72
- task :tag do
73
- unless `git branch` =~ / master#x2F;
74
- puts 'You must be on the master branch to release!'
75
- exit!
76
- end
77
- if version_tag.end_with?('.dev')
78
- puts 'You cannot tag and release a dev version!'
79
- exit!
80
- end
81
-
82
- if `git tag`.split(/\n/).include?(version_tag)
83
- puts "Tag #{version_tag} has already been created."
84
- else
85
- sh "git commit --allow-empty -a -m 'Release #{gem_version}'"
86
- sh 'git push origin master'
87
- sh "git tag #{version_tag}"
88
- sh "git push origin #{version_tag}"
89
- end
90
- end
91
-
92
- desc "Build #{gem_file}, create and push tag #{version_tag} and publish gem to RubyGems.org"
93
- task :release => [ :build, :tag ] do
94
- sh "gem push pkg/#{gem_file}"
95
- end
96
-
data/awestruct.gemspec DELETED
@@ -1,57 +0,0 @@
1
- $:.push File.expand_path('../lib', __FILE__)
2
- require 'awestruct/version'
3
-
4
- spec = Gem::Specification.new do |s|
5
- s.name = 'awestruct'
6
- s.version = Awestruct::VERSION
7
- s.date = '2018-03-24'
8
-
9
- s.authors = ['Bob McWhirter', 'Jason Porter', 'Lance Ball', 'Dan Allen', 'Torsten Curdt', 'other contributors']
10
- s.email = ['bob@mcwhirter.org', 'lightguard.jp@gmail.com', 'lball@redhat.com', 'dan.j.allen@gmail.com', 'tcurdt@vafer.org']
11
- s.homepage = 'http://awestruct.org'
12
- s.summary = 'Static site baking and publishing tool'
13
- s.description = 'Awestruct is a static site baking and publishing tool. It supports an extensive list of both templating and markup languages via Tilt (Haml, Slim, AsciiDoc, Markdown, Sass via Compass, etc), provides mobile-first layout and styling via Bootstrap or Foundation, offers a variety of deployment options (rsync, git, S3), handles site optimizations (minification, compression, cache busting), includes built-in extensions such as blog post management and is highly extensible.'
14
-
15
- s.rubyforge_project = s.name
16
-
17
- s.license = 'MIT'
18
-
19
- s.platform = Gem::Platform::RUBY
20
- s.required_ruby_version = '>= 2.4.0'
21
-
22
- s.has_rdoc = true
23
- s.rdoc_options = ['--charset=UTF-8']
24
- s.extra_rdoc_files = 'README.md'
25
-
26
- s.files = `git ls-files -z -- {lib,man,spec}/* {README,LICENSE}* *{.gemspec,file}`.split("\0")
27
- s.test_files = s.files.select { |path| path =~ /^spec\/.*_spec\.rb/ }
28
- s.executables = `git ls-files -z -- bin/*`.split("\0").map {|f| File.basename f }
29
- s.require_paths = ['lib']
30
-
31
- s.requirements = <<-EOS
32
- Any markup languages you are using and its dependencies.
33
- Haml and Markdown filters are touchy things. Redcarpet or Rdiscount work well if you're running on MRI. JRuby should be using haml 4.0.0+ with Kramdown.
34
- Compass and sass are no longer hard dependencies. You'll need too add them on your own should you want them. We also should be able to work with sassc.
35
- EOS
36
-
37
- s.add_dependency 'haml', '>= 4.0.5', '< 6.0'
38
- s.add_dependency 'asciidoctor', '~> 1.5', '>= 1.5.2'
39
- s.add_dependency 'tilt', '~> 2.0', '>= 2.0.1'
40
- s.add_dependency 'mime-types', '~> 3.0'
41
- s.add_dependency 'rest-client', '~> 2.0'
42
- s.add_dependency 'listen', '~> 3.1'
43
- s.add_dependency 'rack', '~> 2.0'
44
- s.add_dependency 'git', '~> 1.2', '>= 1.2.6'
45
- s.add_dependency 'guard', '~> 2.0', '>= 2.13.0'
46
- s.add_dependency 'guard-livereload', '~> 2.0', '>= 2.1.2'
47
- s.add_dependency 'logging', '~> 2.2'
48
- s.add_dependency 'oga', '~> 2.0'
49
- s.add_dependency 'parallel', '~> 1.0', '> 1.1.1'
50
-
51
- s.add_development_dependency 'nokogiri', '>= 1.5.10'
52
- s.add_development_dependency 'compass-960-plugin', '~> 0.10','>= 0.10.4'
53
- s.add_development_dependency 'bootstrap-sass', '>= 3.2.0.2'
54
- s.add_development_dependency 'zurb-foundation', '>= 4.3.2'
55
- s.add_development_dependency 'rspec', '>= 3.0'
56
- s.add_development_dependency 'guard-rspec', '>= 4.0'
57
- end
data/lib/awestruct/astruct.rb DELETED
@@ -1,30 +0,0 @@
1
- require 'awestruct/astruct_mixin'
2
-
3
- module Awestruct
4
-
5
- class AStruct < Hash
6
-
7
- include AStructMixin
8
-
9
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
10
- undef org, com, java, javax, javafx # Issue #480
11
- end
12
-
13
- def initialize(hash=nil)
14
- hash.each{|k,v| self[k]=v } if hash
15
- end
16
-
17
- alias_method :original_entries, :entries
18
- undef entries
19
-
20
- def inspect
21
- "AStruct{...}"
22
- end
23
-
24
- def hash()
25
- self.output_path.hash
26
- end
27
-
28
- end
29
-
30
- end
data/lib/awestruct/astruct_mixin.rb DELETED
@@ -1,83 +0,0 @@
1
- require 'awestruct/dependencies'
2
-
3
- module Awestruct
4
-
5
- module AStructMixin
6
-
7
- def self.extended(o)
8
- class << o
9
- alias_method :original_entries, :entries
10
- undef entries
11
- end
12
- end
13
-
14
- def cascade_for_nils!
15
- @cascade_for_nils = true
16
- self
17
- end
18
-
19
- def key?(key)
20
- super( key ) || super( key.to_sym ) || super( key.to_s )
21
- end
22
-
23
- def [](key)
24
- r = [key, key.to_sym, key.to_s].find { |fk| !super(fk).nil? }
25
- transform_entry( key, super(r) )
26
- end
27
-
28
- def method_missing(sym, *args, &blk)
29
- type = sym.to_s[-1,1]
30
- name = sym.to_s.gsub(/[=!?]#x2F;, '').to_sym
31
- case type
32
- when '='
33
- self[name] = args.first
34
- when '!'
35
- __send__(name, *args, &blk)
36
- when '?'
37
- self[name]
38
- else
39
- if key?(name)
40
- self[name]
41
- elsif @cascade_for_nils
42
- self[name] = AStruct.new.cascade_for_nils!
43
- self[name]
44
- else
45
- unless args.size.zero?
46
- $LOG.warn "Call to unknown method: #{name}"
47
- end
48
- nil
49
- end
50
- end
51
- end
52
-
53
- UNTRACKED_KEYS = [
54
- :url,
55
- ]
56
-
57
- def transform_entry(for_key, entry)
58
- r = case(entry)
59
- when AStructMixin
60
- entry
61
- when Hash
62
- #AStruct.new( entry )
63
- entry.extend( AStructMixin )
64
- when Array
65
- entry.map!{|i| transform_entry( for_key, i)}
66
- else
67
- entry
68
- end
69
- if ( self.is_a? Awestruct::Page )
70
- unless UNTRACKED_KEYS.include? for_key.to_sym
71
- Awestruct::Dependencies.track_key_dependency( self, for_key )
72
- end
73
- end
74
- r
75
- end
76
-
77
- def inspect
78
- "AStruct<#{super.to_s}>"
79
- end
80
-
81
- end
82
-
83
- end
data/lib/awestruct/cli/auto.rb DELETED
@@ -1,104 +0,0 @@
1
- require 'awestruct/util/exception_helper'
2
-
3
- require 'listen'
4
- require 'guard'
5
- require 'guard/livereload'
6
-
7
- module Awestruct
8
- module CLI
9
- class Auto
10
-
11
- def initialize(config, base_url)
12
- @config = config
13
- @base_url = base_url
14
- end
15
-
16
- def run()
17
- generate_thread = nil
18
- current_path = nil
19
-
20
- begin
21
- guard = if ( @config.options.livereload )
22
- Guard.init({})
23
- guard = Guard::LiveReload.new
24
- guard.start
25
- guard
26
- else
27
- nil
28
- end
29
- rescue => e
30
- puts e
31
- puts e.backtrace
32
- end
33
-
34
- force_polling = ( RUBY_PLATFORM =~ /mingw/ ? true : false )
35
- listener = Listen.to( @config.dir, :latency=>0.5, :force_polling=>force_polling ) do |modified, added, removed|
36
- modified.each do |path| # path is absolute path
37
- engine = ::Awestruct::Engine.instance
38
-
39
- begin
40
- $LOG.info "Change detected for file #{path}" if $LOG.info?
41
- if path.eql? current_path
42
- unless generate_thread.nil?
43
- $LOG.info "Same path triggered, stopping previous generation" if generate_thread.alive? && $LOG.info?
44
- generate_thread.kill
45
- end
46
- else
47
- generate_thread.join unless generate_thread.nil?
48
- current_path = path
49
- end
50
-
51
- generate_thread = Thread.new {
52
- begin
53
- page = engine.page_by_source_path(path)
54
- pages = []
55
- if ( page )
56
- unless ( guard )
57
- pages = engine.generate_page_and_dependencies( page )
58
- else
59
- pages = engine.page_dependencies( page )
60
- end
61
- else
62
- if File.exist? path
63
- # chances are this is an extension or yaml file
64
- pages = engine.run_auto_for_non_page(path, !@config.options.generate_on_access)
65
- end
66
- end
67
-
68
- unless ( guard )
69
- $LOG.info "Regeneration finished." if $LOG.info?
70
- end
71
-
72
- if ( guard )
73
- urls = pages.map do |p|
74
- @base_url + p.url.to_s
75
- end
76
-
77
- guard.run_on_modifications(urls)
78
- end
79
-
80
- rescue => e
81
- ExceptionHelper.log_building_error e, path
82
- end
83
- }
84
- rescue => e
85
- ExceptionHelper.log_building_error e, path
86
- end
87
- end
88
- end
89
- listener.ignore( %r(\.awestruct) )
90
- listener.ignore( %r(^#{File.basename( @config.tmp_dir )}) )
91
- listener.ignore( %r(\.sass-cache) )
92
- listener.ignore( %r(^#{File.basename( @config.output_dir )}) )
93
-
94
- @config.ignore.each do |i|
95
- listener.ignore( %r(^#{i}) )
96
- end
97
-
98
- listener.start
99
- end
100
-
101
- end
102
-
103
- end
104
- end
data/lib/awestruct/cli/deploy.rb DELETED
@@ -1,44 +0,0 @@
1
- require 'awestruct/deploy/s3_deploy'
2
- require 'awestruct/deploy/rsync_deploy'
3
- require 'awestruct/deploy/github_pages_deploy'
4
-
5
- module Awestruct
6
- module CLI
7
-
8
- class Deploy
9
-
10
- attr_accessor :site_config
11
- attr_accessor :deploy_config
12
-
13
- def initialize(site_config, deploy_config)
14
- @site_config = site_config
15
- @deploy_config = deploy_config
16
- @deploy_config['type'] ||= (is_github? ? :github_pages : :rsync)
17
- $LOG.info "Deploying to #{deploy_type}" if $LOG.info?
18
- end
19
-
20
- def deploy_type
21
- deploy_config['type']
22
- end
23
-
24
- def run()
25
- deployer_class = Awestruct::Deployers.instance[ deploy_type.to_sym ]
26
-
27
- if ( deployer_class.nil? )
28
- $LOG.error "Unable to locate correct deployer for #{deploy_type}" if $LOG.error?
29
- $LOG.error "Deployers available for #{::Awestruct::Deployers.instance.collect {|k,v| "#{v} (#{k})"}.join(', ')}" if $LOG.error?
30
- return
31
- end
32
-
33
- deployer = deployer_class.new( site_config, deploy_config )
34
- deployer.run
35
- end
36
-
37
- private
38
- def is_github?
39
- deploy_config['host'].to_s == 'github_pages' || deploy_config['host'].to_s == 'github_pages'
40
- end
41
- end
42
-
43
- end
44
- end
data/lib/awestruct/cli/generate.rb DELETED
@@ -1,31 +0,0 @@
1
- require 'awestruct/engine'
2
- require 'awestruct/util/exception_helper'
3
-
4
- module Awestruct
5
- module CLI
6
- class Generate
7
-
8
- def initialize(config, profile=nil, base_url=nil, default_base_url=Options::DEFAULT_BASE_URL, force=false, generate=true)
9
- @profile = profile
10
- @base_url = base_url
11
- @default_base_url = default_base_url
12
- @force = force
13
- @generate = generate
14
- @engine = Awestruct::Engine.new( config )
15
- end
16
-
17
- def run()
18
- begin
19
- base_url = @base_url || @default_base_url
20
- $LOG.info "Generating site: #{base_url}" if $LOG.info?
21
- start_time = DateTime.now
22
- @engine.run( @profile, @base_url, @default_base_url, @force, @generate )
23
- $LOG.trace "Total time in engine.run #{DateTime.now.to_time - start_time.to_time} seconds"
24
- rescue =>e
25
- ExceptionHelper.log_building_error e, ''
26
- return false
27
- end
28
- end
29
- end
30
- end
31
- end
data/lib/awestruct/cli/init.rb DELETED
@@ -1,84 +0,0 @@
1
- require 'awestruct/cli/manifest'
2
- require 'awestruct/cli/options'
3
-
4
- module Awestruct
5
- module CLI
6
- class Init
7
-
8
- def self.framework_path(path, framework = nil)
9
- File.join [File.dirname(__FILE__), '..', 'frameworks', framework, path].compact
10
- end
11
-
12
- BASE_MANIFEST = Manifest.new {
13
- mkdir('_config')
14
- mkdir('_layouts')
15
- mkdir('_ext')
16
- copy_file('_ext/pipeline.rb', Init.framework_path('base_pipeline.rb'))
17
- copy_file('.awestruct_ignore', Init.framework_path('base_awestruct_ignore'))
18
- copy_file('Rakefile', Init.framework_path('base_Rakefile'))
19
- mkdir('stylesheets')
20
- }
21
-
22
- def initialize(dir = Dir.pwd, framework = 'compass', scaffold = true)
23
- @dir = dir
24
- @framework = framework
25
- @scaffold = scaffold
26
- end
27
-
28
- def run()
29
- manifest = Manifest.new(BASE_MANIFEST)
30
- scaffold_name = @framework
31
- manifest.template_file('Gemfile', Init.framework_path('base_Gemfile'), {:framework => @framework})
32
-
33
- lib = nil
34
- case @framework
35
- when 'bootstrap'
36
- lib = 'bootstrap-sass'
37
- when 'foundation'
38
- lib = 'zurb-foundation'
39
- end
40
- unless lib.nil?
41
- require 'sass/callbacks'
42
- require 'compass'
43
- require 'compass/commands'
44
- require lib
45
- manifest.install_compass(@framework, lib)
46
- end
47
- if (@scaffold)
48
- manifest.copy_file('_config/site.yml', framework_path('base_site.yml'), :overwrite => true)
49
- manifest.copy_file('_layouts/base.html.haml', framework_path('base_layout.html.haml', scaffold_name))
50
- base_index = framework_path('base_index.html.haml', scaffold_name)
51
- if File.file? base_index
52
- manifest.copy_file('index.html.haml', base_index)
53
- else
54
- manifest.copy_file('index.html.haml', framework_path('base_index.html.haml'))
55
- end
56
-
57
- humans_txt = framework_path('humans.txt')
58
- if File.file? humans_txt
59
- manifest.copy_file('humans.txt', humans_txt, :overwrite => true)
60
- end
61
-
62
- manifest.touch_file('_config/site.yml')
63
- manifest.add_requires('_ext/pipeline.rb', [lib]) unless lib.nil?
64
- if scaffold_name == 'foundation'
65
- manifest.remove_file('index.html')
66
- manifest.remove_file('MIT-LICENSE.txt')
67
- end
68
- end
69
- begin
70
- manifest.perform(@dir)
71
- rescue => e
72
- puts e.backtrace
73
- puts e.message
74
- puts manifest.steps
75
- end
76
- end
77
-
78
- def framework_path(path, framework = nil)
79
- Init.framework_path path, framework
80
- end
81
-
82
- end
83
- end
84
- end
data/lib/awestruct/cli/invoker.rb DELETED
@@ -1,192 +0,0 @@
1
- require 'pathname'
2
- require 'logging'
3
- require 'awestruct/cli/options'
4
- require 'awestruct/util/exception_helper'
5
- require 'erb'
6
-
7
- module Awestruct
8
- module CLI
9
- class Invoker
10
-
11
- attr_reader :options
12
-
13
- attr_reader :config
14
- attr_reader :profile
15
- attr_reader :success
16
-
17
- def initialize(*options)
18
- options = options.flatten
19
- if (!options.empty?) && (options.first === Awestruct::CLI::Options)
20
- @options = options.first
21
- else
22
- @options = Awestruct::CLI::Options.parse! options
23
- end
24
- @threads = []
25
- @profile = nil
26
- @success = true
27
- logging_path = Pathname.new File.join(@options.source_dir, '.awestruct')
28
- logging_path.mkpath unless logging_path.exist?
29
-
30
- Logging.init :trace, :debug, :verbose, :info, :warn, :error, :fatal
31
- $LOG = Logging.logger.new 'awestruct'
32
- $LOG.add_appenders(
33
- Logging.appenders.stdout({level: (@options.verbose ? :verbose : :info),
34
- layout: Logging.layouts.pattern(pattern: "%m\n", format_as: :string),
35
- color_scheme: :default}),
36
- Logging.appenders.file('error', {filename: File.join(logging_path, 'error.log'),
37
- layout: Logging.layouts.parseable.json(format_as: :string),
38
- truncate: true, level: :error})
39
- )
40
-
41
- if @options.debug
42
- $LOG.add_appenders(
43
- Logging.appenders.file('debug', {filename: File.join(logging_path, 'debug.log'),
44
- layout: Logging.layouts.parseable.json(format_as: :string),
45
- truncate: true, level: :debug})
46
- )
47
- end
48
-
49
- if @options.perf_log
50
- $LOG.add_appenders(
51
- Logging.appenders.file('perf', {filename: File.join(logging_path, 'perf.log'),
52
- truncate: true, level: :trace,
53
- layout: Logging.layouts.parseable.json(format_as: :string),
54
- filters: Logging::Filters::Level.new(:trace)})
55
- )
56
- end
57
-
58
- # these requires are deferred until after $LOG is set
59
- require 'awestruct/cli/init'
60
- require 'awestruct/cli/generate'
61
- require 'awestruct/cli/auto'
62
- require 'awestruct/cli/server'
63
- end
64
-
65
- def invoke!
66
- begin
67
- load_profile() unless ( options.init )
68
-
69
- setup_config()
70
-
71
- invoke_init() if ( options.init )
72
- invoke_script() if ( options.script )
73
- invoke_force() if ( options.force )
74
- invoke_generate() if ( options.generate )
75
- invoke_deploy() if ( options.deploy )
76
- invoke_server() if ( options.server )
77
- invoke_auto() if ( options.auto )
78
-
79
- wait_for_completion()
80
-
81
- if ExceptionHelper.build_failed? || @success == false
82
- @success = false
83
- false
84
- else
85
- true
86
- end
87
- rescue
88
- @success = false
89
- false
90
- end
91
- end
92
-
93
- def load_profile()
94
- site_yaml_file = File.join( @options.source_dir, '_config', 'site.yml' )
95
-
96
- if ( !File.exist?( site_yaml_file ) )
97
- abort( "No config file at #{site_yaml_file}" )
98
- end
99
-
100
- site_yaml = YAML.load( ERB.new(File.read( site_yaml_file ), nil, '<>').result )
101
-
102
- if ( !site_yaml )
103
- abort( "Failed to parse #{site_yaml_file}" )
104
- end
105
-
106
- profiles = site_yaml['profiles'] || {}
107
-
108
- profile_name = options.profile
109
-
110
- # use the one specified
111
- profile = profiles[profile_name]
112
- if ( !profile )
113
- profile_name, profile = if ( options.deploy )
114
- # or the first one having a deploy section
115
- profiles.select { |k,v| v && v['deploy'] }
116
- else
117
- # or the first one having no deploy section
118
- profiles.select { |k,v| v && !v['deploy'] }
119
- end.first
120
- end
121
-
122
- if profile
123
- $LOG.info "Using profile: #{profile_name}" if $LOG.info?
124
- end
125
-
126
- @profile = profile || {}
127
- end
128
-
129
- def setup_config()
130
- @config = Awestruct::Config.new( @options )
131
- @config.track_dependencies = true if ( @options.auto )
132
- @config.verbose = true if ( @options.verbose )
133
- @config.debug = @options.debug
134
- @config.quiet = true if @options.quiet
135
- @config.perf = true if @options.perf_log
136
- end
137
-
138
- def invoke_init()
139
- Awestruct::CLI::Init.new( @options.source_dir, @options.framework, @options.scaffold ).run
140
- end
141
-
142
- def invoke_script()
143
- end
144
-
145
- def invoke_force()
146
- FileUtils.rm_rf( File.join( config.dir, '.awestruct', 'dependency-cache' ) )
147
- FileUtils.rm_rf( config.output_dir )
148
- end
149
-
150
- def invoke_generate()
151
- base_url = profile['base_url'] || options.base_url
152
- @success = Awestruct::CLI::Generate.new( config, options.profile, base_url, Options::DEFAULT_BASE_URL, options.force, !options.generate_on_access ).run
153
- end
154
-
155
- def invoke_deploy()
156
- require 'awestruct/cli/deploy'
157
-
158
- deploy_config = profile[ 'deploy' ]
159
-
160
- if ( deploy_config.nil? )
161
- $LOG.error "No configuration for 'deploy'" if $LOG.error?
162
- return
163
- end
164
-
165
- Awestruct::CLI::Deploy.new( config, deploy_config ).run
166
- end
167
-
168
- def invoke_auto()
169
- base_url = profile['base_url'] || options.base_url
170
- Awestruct::CLI::Auto.new( config, base_url ).run
171
- end
172
-
173
- def invoke_server()
174
- run_in_thread( Awestruct::CLI::Server.new( options.output_dir, options.bind_addr, options.port, options.generate_on_access ) )
175
- end
176
-
177
-
178
- private
179
-
180
- def run_in_thread(command)
181
- @threads << Thread.new(command){|c| c.run}
182
- end
183
-
184
- def wait_for_completion()
185
- @threads.each do |thr|
186
- thr.join
187
- end
188
- end
189
-
190
- end
191
- end
192
- end
data/lib/awestruct/cli/manifest.rb DELETED
@@ -1,282 +0,0 @@
1
- require 'erb'
2
- require 'rubygems/specification'
3
- require 'ostruct'
4
-
5
- # TODO: We could create our own installer and use that
6
-
7
- module Awestruct
8
- module CLI
9
- #noinspection RubyResolve
10
- class Manifest
11
-
12
- attr_reader :parent
13
- attr_reader :steps
14
-
15
- def initialize(parent=nil, &block)
16
- @parent = parent
17
- @steps = []
18
- instance_eval &block if block
19
- end
20
-
21
- def mkdir(path)
22
- steps << MkDir.new(path)
23
- end
24
-
25
- def template_file(path, input_path, state = {})
26
- new_state = state.merge(load_gem(true))
27
- steps << TemplateFile.new(path, input_path, new_state)
28
- end
29
-
30
- def copy_file(path, input_path, opts = {})
31
- steps << CopyFile.new(path, input_path, opts)
32
- end
33
-
34
- def touch_file(path)
35
- steps << TouchFile.new(path)
36
- end
37
-
38
- def remove_file(path)
39
- steps << RemoveFile.new(path)
40
- end
41
-
42
- def add_requires(path, libs = [])
43
- steps << AddRequires.new(path, libs)
44
- end
45
-
46
- def install_compass(framework, lib)
47
- steps << InstallCompass.new(framework, lib)
48
- end
49
-
50
- def perform(dir)
51
- parent.perform(dir) if parent
52
- begin
53
- steps.each do |step|
54
- step.perform(dir)
55
- end
56
- true
57
- rescue => e
58
- ExceptionHelper.log_error e
59
- ExceptionHelper.log_backtrace e
60
- false
61
- end
62
- end
63
-
64
- def unperform(dir)
65
- steps.each do |step|
66
- begin
67
- step.unperform(dir)
68
- true
69
- rescue => e
70
- ExceptionHelper.log_error e
71
- ExceptionHelper.log_backtrace e
72
- end
73
- end
74
- end
75
-
76
- private
77
-
78
- def load_gem(add_compass = false)
79
- spec = {:dependencies => {}}
80
- gem_spec = Gem::Specification.find_all_by_name('awestruct').last # Make sure we have the latest version
81
-
82
- if add_compass
83
- gem_spec.add_dependency('compass', '>= 1.0.1')
84
- end
85
-
86
- gem_spec.dependencies.each { |d| spec[:dependencies][d.name] = d}
87
- spec[:awestruct_version] = gem_spec.version
88
- spec
89
- end
90
-
91
- ##
92
- ##
93
- ##
94
- ##
95
-
96
- class MkDir
97
- def initialize(path)
98
- @path = path
99
- end
100
-
101
- def perform(dir)
102
- p = File.join(dir, @path)
103
- if File.exist?(p)
104
- $LOG.error "Exists: #{p}" if $LOG.error?
105
- return
106
- end
107
- unless File.directory?(File.dirname(p))
108
- $LOG.error "Does not exist: #{File.dirname(p)}" if $LOG.error?
109
- return
110
- end
111
- $LOG.info "Create directory: #{p}" if $LOG.info?
112
- FileUtils.mkdir(p)
113
- end
114
-
115
- def unperform(dir)
116
- p = File.join(dir, @path)
117
- unless File.exist?(p)
118
- $LOG.error "Does not exist: #{p}" if $LOG.error?
119
- return
120
- end
121
- unless File.directory?(p)
122
- $LOG.error "Not a directory: #{p}" if $LOG.error?
123
- return
124
- end
125
- if Dir.entries(p) != 2
126
- $LOG.error "Not empty: #{p}" if $LOG.error?
127
- return
128
- end
129
- $LOG.info "Remove: #{p}" if $LOG.info?
130
- FileUtils.rmdir(p)
131
- end
132
- end
133
-
134
- class TouchFile
135
- def initialize(path)
136
- @path = path
137
- end
138
-
139
- def perform(dir)
140
- FileUtils.touch(File.join(dir, @path))
141
- end
142
-
143
- def unperform(dir)
144
- #nothing
145
- end
146
- end
147
-
148
- class RemoveFile
149
- def initialize(path)
150
- @path = path
151
- end
152
-
153
- def perform(dir)
154
- FileUtils.rm(File.join(dir, @path), :force => true)
155
- end
156
-
157
- def unperform(dir)
158
- #nothing
159
- end
160
- end
161
-
162
- # Adds a requires for each library in libs to the
163
- # top of the file specified by path
164
- class AddRequires
165
- def initialize(path, libs)
166
- @path = path
167
- @libs = libs
168
- end
169
-
170
- def perform(dir)
171
- file = File.join(dir, @path)
172
- old_lines = File.read file
173
- FileUtils.rm(file)
174
-
175
- File.open(file, 'w') do |new|
176
- @libs.each do |lib|
177
- new.write "require '#{lib}'\n"
178
- end
179
- new.write old_lines
180
- end
181
- end
182
-
183
- def unperform(dir)
184
- #nothing
185
- end
186
- end
187
-
188
- class CopyFile
189
- def initialize(path, input_path, opts = {})
190
- @path = path
191
- @input_path = input_path
192
- @overwrite = opts[:overwrite]
193
- end
194
-
195
- def perform(dir)
196
- p = File.join(dir, @path)
197
- if !@overwrite && File.exist?(p)
198
- $LOG.error "Exists: #{p}" if $LOG.error?
199
- return
200
- end
201
- unless File.directory?(File.dirname(p))
202
- $LOG.error "No directory: #{File.dirname(p)}" if $LOG.error?
203
- return
204
- end
205
- $LOG.info "Create file: #{p}" if $LOG.info?
206
- File.open(p, 'w') { |f| f.write(File.read(@input_path)) }
207
- end
208
-
209
- def unperform(dir)
210
- # nothing
211
- end
212
-
213
- def notunperform(dir)
214
- p = File.join(@dir, p)
215
- unless File.exist?(p)
216
- $LOG.error "Does not exist: #{p}" if $LOG.error?
217
- return
218
- end
219
- $LOG.info "Remove: #{p}" if $LOG.info?
220
- FileUtils.rm(p)
221
- end
222
-
223
- end
224
-
225
- class TemplateFile
226
- def initialize(path, input_path, state = {})
227
- @path = path
228
- @input_path = input_path
229
- @state = state
230
- end
231
-
232
- def perform(dir)
233
-
234
- begin
235
- rendered = ERB.new(File.read(@input_path), nil, '<>').result(
236
- OpenStruct.new(@state).instance_eval { binding })
237
- rescue => e
238
- $LOG.debug "::DEBUG:: #{e.message} state - #{@state}"
239
- end
240
-
241
- p = File.join(dir, @path)
242
- $LOG.info "Create file: #{p}" if $LOG.info?
243
- File.open(p, 'w') { |f| f.write(rendered) }
244
- end
245
-
246
- def unperform(dir)
247
- # nothing
248
- end
249
- end
250
-
251
- class InstallCompass
252
- def initialize(framework='compass', lib)
253
- @framework = framework
254
- @lib = lib
255
- end
256
-
257
- def perform(dir)
258
- ::Compass.configuration.sass_dir = 'stylesheets'
259
- ::Compass.configuration.css_dir = '_site/stylesheets'
260
- ::Compass.configuration.images_dir = 'images'
261
-
262
- cmd = ::Compass::Commands::CreateProject.new(dir, {
263
- :framework => @framework,
264
- :project_type => :stand_alone,
265
- :css_dir => '_site/stylesheets',
266
- :sass_dir => 'stylesheets',
267
- :images_dir => 'images',
268
- :fonts_dir => 'fonts',
269
- :javascripts_dir => 'javascripts',
270
- :bare => true
271
- })
272
- cmd.perform
273
- end
274
-
275
- def unperform(dir)
276
- # nothing
277
- end
278
- end
279
-
280
- end
281
- end
282
- end
data/lib/awestruct/cli/options.rb DELETED
@@ -1,180 +0,0 @@
1
- require 'optparse'
2
-
3
- require 'awestruct/version'
4
-
5
- module Awestruct
6
- module CLI
7
-
8
- class Options
9
- DEFAULT_BIND_ADDR = 'localhost'
10
- DEFAULT_PORT = 4242
11
- DEFAULT_BASE_URL = %(http://#{DEFAULT_BIND_ADDR}:#{DEFAULT_PORT})
12
- DEFAULT_GENERATE_ON_ACCESS = false
13
-
14
- attr_accessor :generate
15
- attr_accessor :server
16
- attr_accessor :port
17
- attr_accessor :bind_addr
18
- attr_accessor :auto
19
- attr_accessor :force
20
- attr_accessor :init
21
- attr_accessor :framework
22
- attr_accessor :scaffold
23
- attr_accessor :base_url
24
- attr_accessor :profile
25
- attr_accessor :deploy
26
- attr_accessor :script
27
- attr_accessor :verbose
28
- attr_accessor :quiet
29
- attr_accessor :source_dir
30
- attr_accessor :output_dir
31
- attr_accessor :livereload
32
- attr_accessor :debug
33
- attr_accessor :generate_on_access
34
- attr_accessor :perf_log
35
-
36
- def initialize(opts = {})
37
- default_opts = { server: false, port: DEFAULT_PORT, bind_addr: DEFAULT_BIND_ADDR, auto: false, force: false,
38
- init: false, framework: 'compass', scaffold: true, base_url: DEFAULT_BASE_URL, deploy: false,
39
- verbose: false, quiet: false, livereload: false, source_dir: Dir.pwd, debug: false,
40
- output_dir: File.expand_path('_site'), generate_on_access: DEFAULT_GENERATE_ON_ACCESS,
41
- perf_log: false
42
- }.merge opts
43
- @generate = default_opts[:generate]
44
- @server = default_opts[:server]
45
- @port = default_opts[:port]
46
- @bind_addr = default_opts[:bind_addr]
47
- @auto = default_opts[:auto]
48
- @force = default_opts[:force]
49
- @init = default_opts[:init]
50
- @framework = default_opts[:framework]
51
- @scaffold = default_opts[:scaffold]
52
- @base_url = default_opts[:base_url]
53
- @profile = default_opts[:profile]
54
- @deploy = default_opts[:deploy]
55
- @script = default_opts[:script]
56
- @verbose = default_opts[:verbose]
57
- @quiet = default_opts[:quiet]
58
- @livereload = default_opts[:livereload]
59
- @source_dir = default_opts[:source_dir]
60
- @output_dir = default_opts[:output_dir]
61
- @generate_on_access = default_opts[:generate_on_access]
62
- @perf_log = default_opts[:perf_log]
63
- @debug = default_opts[:debug]
64
- end
65
-
66
- def self.parse!(args)
67
- Options.new({output_dir: nil}).parse! args
68
- end
69
-
70
- def parse!(args)
71
- opts = OptionParser.new do |opts|
72
- opts.on('-D', '--debug', 'Enable debug logging') do |verbose|
73
- self.debug = true
74
- end
75
- opts.on('-w', '--verbose', 'Enable verbose mode') do |verbose|
76
- self.verbose = true
77
- end
78
- opts.on('-q', '--quiet', 'Only display warnings and errors') do |quiet|
79
- self.quiet = true
80
- end
81
- opts.on( '-i', '--init', 'Initialize a new project in the current directory' ) do |init|
82
- self.init = init
83
- self.generate = false
84
- end
85
- opts.on( '-f', '--framework FRAMEWORK', 'Specify a compass framework during initialization (bootstrap, foundation)' ) do |framework|
86
- self.framework = framework
87
- end
88
- opts.on( '--[no-]scaffold', 'Create scaffolding during initialization (default: true)' ) do |s|
89
- self.scaffold = s
90
- end
91
- opts.on( '--force', 'Force a regeneration' ) do |force|
92
- self.force = force
93
- end
94
- opts.on( '-s', '--server', 'Serve generated site' ) do |s|
95
- self.server = s
96
- end
97
- opts.on( '-u', '--url URL', 'Set site.base_url' ) do |url|
98
- self.base_url = url
99
- end
100
- opts.on( '-d', '--dev', "Run site in development mode (--auto, --server, --port #{DEFAULT_PORT}, --profile development, --livereload and --generate_on_access)" ) do |url|
101
- self.server = true
102
- self.auto = true
103
- self.port = DEFAULT_PORT
104
- self.profile = 'development'
105
- self.livereload = true
106
- self.generate_on_access = true
107
- end
108
- opts.on( '-a', '--auto', 'Auto-generate when changes are noticed' ) do |a|
109
- self.auto = a
110
- self.livereload = true
111
- end
112
- opts.on( '--[no-]livereload', 'Support for browser livereload' ) do |livereload|
113
- self.livereload = livereload
114
- self.generate_on_access = true if self.livereload
115
- end
116
-
117
- opts.on( '--[no-]generate-on-access', 'Support for calling generate on HTTP access' ) do |generate_on_access|
118
- self.generate_on_access = generate_on_access
119
- end
120
-
121
- opts.on( '-P', '--profile PROFILE', 'Activate a configuration profile' ) do |profile|
122
- self.profile = profile
123
- end
124
-
125
- opts.on( '--deploy', 'Deploy site' ) do |deploy|
126
- self.deploy = deploy
127
- self.generate = false if self.generate.nil?
128
- end
129
-
130
- opts.on( '-p', '--port PORT', Integer, "Server port (default: #{DEFAULT_PORT})" ) do |port|
131
- self.port = port
132
- end
133
- opts.on( '-b', '--bind ADDR', "Server address (default: #{DEFAULT_BIND_ADDR})" ) do |bind_addr|
134
- self.bind_addr = bind_addr
135
- end
136
- opts.on( '-g', '--[no-]generate', 'Generate site' ) do |g|
137
- self.generate = g
138
- end
139
- #opts.on( '--run SCRIPT', 'Invoke a script after initialization' ) do |script|
140
- # self.script = script
141
- #end
142
- opts.on( '--source-dir DIR', 'Location of sources (default: .)' ) do |source_dir|
143
- self.source_dir = File.expand_path source_dir
144
- end
145
-
146
- opts.on( '--output-dir DIR', 'Location to output generated site (default: _site)' ) do |output_dir|
147
- self.output_dir = File.expand_path output_dir
148
- end
149
-
150
- opts.on('--perf', 'Enable performance logging to .awestruct/perf.log') do
151
- self.perf_log = true
152
- end
153
-
154
- opts.separator ''
155
- opts.separator "Common options:"
156
-
157
- opts.on_tail("-h", "--help", "Show this message") do
158
- puts opts
159
- exit
160
- end
161
-
162
- opts.on_tail("-v", "--version", "Display the version") do
163
- puts "Awestruct: #{Awestruct::VERSION}"
164
- puts "http://awestruct.org/"
165
- exit
166
- end
167
- end
168
-
169
- opts.parse!(args)
170
- self.port ||= DEFAULT_PORT
171
- self.base_url = %(http://#{self.bind_addr}:#{self.port}) if self.base_url === DEFAULT_BASE_URL
172
- self.output_dir ||= File.expand_path(File.join(self.source_dir, '_site'))
173
-
174
- self.generate = true if self.generate.nil?
175
- self
176
- end # parse()
177
-
178
- end
179
- end
180
- end
data/lib/awestruct/cli/server.rb DELETED
@@ -1,59 +0,0 @@
1
- require 'rack'
2
- require 'rack/builder'
3
- require 'rack/server'
4
- require 'awestruct/rack/app'
5
- require 'awestruct/rack/debug'
6
- require 'awestruct/rack/generate'
7
- require 'awestruct/cli/options'
8
-
9
- module Awestruct
10
- module CLI
11
- class Server
12
- attr_reader :server
13
-
14
- def initialize(path, bind_addr=Options::DEFAULT_BIND_ADDR, port=Options::DEFAULT_PORT, generate_on_access=Options::DEFAULT_GENERATE_ON_ACCESS)
15
- @path = path
16
- @bind_addr = bind_addr
17
- @port = port
18
- @generate_on_access = generate_on_access
19
- end
20
-
21
- def run
22
- unless port_open? @bind_addr, @port
23
- $LOG.error "#{@bind_addr}:#{@port} not available for server"
24
- abort
25
- end
26
- url = %(http://#{@bind_addr}:#{@port})
27
- msg = %(Starting preview server at #{url} (Press Ctrl-C to shutdown))
28
- $LOG.info %(#{'*' * msg.length}\n#{msg}\n#{'*' * msg.length}\n)
29
-
30
- path = @path
31
- generate_on_access = @generate_on_access
32
- app = ::Rack::Builder.new do
33
- use Awestruct::Rack::GenerateOnAccess if generate_on_access
34
- use Awestruct::Rack::Debug
35
- map "/" do
36
- run Awestruct::Rack::App.new( path )
37
- end
38
- end
39
-
40
- ::Rack::Server::start(:app => app,
41
- :Port => @port,
42
- :Host => @bind_addr
43
- )
44
- end
45
-
46
- private
47
- # Private. Checks to see if the port is open.
48
- def port_open?(addr, port)
49
- begin
50
- s = TCPServer.new(addr, port)
51
- s.close
52
- true
53
- rescue
54
- false
55
- end
56
- end
57
- end
58
- end
59
- end
data/lib/awestruct/compatibility.rb DELETED
@@ -1,5 +0,0 @@
1
- unless File.respond_to?(:binread)
2
- def File.binread(file)
3
- File.open(file,"rb") { |f| f.read }
4
- end
5
- end
data/lib/awestruct/config.rb DELETED
@@ -1,57 +0,0 @@
1
- require 'awestruct/cli/options'
2
-
3
- module Awestruct
4
-
5
- class Config
6
-
7
- attr_accessor :dir
8
- attr_accessor :layouts_dir
9
- attr_accessor :config_dir
10
- attr_accessor :extension_dir
11
- attr_accessor :input_dir
12
- attr_accessor :output_dir
13
- attr_accessor :skin_dir
14
- attr_accessor :tmp_dir
15
- attr_accessor :ignore
16
- attr_accessor :track_dependencies
17
-
18
- attr_accessor :images_dir
19
- attr_accessor :stylesheets_dir
20
-
21
- attr_accessor :verbose
22
- attr_accessor :quiet
23
- attr_accessor :options
24
- attr_accessor :debug
25
- attr_accessor :perf
26
-
27
- def initialize(opts = Awestruct::CLI::Options.new)
28
- @dir = Pathname.new(File.expand_path(Pathname.new( opts.source_dir )))
29
- @layouts_dir = Pathname.new( File.join(@dir, '_layouts') )
30
- @config_dir = Pathname.new( File.join(@dir, '_config') )
31
- @input_dir = @dir
32
- @output_dir = Pathname.new(File.expand_path(Pathname.new( opts.output_dir )))
33
- @extension_dir = Pathname.new( File.join(@dir, '_ext') )
34
- @skin_dir = Pathname.new( File.join(@dir, '_skin') )
35
- @tmp_dir = Pathname.new( File.join(@dir, '_tmp') )
36
- @images_dir = Pathname.new( File.join(@dir, 'images') )
37
- @stylesheets_dir = Pathname.new( File.join(@dir, 'stylesheets') )
38
-
39
- @options = opts
40
- @verbose = opts.verbose
41
- @debug = opts.debug
42
- @perf = opts.perf_log
43
-
44
- # Dir[] doesn't like empty list
45
- ignore_file = File.join(@dir, ".awestruct_ignore")
46
- if File.exists?(ignore_file)
47
- ignore_stmts = IO.read(ignore_file).each_line.map(&:strip)
48
- end
49
-
50
- @ignore = (!ignore_stmts.nil? and ignore_stmts.size > 0) ? Dir[*ignore_stmts] : []
51
-
52
- @track_dependencies = false
53
- end
54
-
55
- end
56
-
57
- end
data/lib/awestruct/config/default-site.yml DELETED
@@ -1,50 +0,0 @@
1
- encoding: UTF-8
2
- interpolate: false
3
-
4
- scss:
5
- :line_numbers: true
6
- :style: expanded
7
- sass:
8
- :line_numbers: true
9
- :style: expanded
10
-
11
- content_syntax:
12
- coffee: coffeescript
13
- md: markdown
14
- mkd: markdown
15
- org: orgmod
16
- adoc: asciidoc
17
- ad: asciidoc
18
-
19
- haml:
20
- :attr_wrapper: '"'
21
- :escape_attrs: :once
22
- :format: :xhtml
23
-
24
- haml|html:
25
- :format: :html5
26
-
27
- slim:
28
- :sort_attrs: false
29
- :disable_escape: true
30
- :format: :xhtml
31
-
32
- slim|html:
33
- :format: :html
34
-
35
- asciidoctor:
36
- :backend: html5
37
- :safe: 1
38
- :attributes:
39
- imagesdir: /images
40
- stylesdir: /stylesheets
41
-
42
- textile:
43
- :no_span_caps: true
44
-
45
- generation:
46
- :in_threads: <%= Parallel.processor_count * 10 %>
47
-
48
- profiles:
49
- development:
50
- show_drafts: true
data/lib/awestruct/context.rb DELETED
@@ -1,40 +0,0 @@
1
- require 'awestruct/astruct'
2
-
3
- module Awestruct
4
-
5
- class Context < Awestruct::AStruct
6
- attr_accessor :site
7
- attr_accessor :page
8
-
9
- def initialize(hash)
10
- super
11
- @page = hash[:page]
12
- @site = hash[:site]
13
-
14
- # Update the front matter from the handler chain
15
- @page.handler.front_matter.each do |k,v|
16
- k_sym = k.to_sym
17
- if @page.key? k_sym
18
- if @page[k_sym].is_a?(Array) && v.is_a?(Array)
19
- page_values = @page[k_sym].collect {|value| value.class.to_s}.sort
20
- front_matter_values = v.collect {|value| value.class.to_s}.sort
21
- @page[k_sym] = v if page_values.eql? front_matter_values
22
- elsif @page[k_sym].is_a?(Hash) && v.is_a?(Hash)
23
- page_values = @page[k_sym].collect {|key, value| value.class.to_s}.sort
24
- front_matter_values = v.collect {|key, value| value.class.to_s}.sort
25
- @page[k_sym] = v if page_values.eql? front_matter_values
26
- else
27
- @page[k_sym] = v if @page.key?(k_sym) && (@page[k_sym].class == v.class)
28
- end
29
- else # new key, just add it
30
- @page[k_sym] = v
31
- end
32
- end
33
- end
34
-
35
- def inspect
36
- "Awestruct::Context{:page=>#{self.page.inspect}}"
37
- end
38
- end
39
-
40
- end
data/lib/awestruct/context_helper.rb DELETED
@@ -1,76 +0,0 @@
1
- require 'oga'
2
- require 'awestruct/util/exception_helper'
3
-
4
- module Awestruct
5
- module ContextHelper
6
-
7
- def html_to_text(str)
8
- str.gsub( /<[^>]+>/, '' ).gsub( /&nbsp;/, ' ' )
9
- end
10
-
11
- def clean_html(str)
12
- str.gsub( /&nbsp;/, ' ' )
13
- end
14
-
15
- def without_images(str)
16
- str.gsub(/<img[^>]+>/,'').gsub(/<a[^>]+>([^<]*)<\/a>/, '\1')
17
- end
18
-
19
- def close_tags(s)
20
- stack = []
21
- s.scan(/<\/?[^>]+>/).each do |tag|
22
- if tag[1] != '/'
23
- tag = tag[1..-1].scan(/\w+/).first
24
- stack = [ tag ] + stack
25
- else
26
- tag = tag[2..-1].scan(/\w+/).first
27
- if stack[0] == tag
28
- stack = stack.drop(1)
29
- else
30
- raise "Malformed HTML expected #{tag[0]} but got #{tag} '#{s}'"
31
- end
32
- end
33
- end
34
- stack.inject(s) { |memo,tag| memo += "</#{tag}>" }
35
- end
36
-
37
- def summarize(text, numwords=20, ellipsis='...')
38
- close_tags(text.split(/ /)[0, numwords].join(' ') + ellipsis)
39
- end
40
-
41
- def fully_qualify_urls(base_url, text)
42
- begin
43
- doc = Oga.parse_xml text
44
-
45
- doc.each_node do |elem|
46
- if elem.is_a?(Oga::XML::Element)
47
- case elem.name
48
- when 'a'
49
- elem.set 'href', fix_url(base_url, elem.get('href')) if elem.get('href')
50
- when 'link'
51
- elem.set 'href', fix_url(base_url, elem.get('href')) if elem.get('href')
52
- when 'img'
53
- elem.set 'src', fix_url(base_url, elem.get('src')) if elem.get('src')
54
- end
55
- end
56
- end
57
-
58
- doc.to_xml.tap do |d|
59
- d.force_encoding(text.encoding) if d.encoding != text.encoding
60
- end
61
- rescue => e
62
- Awestruct::ExceptionHelper.log_error e
63
- $LOG.info %Q(If the error has to do with 'end of input' ensure none of the following tags have a closing tag:
64
- #{Oga::XML::HTML_VOID_ELEMENTS.to_a.collect {|a| a.downcase}.uniq.join(', ')}) if $LOG.info?
65
- $LOG.warn "Text being parsed:\n#{text}" if $LOG.warn?
66
- text # returning the bad text, which hopefully will help find the cause
67
- end
68
- end
69
-
70
- def fix_url(base_url, url)
71
- return url unless ( url =~ /^\// )
72
- "#{base_url}#{url}"
73
- end
74
- end
75
-
76
- end
data/lib/awestruct/dependencies.rb DELETED
@@ -1,201 +0,0 @@
1
- module Awestruct
2
- class Dependencies
3
-
4
- attr_reader :page
5
- attr_reader :dependencies
6
- attr_reader :key_dependencies
7
- attr_reader :dependents
8
- attr_reader :key_dependents
9
- attr_reader :content_hash
10
- attr_reader :key_hash
11
- attr_reader :has_changed_content
12
- attr_reader :has_changed_keys
13
-
14
-
15
- def self.track_dependencies=(bol)
16
- @track_dependencies = bol
17
- end
18
-
19
- def self.should_track_dependencies
20
- @track_dependencies
21
- end
22
-
23
- def self.top_page
24
- @pages ||= []
25
- @pages.first
26
- end
27
-
28
- def self.push_page(page)
29
- $LOG.debug "push #{page.output_path}" if $LOG.debug?
30
- if ( top_page.nil? )
31
- $LOG.debug "clearing dependencies" if $LOG.debug?
32
- page.dependencies.clear
33
- else
34
- $LOG.debug "adding page as a dependency to top_page" if $LOG.debug?
35
- top_page.dependencies.add_dependency( page )
36
- end
37
- @pages.push( page )
38
- end
39
-
40
- def self.pop_page
41
- page = @pages.pop
42
- $LOG.debug "pop #{page.output_path} #{@pages.empty?}" if $LOG.debug?
43
- end
44
-
45
-
46
- def self.track_dependency(dep)
47
- return if top_page.nil?
48
- return if top_page == dep
49
- $LOG.debug "dep #{top_page.relative_source_path} - #{dep.relative_source_path}" if $LOG.debug?
50
- top_page.dependencies.add_dependency(dep)
51
- end
52
-
53
- def self.track_key_dependency(dep, key)
54
- return if !Awestruct::Dependencies.should_track_dependencies
55
- return if top_page.nil?
56
- return if top_page == dep
57
- $LOG.debug "dep key #{top_page.relative_source_path} - #{dep.relative_source_path} -> #{key}" if $LOG.debug?
58
- $LOG.debug "callers #{Kernel.caller}" if $LOG.debug?
59
- top_page.dependencies.add_key_dependency(dep)
60
- end
61
-
62
-
63
- def initialize(page)
64
- @page = page
65
- @dependencies = Set.new
66
- @key_dependencies = Set.new
67
- @dependents = Set.new
68
- @key_dependents = Set.new
69
- @content_hash = nil
70
- @key_hash = nil
71
- @has_changed_content = false
72
- @has_changed_keys = false
73
- end
74
-
75
- def key_hash=(key)
76
- $LOG.debug "key_hash #{key}" if $LOG.debug?
77
- if @key_hash.nil?
78
- @has_changed_keys = false
79
- else
80
- if key.eql? @key_hash
81
- @has_changed_keys = false
82
- else
83
- @has_changed_keys = true
84
- end
85
- end
86
- @key_hash = key
87
- end
88
-
89
- def content_hash=(key)
90
- $LOG.debug "content_hash #{key}" if $LOG.debug?
91
- if @content_hash.nil?
92
- @has_changed_content = false
93
- else
94
- if key.eql? @content_hash
95
- @has_changed_content = false
96
- else
97
- @has_changed_content = true
98
- end
99
- end
100
- @content_hash = key
101
- end
102
-
103
- def <<(dep)
104
- add_dependency( dep )
105
- end
106
-
107
- def add_dependency(dep)
108
- return if dep.nil?
109
- return if @page.do_not_track_dependencies
110
- return if @page.output_path.nil?
111
- return if dep == @page
112
- $LOG.debug "adding dependency #{dep.source_path} to #{page.source_path}" if $LOG.debug?
113
- @dependencies << dep
114
- dep.dependencies.add_dependent( page )
115
- end
116
-
117
- def add_key_dependency(dep)
118
- return if dep.nil?
119
- return if @page.do_not_track_dependencies
120
- return if @page.output_path.nil?
121
- return if dep == @page
122
- @key_dependencies << dep
123
- dep.dependencies.add_key_dependent( page )
124
- end
125
-
126
- def add_dependent(dep)
127
- return if dep.nil?
128
- @dependents << dep
129
- end
130
-
131
- def add_key_dependent(dep)
132
- return if dep.nil?
133
- @key_dependents << dep
134
- end
135
-
136
- def remove_dependent(dep)
137
- return if dep.nil?
138
- @dependents.delete( dep )
139
- end
140
-
141
- def clear
142
- @dependencies.clear
143
- @dependents.each do |d|
144
- if (d.instance_of? Awestruct::Dependencies)
145
- d.remove_dependent( page )
146
- else
147
- d.dependencies.remove_dependent( page )
148
- end
149
- end
150
- end
151
-
152
- def persist!
153
- return if page.output_path.nil? || page.output_path == ''
154
- file = File.join( @page.site.config.dir.to_s, '.awestruct', 'dependency-cache', page.output_path )
155
- $LOG.debug "store #{file}" if $LOG.debug?
156
- FileUtils.mkdir_p( File.dirname( file ) )
157
- File.open( file, 'w' ) do |file|
158
- file.puts "ch:#{@content_hash}"
159
- file.puts "kh:#{@key_hash}"
160
- @dependencies.collect{|e| e.relative_source_path }.uniq.each do |d|
161
- file.puts "c:#{d}" unless d.nil?
162
- end
163
- @key_dependencies.collect{|e| e.relative_source_path }.uniq.each do |d|
164
- file.puts "k:#{d}" unless d.nil?
165
- end
166
- end
167
- end
168
-
169
- def load!
170
- return if page.output_path.nil? || page.output_path == ''
171
- file = File.join( @page.site.config.dir, '.awestruct', 'dependency-cache', page.output_path )
172
- $LOG.debug "load #{file}" if $LOG.debug?
173
- if ( File.exist?( file ) )
174
- File.open( file, 'r' ) do |file|
175
- file.each_line do |line|
176
- type, path = line.split(':')
177
- path ||= ""
178
- path.strip!
179
- if type.eql? 'c' or type.eql? 'k'
180
- d = find_page_by_path( path )
181
- unless d.nil?
182
- add_dependency( d ) if 'c'.eql? type
183
- add_key_dependency( d ) if 'k'.eql? type
184
- end
185
- else
186
- self.content_hash = path if 'ch'.eql? type
187
- self.key_hash = path if 'kh'.eql? type
188
- end
189
- end
190
- end
191
- return true
192
- end
193
- false
194
- end
195
-
196
- def find_page_by_path(path)
197
- page.site.pages_by_relative_source_path[ path ]
198
- end
199
-
200
- end
201
- end
data/lib/awestruct/deploy/base_deploy.rb DELETED
@@ -1,111 +0,0 @@
1
- require 'awestruct/deployers'
2
- require 'awestruct/compatibility'
3
- require 'awestruct/util/exception_helper'
4
-
5
- Dir[ File.join( File.dirname(__FILE__), '..', 'scm', '*.rb' ) ].each do |f|
6
- begin
7
- require f
8
- rescue LoadError => e
9
- raise e 'Something horribly, horribly wrong has happened'
10
- end
11
- end
12
-
13
-
14
- module Awestruct
15
- module Deploy
16
- class Base
17
- UNCOMMITTED_CHANGES = 'You have uncommitted changes in the working branch. Please commit or stash them.'
18
-
19
- def initialize(site_config, deploy_config)
20
- # Add a single front slash at the end of output dir
21
- @site_path = File.join( site_config.output_dir, '/' ).gsub(/^\w:\//, '/')
22
- @gzip = deploy_config['gzip']
23
- @gzip_level = deploy_config['gzip_level'] || Zlib::BEST_COMPRESSION
24
- @source_dir = deploy_config['source_dir'] || site_config.dir
25
- @ignore_uncommitted = deploy_config['uncommitted']
26
- init_scm(deploy_config['scm'] || 'git')
27
- end
28
-
29
- def run
30
- if ExceptionHelper.build_failed?
31
- ExceptionHelper.log_message 'Not running deploy due to build failure'
32
- return
33
- end
34
-
35
- if @ignore_uncommitted == true
36
- compress_site
37
- publish_site
38
- else
39
- if @scm.uncommitted_changes? @source_dir
40
- existing_changes
41
- else
42
- compress_site
43
- publish_site
44
- end
45
- end
46
- end
47
-
48
- def publish_site
49
- $LOG.error( "#{self.class.name}#publish_site not implemented." )
50
- end
51
-
52
- def existing_changes
53
- $LOG.error UNCOMMITTED_CHANGES
54
- end
55
-
56
- def compress_site
57
- if @gzip
58
- gzip_site @site_path
59
- end
60
- end
61
-
62
- def gzip_site(site_path)
63
- Dir.glob("#{site_path}/**/*") do |item|
64
- next if item == '.' or item == '..'
65
- ext = File.extname(item)
66
- if !ext.empty?
67
- ext_sym = ext[1..-1].to_sym
68
- case ext_sym
69
- when :css, :js, :html
70
- require 'zlib'
71
- if !is_gzipped item
72
- gzip_file(item, @gzip_level)
73
- end
74
- end
75
- end
76
- end
77
- end
78
-
79
- def gzip_file(filename, level)
80
- $LOG.debug "Gzipping File #{filename}"
81
- Zlib::GzipWriter.open("#{filename}.gz", level) do |gz|
82
- gz.mtime = File.mtime(filename)
83
- gz.orig_name = filename
84
- gz.write File.binread(filename)
85
- end
86
- File.rename("#{filename}.gz", "#{filename}")
87
- end
88
-
89
- def is_gzipped(filename)
90
- begin
91
- File.open("#{filename}") do |f|
92
- Zlib::GzipReader.new(f)
93
- true
94
- end
95
- rescue
96
- false
97
- end
98
- end
99
-
100
- def init_scm type
101
- begin
102
- clazz = Object.const_get('Awestruct').const_get('Scm').const_get(type.capitalize)
103
- @scm = clazz.new
104
- rescue
105
- ExceptionHelper.log_message( "Could not resolve class for scm type: #{type}" )
106
- ExceptionHelper.mark_failed
107
- end
108
- end
109
- end
110
- end
111
- end
data/lib/awestruct/deploy/github_pages_deploy.rb DELETED
@@ -1,61 +0,0 @@
1
- require 'awestruct/deploy/base_deploy'
2
- require 'awestruct/util/exception_helper'
3
- require 'git'
4
-
5
- module Awestruct
6
- module Deploy
7
- class GitHubPagesDeploy < Base
8
- def initialize(site_config, deploy_config)
9
- super
10
- @branch = deploy_config['branch'] || 'gh-pages'
11
- @repo = deploy_config['repository'] || 'origin'
12
- end
13
-
14
- def publish_site
15
- tmp_branch = '__awestruct_deploy__'
16
- detached_branch = nil
17
-
18
- original_branch = git.current_branch
19
-
20
- # detect a detached state
21
- # values include (no branch), (detached from x), etc
22
- if original_branch.start_with? '('
23
- detached_branch = git.log(1).first.sha
24
- git.branch(original_branch = tmp_branch).checkout
25
- end
26
-
27
- # work in a branch, then revert to current branch
28
- git.branch(@branch).checkout
29
- add_and_commit_site @site_path
30
- git.push(@repo, @branch)
31
-
32
- if detached_branch
33
- git.checkout detached_branch
34
- git.branch(original_branch).delete
35
- else
36
- git.checkout original_branch
37
- end
38
- end
39
-
40
- private
41
- def add_and_commit_site(path)
42
- git.with_working(path) do
43
- git.add(".")
44
- begin
45
- git.commit("Published #{@branch} to GitHub pages.")
46
- rescue ::Git::GitExecuteError => e
47
- ExceptionHelper.log_message "Can't commit. #{e}."
48
- ExceptionHelper.mark_failed
49
- end
50
- end
51
- git.reset_hard
52
- end
53
-
54
- def git
55
- @git ||= ::Git.open('.')
56
- end
57
- end
58
- end
59
- end
60
-
61
- Awestruct::Deployers.instance[:github_pages] = Awestruct::Deploy::GitHubPagesDeploy
data/lib/awestruct/deploy/rsync_deploy.rb DELETED
@@ -1,62 +0,0 @@
1
- require 'awestruct/deploy/base_deploy'
2
- require 'shellwords'
3
- require 'open3'
4
-
5
- module Awestruct
6
- module Deploy
7
- class RSyncDeploy < Base
8
-
9
- def initialize(site_config, deploy_config)
10
- super
11
- @host = deploy_config['host']
12
- @path = File.join( deploy_config['path'], '/' )
13
- @exclude = deploy_config['exclude']
14
- end
15
-
16
- def publish_site
17
- exclude_option = (!@exclude.nil? and !@exclude.empty?) ? "--exclude=" + Shellwords.escape(@exclude) : nil
18
- site_path = Shellwords.escape(@site_path)
19
- host = Shellwords.escape(@host)
20
- path = Shellwords.escape(@path)
21
-
22
- cmd = "rsync -r -l -i --no-p --no-g --chmod=Dg+sx,ug+rw --delete #{exclude_option} #{site_path} #{host}:#{path}"
23
-
24
- Open3.popen3( cmd ) do |stdin, stdout, stderr|
25
- stdin.close
26
- threads = []
27
- threads << Thread.new(stdout) do |i|
28
- while ( ! i.eof? )
29
- line = i.readline
30
- head = line[0,9]
31
- file = line[10..-1].chomp
32
- case head
33
- when '<f.sT....'
34
- $LOG.info " updating #{file}" if $LOG.info?
35
- when 'cd+++++++'
36
- $LOG.info " creating #{file}" if $LOG.info?
37
- when '<f+++++++'
38
- $LOG.info " adding #{file}" if $LOG.info?
39
- when '<f..T....'
40
- # ignoring unchanged files
41
- $LOG.debug " no change to #{file}" if $LOG.debug?
42
- when '*deleting'
43
- $LOG.info " deleting #{file}" if $LOG.info?
44
- else
45
- $LOG.debug line if $LOG.debug
46
- end
47
- end
48
- end
49
- threads << Thread.new(stderr) do |i|
50
- while ( ! i.eof? )
51
- line = i.readline
52
- $LOG.error line if $LOG.error?
53
- end
54
- end
55
- threads.each{|t|t.join}
56
- end
57
- end
58
- end
59
- end
60
- end
61
-
62
- Awestruct::Deployers.instance[ :rsync ] = Awestruct::Deploy::RSyncDeploy
data/lib/awestruct/deploy/s3_deploy.rb DELETED
@@ -1,61 +0,0 @@
1
- require 'awestruct/deploy/base_deploy'
2
-
3
- module Awestruct
4
- module Deploy
5
- class S3Deploy < Base
6
- def initialize( site_config, deploy_config )
7
- super
8
- @bucket = deploy_config['bucket']
9
- @metadata = deploy_config['metadata']
10
- end
11
-
12
- def publish_site
13
- $LOG.info "Syncing #{@site_path} to bucket #{@bucket}" if $LOG.info?
14
- if @metadata and !@metadata.empty?
15
- @metadata.each do |fileType, headers|
16
- # Build the add-header command because the s3cmd-dsl gem doesn't support multi-headers
17
- headerCmd = ""
18
- if headers && !headers.empty?
19
- headers.each do |key, value|
20
- headerCmd << add_header(key, value)
21
- end
22
- end
23
- # If gzip is enabled, add 'Content-Encoding: gzip' on js, css and html files
24
- if @gzip and ['js', 'css', 'html'].include? fileType
25
- headerCmd << add_header("Content-Encoding", "gzip")
26
- end
27
- # Sync files of current type with specified headers
28
- s3_sync(@site_path, @bucket, "*", "*.#{fileType}", headerCmd)
29
- end
30
- end
31
- # If gzip is enabled, add 'Content-Encoding: gzip' on not processed js, css and html files
32
- if @gzip
33
- remainingFileType = ['js', 'css', 'html'].find_all { |fileType| !@metadata.keys.include? fileType }
34
- remainingFileType.each do |fileType|
35
- headerCmd = add_header("Content-Encoding", "gzip")
36
- s3_sync(@site_path, @bucket, "*", "*.#{fileType}", headerCmd)
37
- end
38
- end
39
- # Finally, sync others files
40
- s3_sync(@site_path, @bucket)
41
- $LOG.info "DONE" if $LOG.info?
42
- end
43
-
44
- def add_header(key, value)
45
- " --add-header '#{key}:#{value}'"
46
- end
47
-
48
- def s3_sync(site_path, bucket, exclude = nil, include = nil, headersCmd = nil)
49
- cmd="s3cmd sync '#{site_path}' '#{bucket}'"
50
- cmd << " --exclude '#{exclude}'" if exclude
51
- cmd << " --include '#{include}'" if include
52
- cmd << " #{headersCmd}" if headersCmd
53
- $LOG.info "Execute #{cmd}"
54
- `#{cmd}`
55
- end
56
- end
57
- end
58
- end
59
-
60
- Awestruct::Deployers.instance[ :s3 ] = Awestruct::Deploy::S3Deploy
61
-
data/lib/awestruct/deployers.rb DELETED
@@ -1,14 +0,0 @@
1
- module Awestruct
2
-
3
- class Deployers < Hash
4
- def self.instance
5
- @instance ||= Deployers.new
6
- end
7
-
8
- def self.register( key, cls )
9
- Deployers.instance[ key.to_sym ] = cls
10
- end
11
-
12
- end
13
-
14
- end
data/lib/awestruct/engine.rb DELETED
@@ -1,578 +0,0 @@
1
- require 'awestruct/util/inflector'
2
- require 'awestruct/util/exception_helper'
3
- require 'awestruct/util/default_inflections'
4
-
5
- require 'awestruct/config'
6
- require 'awestruct/site'
7
- require 'awestruct/pipeline'
8
- require 'awestruct/page'
9
- require 'awestruct/page_loader'
10
-
11
- require 'awestruct/extensions/pipeline'
12
-
13
- require 'fileutils'
14
- require 'set'
15
- require 'date'
16
- require 'erb'
17
-
18
- require 'parallel'
19
-
20
- class OpenStruct
21
- def inspect
22
- "OpenStruct{...}"
23
- end
24
- end
25
-
26
- module Awestruct
27
-
28
- class Engine
29
-
30
- attr_reader :site
31
- attr_reader :pipeline
32
- attr_reader :config
33
-
34
- def self.instance
35
- @instance
36
- end
37
-
38
- def self.instance=(engine)
39
- @instance = engine
40
- end
41
-
42
- def initialize(config=Awestruct::Config.new)
43
- Engine.instance = self
44
- @site = Site.new( self, config)
45
- @pipeline = Pipeline.new
46
- @site_page_loader = PageLoader.new( @site )
47
- @layout_page_loader = PageLoader.new( @site, :layouts )
48
- @config = config
49
- end
50
-
51
- def config
52
- site.config
53
- end
54
-
55
- def run(profile, base_url, default_base_url, force=false, generate=true)
56
- start_time = DateTime.now
57
- $LOG.verbose 'adjust_load_path' if config.verbose
58
- adjust_load_path
59
- $LOG.trace "Total time in adjust_load_path: #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
60
-
61
- $LOG.verbose 'load_default_site_yaml' if config.verbose
62
- start_time = DateTime.now
63
- load_default_site_yaml( profile )
64
- $LOG.trace "Total time in load_default_site_yaml #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
65
-
66
- $LOG.verbose 'load_user_site_yaml -- profile' if config.verbose
67
- start_time = DateTime.now
68
- load_user_site_yaml( profile )
69
- $LOG.trace "Total time in load_user_site_yaml #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
70
-
71
- $LOG.verbose 'set_base_url' if config.verbose
72
- start_time = DateTime.now
73
- set_base_url( base_url, default_base_url )
74
- $LOG.trace "Total time in set_base_url #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
75
-
76
- $LOG.verbose 'load_yamls' if config.verbose
77
- start_time = DateTime.now
78
- load_yamls
79
- $LOG.trace "Total time in load_yamls #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
80
-
81
- $LOG.verbose 'load_pipeline' if config.verbose
82
- start_time = DateTime.now
83
- load_pipeline
84
- $LOG.trace "Total time in load_pipeline #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
85
-
86
- $LOG.verbose 'load_pages' if config.verbose
87
- start_time = DateTime.now
88
- load_pages
89
- $LOG.trace "Total time in load_pages #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
90
-
91
- $LOG.verbose 'execute_pipeline' if config.verbose
92
- $LOG.info 'Executing pipeline...'
93
- start_time = DateTime.now
94
- execute_pipeline(false)
95
- $LOG.trace "Total time in execute_pipeline #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
96
-
97
- begin
98
- if defined?(::Compass)
99
- $LOG.verbose 'configure_compass' if config.verbose
100
- start_time = DateTime.now
101
- configure_compass
102
- $LOG.trace "Total time in configure_compass #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
103
- end
104
- rescue LoadError
105
- # doesn't matter if we can't load it
106
- end
107
- $LOG.verbose 'set_urls' if config.verbose
108
- start_time = DateTime.now
109
- set_urls( site.pages )
110
- $LOG.trace "Total time in set_urls #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
111
-
112
- $LOG.verbose 'build_page_index' if config.verbose
113
- start_time = DateTime.now
114
- build_page_index
115
- $LOG.trace "Total time in build_page_index #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
116
-
117
- if generate
118
- $LOG.debug 'generate_output' if config.debug
119
- $LOG.info 'Generating pages...'
120
- start_time = DateTime.now
121
- generate_output
122
- $LOG.trace "Total time in generate_output #{DateTime.now.to_time - start_time.to_time} seconds" if config.perf
123
- end
124
- Awestruct::ExceptionHelper::EXITCODES[:success]
125
- end
126
-
127
- def build_page_index
128
- site.pages_by_relative_source_path = {}
129
- site.pages_by_output_path = {}
130
- site.pages.each do |p|
131
- # Add the layout to the set of dependencies
132
- p.dependencies.add_dependency(site.layouts.find_matching(p.layout, p.output_extension))
133
- if p.relative_source_path
134
- site.pages_by_relative_source_path[ p.relative_source_path ] = p
135
- end
136
- site.pages_by_output_path[ p.output_path ] = p
137
- end
138
- site.layouts.each do |p|
139
- # Add the layout to the set of dependencies
140
- p.dependencies.add_dependency(site.layouts.find_matching(p.layout, p.output_extension))
141
-
142
- if p.relative_source_path
143
- site.pages_by_relative_source_path[ p.relative_source_path ] = p
144
- end
145
- end
146
- end
147
-
148
- def set_base_url(base_url, default_base_url)
149
- if base_url
150
- site.base_url = base_url
151
- end
152
-
153
- if site.base_url.nil?
154
- site.base_url = default_base_url
155
- end
156
-
157
- if site.base_url
158
- if site.base_url =~ /^(.*)\/#x2F;
159
- site.base_url = $1
160
- end
161
- end
162
-
163
- end
164
-
165
- def load_default_site_yaml(profile = nil)
166
- default_site_yaml_path = File.join( File.dirname( __FILE__ ), 'config', 'default-site.yml' )
167
- load_site_yaml( default_site_yaml_path, profile )
168
- end
169
-
170
- def load_user_site_yaml(profile = nil)
171
- site_yaml_path = File.join( site.config.config_dir, 'site.yml' )
172
- load_site_yaml( site_yaml_path, profile )
173
- end
174
-
175
- def load_yamls
176
- Dir[ File.join( site.config.config_dir, '*.yml' ) ].each do |yaml_path|
177
- load_yaml( yaml_path ) unless ( File.basename( yaml_path ) == 'site.yml' )
178
- end
179
- end
180
-
181
- def load_site_yaml(yaml_path, profile = nil)
182
- if File.exist?(yaml_path)
183
- begin
184
- data = YAML.load( ERB.new(File.read( yaml_path, :encoding => 'bom|utf-8' ), nil, '<>').result )
185
- if profile
186
- # JP: Interpolation now turned off by default, turn it per page if needed
187
- site.interpolate = false
188
- profile_data = {}
189
- data.each do |k,v|
190
- if (k == 'profiles') && (!profile.nil?)
191
- profile_data = ( v[profile] || {} )
192
- else
193
- site.send( "#{k}=", merge_data( site.send( "#{k}" ), v ) )
194
- end
195
- end if data
196
- site.profile = profile
197
- profile_data.each do |k,v|
198
- site.send( "#{k}=", merge_data( site.send( "#{k}" ), v ) )
199
- end
200
- else
201
- data.each do |k,v|
202
- site.send( "#{k}=", v )
203
- end if data
204
- end
205
- rescue Exception => e
206
- ExceptionHelper.log_building_error e, yaml_path
207
- ExceptionHelper.mark_failed
208
- end
209
- end
210
- end
211
-
212
- def load_yaml(yaml_path)
213
- begin
214
- data = YAML.load( ERB.new(File.read( yaml_path ), nil, '<>').result )
215
- rescue Exception => e
216
- ExceptionHelper.log_building_error e, yaml_path
217
- ExceptionHelper.mark_failed
218
- end
219
- name = File.basename( yaml_path, '.yml' )
220
- site.send( "#{name}=", massage_yaml( data ) )
221
- end
222
-
223
- def merge_data(existing, new)
224
- if existing.kind_of? Hash
225
- result = existing.inject({}) do |merged, (k,v)|
226
- if new.has_key? k
227
- if v.kind_of? Hash
228
- merged[k] = merge_data(v, new.delete(k))
229
- else
230
- merged[k] = new.delete(k)
231
- end
232
- else
233
- merged[k] = v
234
- end
235
- merged
236
- end
237
- result.merge new
238
- else
239
- new
240
- end
241
- end
242
-
243
- def massage_yaml(obj)
244
- result = obj
245
- case ( obj )
246
- when Hash
247
- result = {}
248
- obj.each do |k,v|
249
- result[k] = massage_yaml(v)
250
- end
251
- result = AStruct.new( result ).cascade_for_nils!
252
- when Array
253
- result = []
254
- obj.each do |v|
255
- result << massage_yaml(v)
256
- end
257
- end
258
- result
259
- end
260
-
261
- def adjust_load_path
262
- ext_dir = File.join( site.config.extension_dir )
263
- if $LOAD_PATH.index(ext_dir).nil?
264
- $LOAD_PATH << ext_dir
265
- end
266
- end
267
-
268
- def set_urls(pages)
269
- pages.each do |page|
270
- $LOG.debug "relative_source_path #{page.relative_source_path}" if config.debug
271
- page_path = page.output_path
272
- if page_path =~ /^\//
273
- page.url = page_path
274
- else
275
- page.url = "/#{page_path}"
276
- end
277
- if page.url =~ /^(.*\/)index.html#x2F;
278
- page.url = $1
279
- end
280
- end
281
- end
282
-
283
- def load_pipeline
284
- ext_dir = File.join( site.config.extension_dir )
285
- pipeline_file = File.join( ext_dir, 'pipeline.rb' )
286
- if File.exists?(pipeline_file)
287
- p = eval(File.read( pipeline_file ), nil, pipeline_file, 1)
288
- p.before_all_extensions.each do |e|
289
- pipeline.add_before_extension( e )
290
- end
291
- p.extensions.each do |e|
292
- pipeline.extension( e )
293
- end
294
- p.after_all_extensions.each do |e|
295
- pipeline.add_after_extension( e )
296
- end
297
- p.helpers.each do |h|
298
- pipeline.helper( h )
299
- end
300
- p.transformers.each do |t|
301
- pipeline.transformer( t )
302
- end
303
- p.after_generation_extensions.each do |e|
304
- pipeline.add_after_generation_extension( e )
305
- end
306
- end
307
- end
308
-
309
- def execute_pipeline(on_reload = false)
310
- FileUtils.mkdir_p( site.config.output_dir )
311
- FileUtils.mkdir_p( site.config.tmp_dir )
312
- pipeline.execute( site, on_reload )
313
- end
314
-
315
- def configure_compass
316
- site.images_dir = File.join( site.config.dir, 'images' )
317
- site.fonts_dir = File.join( site.config.dir, 'fonts' )
318
- site.sass_dir = File.join( site.config.dir, 'stylesheets' )
319
- site.css_dir = File.join( site.config.output_dir, 'stylesheets' )
320
- site.javascripts_dir = File.join( site.config.dir, 'javascripts' )
321
-
322
- ::Compass.configuration do |config|
323
- config.project_type = :stand_alone
324
- config.environment = site.profile