middleman 2.0.16.1 → 3.0.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. data/.gitignore +2 -1
  2. data/CHANGELOG +16 -8
  3. data/features/builder.feature +2 -5
  4. data/features/cache_buster.feature +1 -1
  5. data/features/clean_build.feature +0 -1
  6. data/features/coffee-script.feature +3 -3
  7. data/features/custom_layout_engines.feature +10 -0
  8. data/features/directory_index.feature +0 -1
  9. data/features/dynamic_pages.feature +0 -1
  10. data/features/fonts.feature +0 -1
  11. data/features/{padrino_helpers.feature → former_padrino_helpers.feature} +1 -1
  12. data/features/sprockets.feature +34 -5
  13. data/features/sprockets_gems.feature +7 -4
  14. data/features/step_definitions/asset_host_steps.rb +7 -6
  15. data/features/step_definitions/builder_steps.rb +4 -0
  16. data/features/step_definitions/middleman_steps.rb +22 -16
  17. data/features/step_definitions/page_layout_steps.rb +10 -8
  18. data/fixtures/custom-layout-app/config.rb +1 -0
  19. data/fixtures/custom-layout-app/source/index.html.erb +1 -0
  20. data/fixtures/custom-layout-app/source/layout.haml +6 -0
  21. data/fixtures/sprockets-app/config.rb +2 -1
  22. data/fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss +1 -0
  23. data/fixtures/sprockets-app/source/library/css/plain.css +3 -0
  24. data/fixtures/sprockets-app/source/library/css/sprockets_base1.css.scss +1 -0
  25. data/fixtures/sprockets-app/source/library/css/sprockets_base2.css.scss +1 -0
  26. data/fixtures/sprockets-app/source/library/css/sprockets_sub.css.scss +1 -0
  27. data/fixtures/sprockets-app/source/{jquery_include.js → library/js/jquery_include.js} +0 -0
  28. data/fixtures/sprockets-app/source/library/js/plain.js +3 -0
  29. data/fixtures/sprockets-app/source/library/{javascripts → js}/sprockets_base.js +0 -0
  30. data/fixtures/sprockets-app/source/library/{javascripts → js}/sprockets_sub.js +0 -0
  31. data/fixtures/test-app/config.rb +5 -4
  32. data/fixtures/test-app/source/{padrino_test.html.haml → former_padrino_test.html.haml} +0 -0
  33. data/fixtures/test-app/source/stylesheets/sprockets_base1.css.scss +1 -0
  34. data/fixtures/test-app/source/stylesheets/sprockets_base2.css.scss +1 -0
  35. data/fixtures/test-app/source/stylesheets/sprockets_sub.css.scss +1 -0
  36. data/lib/middleman.rb +27 -25
  37. data/lib/middleman/base.rb +408 -166
  38. data/lib/middleman/builder.rb +78 -162
  39. data/lib/middleman/cli.rb +61 -32
  40. data/lib/middleman/core_extensions/assets.rb +4 -44
  41. data/lib/middleman/core_extensions/builder.rb +12 -16
  42. data/lib/middleman/core_extensions/compass.rb +28 -57
  43. data/lib/middleman/core_extensions/data.rb +65 -49
  44. data/lib/middleman/core_extensions/default_helpers.rb +33 -18
  45. data/lib/middleman/core_extensions/features.rb +48 -26
  46. data/lib/middleman/core_extensions/file_watcher.rb +66 -0
  47. data/lib/middleman/core_extensions/front_matter.rb +91 -86
  48. data/lib/middleman/core_extensions/rendering.rb +9 -8
  49. data/lib/middleman/core_extensions/routing.rb +19 -53
  50. data/lib/middleman/core_extensions/sitemap.rb +229 -0
  51. data/lib/middleman/core_extensions/sprockets.rb +53 -37
  52. data/lib/middleman/features/asset_host.rb +20 -10
  53. data/lib/middleman/features/automatic_image_sizes.rb +12 -9
  54. data/lib/middleman/features/cache_buster.rb +38 -25
  55. data/lib/middleman/features/directory_indexes.rb +31 -28
  56. data/lib/middleman/features/minify_css.rb +3 -2
  57. data/lib/middleman/features/minify_css/cssmin.rb +55 -0
  58. data/lib/middleman/features/minify_javascript.rb +12 -5
  59. data/lib/middleman/features/relative_assets.rb +28 -25
  60. data/lib/middleman/features/sitemap_tree.rb +34 -0
  61. data/lib/middleman/guard.rb +57 -23
  62. data/lib/middleman/renderers/erb.rb +29 -0
  63. data/lib/middleman/renderers/liquid.rb +3 -12
  64. data/lib/middleman/renderers/markdown.rb +16 -15
  65. data/lib/middleman/renderers/sass.rb +34 -38
  66. data/lib/middleman/vendor/hooks-0.2.0/CHANGES.textile +9 -0
  67. data/lib/middleman/vendor/hooks-0.2.0/Gemfile +3 -0
  68. data/lib/middleman/vendor/hooks-0.2.0/README.rdoc +107 -0
  69. data/lib/middleman/vendor/hooks-0.2.0/Rakefile +12 -0
  70. data/lib/middleman/vendor/hooks-0.2.0/hooks.gemspec +22 -0
  71. data/lib/middleman/vendor/hooks-0.2.0/lib/hooks.rb +109 -0
  72. data/lib/middleman/vendor/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +33 -0
  73. data/lib/middleman/vendor/hooks-0.2.0/test/hooks_test.rb +141 -0
  74. data/lib/middleman/vendor/hooks-0.2.0/test/inheritable_attribute_test.rb +55 -0
  75. data/lib/middleman/vendor/hooks-0.2.0/test/test_helper.rb +10 -0
  76. data/lib/middleman/vendor/padrino-core-0.10.5/.document +5 -0
  77. data/lib/middleman/vendor/padrino-core-0.10.5/.gitignore +22 -0
  78. data/lib/middleman/vendor/padrino-core-0.10.5/.yardopts +1 -0
  79. data/lib/middleman/vendor/padrino-core-0.10.5/LICENSE.txt +20 -0
  80. data/lib/middleman/vendor/padrino-core-0.10.5/README.rdoc +294 -0
  81. data/lib/middleman/vendor/padrino-core-0.10.5/Rakefile +5 -0
  82. data/lib/middleman/vendor/padrino-core-0.10.5/bin/padrino +9 -0
  83. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core.rb +167 -0
  84. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application.rb +270 -0
  85. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/rendering.rb +292 -0
  86. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/routing.rb +934 -0
  87. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/showexceptions.rb +20 -0
  88. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/caller.rb +53 -0
  89. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/adapter.rb +24 -0
  90. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/base.rb +151 -0
  91. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/console.rb +20 -0
  92. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/rake.rb +24 -0
  93. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/rake_tasks.rb +59 -0
  94. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/command.rb +38 -0
  95. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/images/404.png +0 -0
  96. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/images/500.png +0 -0
  97. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/loader.rb +210 -0
  98. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/cs.yml +34 -0
  99. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/da.yml +34 -0
  100. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/de.yml +34 -0
  101. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/en.yml +34 -0
  102. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/es.yml +34 -0
  103. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/fr.yml +34 -0
  104. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/hu.yml +34 -0
  105. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/it.yml +40 -0
  106. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/ja.yml +34 -0
  107. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/lv.yml +34 -0
  108. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/nl.yml +34 -0
  109. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/no.yml +35 -0
  110. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/pl.yml +34 -0
  111. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/pt_br.yml +40 -0
  112. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/ru.yml +35 -0
  113. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/tr.yml +34 -0
  114. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/uk.yml +34 -0
  115. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/zh_cn.yml +34 -0
  116. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/zh_tw.yml +34 -0
  117. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/logger.rb +345 -0
  118. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/mounter.rb +224 -0
  119. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/reloader.rb +254 -0
  120. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/router.rb +98 -0
  121. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/server.rb +79 -0
  122. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/support_lite.rb +199 -0
  123. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/tasks.rb +21 -0
  124. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/version.rb +20 -0
  125. data/lib/middleman/vendor/padrino-core-0.10.5/padrino-core.gemspec +38 -0
  126. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/.components +6 -0
  127. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/.gitignore +7 -0
  128. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/complex.rb +32 -0
  129. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/simple.rb +33 -0
  130. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/a.rb +9 -0
  131. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/b.rb +4 -0
  132. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/c.rb +1 -0
  133. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/e.rb +13 -0
  134. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/f.rb +2 -0
  135. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/g.rb +2 -0
  136. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/d.rb +4 -0
  137. data/lib/middleman/vendor/padrino-core-0.10.5/test/helper.rb +81 -0
  138. data/lib/middleman/vendor/padrino-core-0.10.5/test/mini_shoulda.rb +45 -0
  139. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_application.rb +108 -0
  140. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_core.rb +79 -0
  141. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_dependencies.rb +44 -0
  142. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_filters.rb +278 -0
  143. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_locale.rb +21 -0
  144. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_logger.rb +100 -0
  145. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_mounter.rb +177 -0
  146. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_reloader_complex.rb +75 -0
  147. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_reloader_simple.rb +98 -0
  148. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_rendering.rb +461 -0
  149. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_restful_routing.rb +33 -0
  150. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_router.rb +146 -0
  151. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_routing.rb +1673 -0
  152. data/lib/middleman/vendor/padrino-helpers-0.10.5/.document +5 -0
  153. data/lib/middleman/vendor/padrino-helpers-0.10.5/.gitignore +21 -0
  154. data/lib/middleman/vendor/padrino-helpers-0.10.5/.yardopts +1 -0
  155. data/lib/middleman/vendor/padrino-helpers-0.10.5/LICENSE.txt +20 -0
  156. data/lib/middleman/vendor/padrino-helpers-0.10.5/README.rdoc +239 -0
  157. data/lib/middleman/vendor/padrino-helpers-0.10.5/Rakefile +5 -0
  158. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers.rb +58 -0
  159. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/asset_tag_helpers.rb +420 -0
  160. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_builder/abstract_form_builder.rb +220 -0
  161. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_builder/standard_form_builder.rb +43 -0
  162. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_helpers.rb +602 -0
  163. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/format_helpers.rb +381 -0
  164. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/cs.yml +103 -0
  165. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/da.yml +91 -0
  166. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/de.yml +81 -0
  167. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/en.yml +103 -0
  168. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/es.yml +103 -0
  169. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/fr.yml +80 -0
  170. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/hu.yml +103 -0
  171. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/it.yml +89 -0
  172. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/ja.yml +103 -0
  173. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/lv.yml +103 -0
  174. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/nl.yml +82 -0
  175. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/no.yml +91 -0
  176. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/pl.yml +95 -0
  177. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/pt_br.yml +103 -0
  178. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/ru.yml +103 -0
  179. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/tr.yml +103 -0
  180. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/uk.yml +103 -0
  181. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/zh_cn.yml +104 -0
  182. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/zh_tw.yml +103 -0
  183. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/number_helpers.rb +288 -0
  184. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers.rb +175 -0
  185. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/abstract_handler.rb +98 -0
  186. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/erb_handler.rb +79 -0
  187. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/haml_handler.rb +63 -0
  188. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/slim_handler.rb +81 -0
  189. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/render_helpers.rb +60 -0
  190. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/tag_helpers.rb +103 -0
  191. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/translation_helpers.rb +38 -0
  192. data/lib/middleman/vendor/padrino-helpers-0.10.5/padrino-helpers.gemspec +27 -0
  193. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/app.rb +73 -0
  194. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.erb +14 -0
  195. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.haml +12 -0
  196. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.slim +13 -0
  197. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.erb +14 -0
  198. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.haml +12 -0
  199. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.slim +12 -0
  200. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.erb +11 -0
  201. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.haml +9 -0
  202. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.slim +9 -0
  203. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.erb +5 -0
  204. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.haml +5 -0
  205. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.slim +5 -0
  206. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.erb +20 -0
  207. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.haml +15 -0
  208. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.slim +15 -0
  209. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.erb +56 -0
  210. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.haml +47 -0
  211. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.slim +47 -0
  212. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.erb +56 -0
  213. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.haml +45 -0
  214. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.slim +45 -0
  215. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.erb +5 -0
  216. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.haml +4 -0
  217. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.slim +4 -0
  218. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.erb +3 -0
  219. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.haml +3 -0
  220. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.slim +3 -0
  221. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.erb +3 -0
  222. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.haml +3 -0
  223. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.slim +3 -0
  224. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_erb.erb +1 -0
  225. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_haml.haml +1 -0
  226. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_slim.slim +1 -0
  227. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.erb +1 -0
  228. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.haml +1 -0
  229. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.slim +1 -0
  230. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/app.rb +50 -0
  231. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engine.haml +5 -0
  232. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_erb.erb +1 -0
  233. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_haml.haml +1 -0
  234. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_slim.slim +1 -0
  235. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/erb/test.erb +1 -0
  236. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/explicit_engine.haml +5 -0
  237. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/haml/test.haml +1 -0
  238. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/_user.haml +7 -0
  239. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/haml_template.haml +1 -0
  240. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/some_template.haml +2 -0
  241. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/helper.rb +66 -0
  242. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_asset_tag_helpers.rb +320 -0
  243. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_form_builder.rb +996 -0
  244. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_form_helpers.rb +645 -0
  245. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_format_helpers.rb +227 -0
  246. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_locale.rb +20 -0
  247. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_number_helpers.rb +136 -0
  248. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_output_helpers.rb +153 -0
  249. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_render_helpers.rb +76 -0
  250. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb +105 -0
  251. data/lib/middleman/version.rb +1 -1
  252. data/middleman-x86-mingw32.gemspec +16 -33
  253. data/middleman.gemspec +16 -31
  254. metadata +590 -349
  255. data/features/sinatra.feature +0 -6
  256. data/lib/middleman/core_extensions/rack_map.rb +0 -35
  257. data/lib/middleman/renderers/coffee_script.rb +0 -8
  258. data/lib/middleman/renderers/haml.rb +0 -31
  259. data/lib/middleman/renderers/slim.rb +0 -8
@@ -1,137 +1,70 @@
1
- # require 'sinatra/synchrony'
2
-
1
+ require "rack"
2
+ require "tilt"
3
3
  require "i18n"
4
-
4
+ require "middleman/vendor/hooks-0.2.0/lib/hooks"
5
+
5
6
  require "active_support"
6
7
  require "active_support/json"
7
- require "active_support/core_ext/class/attribute_accessors"
8
+ require "active_support/core_ext/string/inflections"
8
9
 
9
- module Middleman::Base
10
+ class Middleman::Base
11
+ include Hooks
12
+ define_hook :before
13
+ define_hook :ready
14
+ define_hook :initialized
15
+
10
16
  class << self
11
- def registered(app)
12
- # app.register ::Sinatra::Synchrony
13
-
14
- app.extend ClassMethods
15
- app.send :include, InstanceMethods
16
-
17
- # Basic Sinatra config
18
- app.set :app_file, __FILE__
19
- app.set :root, Dir.pwd
20
- app.set :sessions, false
21
- app.set :logging, false
22
- app.set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development
23
-
24
- # Middleman-specific options
25
- app.set :index_file, "index.html" # What file responds to folder requests
26
- # Such as the homepage (/) or subfolders (/about/)
27
-
28
- # These directories are passed directly to Compass
29
- app.set :js_dir, "javascripts" # Where to look for javascript files
30
- app.set :css_dir, "stylesheets" # Where to look for CSS files
31
- app.set :images_dir, "images" # Where to look for images
32
-
33
- app.set :build_dir, "build" # Which folder are builds output to
34
- app.set :http_prefix, nil # During build, add a prefix for absolute paths
35
-
36
- # Pass all request to Middleman, even "static" files
37
- app.set :static, false
38
-
39
- app.set :views, "source"
40
-
41
- # Add Builder Callbacks
42
- app.register Middleman::CoreExtensions::Builder
43
-
44
- # Add Rack::Builder.map to Sinatra
45
- app.register Middleman::CoreExtensions::RackMap
46
-
47
- # Activate custom features
48
- app.register Middleman::CoreExtensions::Features
49
-
50
- # Activate Yaml Data package
51
- app.register Middleman::CoreExtensions::Data
52
-
53
- # Setup custom rendering
54
- app.register Middleman::CoreExtensions::Rendering
55
-
56
- # Compass framework
57
- app.register Middleman::CoreExtensions::Compass
58
-
59
- # Sprockets asset handling
60
- app.register Middleman::CoreExtensions::Sprockets
61
-
62
- # Setup asset path pipeline
63
- app.register Middleman::CoreExtensions::Assets
64
-
65
- # Activate built-in helpers
66
- app.register Middleman::CoreExtensions::DefaultHelpers
67
-
68
- # with_layout and page routing
69
- app.register Middleman::CoreExtensions::Routing
70
-
71
- # Parse YAML from templates
72
- app.register Middleman::CoreExtensions::FrontMatter
73
-
74
- app.set :default_features, [
75
- :lorem
76
- ]
77
-
78
- # Default layout name
79
- app.set :layout, :layout
80
-
81
- # This will match all requests not overridden in the project's config.rb
82
- app.not_found do
83
- process_request
84
- end
85
-
86
- # Custom 404 handler (to be styled)
87
- app.error Sinatra::NotFound do
88
- content_type 'text/html'
89
- "<html><body><h1>File Not Found</h1><p>#{request.path_info}</p></body>"
90
- end
91
-
92
- # See if Tilt cannot handle this file
93
- app.before_processing(:base) do |result|
94
- request_path = request.path_info.gsub("%20", " ")
95
- should_be_ignored = !(request["is_proxy"]) && settings.excluded_paths.include?("/#{request_path}")
96
-
97
- if result && !should_be_ignored
98
- extensionless_path, template_engine = result
17
+ def reset!
18
+ @app = nil
19
+ @prototype = nil
20
+ end
21
+
22
+ def app
23
+ @app ||= Rack::Builder.new
24
+ end
25
+
26
+ def inst(&block)
27
+ @inst ||= new(&block)
28
+ end
29
+
30
+ def to_rack_app(&block)
31
+ inner_app = inst(&block)
32
+ app.map("/") { run inner_app }
33
+ app
34
+ end
35
+
36
+ def prototype
37
+ @prototype ||= app.to_app
38
+ end
99
39
 
100
- # Return static files
101
- if !::Tilt.mappings.has_key?(template_engine.to_s)
102
- matched_mime = mime_type(File.extname(request_path))
103
- matched_mime = "application/octet-stream" if matched_mime.nil?
104
- content_type matched_mime, :charset => 'utf-8'
105
- status 200
106
- send_file File.join(settings.views, request_path)
107
- false
108
- else
109
- true
110
- end
111
- else
112
- if !%w(favicon.ico).include?(request_path)
113
- $stderr.puts "File not found: #{request_path}"
114
- end
115
-
116
- status 404
117
- false
118
- end
119
- end
40
+ def call(env)
41
+ prototype.call(env)
42
+ end
43
+
44
+ def use(middleware, *args, &block)
45
+ app.use(middleware, *args, &block)
120
46
  end
121
- alias :included :registered
122
- end
123
-
124
- module ClassMethods
125
- # Override Sinatra's set to accept a block
126
- # Specifically for the asset_host feature
127
- def set(option, value = (not_set = true), ignore_setter = false, &block)
128
- if block_given?
129
- value = Proc.new { block }
130
- end
131
47
 
132
- super(option, value, ignore_setter, &nil)
48
+ def map(map, &block)
49
+ app.map(map, &block)
133
50
  end
134
51
 
52
+ def helpers(*extensions, &block)
53
+ class_eval(&block) if block_given?
54
+ include(*extensions) if extensions.any?
55
+ end
56
+
57
+ def defaults
58
+ @defaults ||= {}
59
+ end
60
+
61
+ def set(key, value)
62
+ @defaults ||= {}
63
+ @defaults[key] = value
64
+ end
65
+
66
+ def asset_stamp; false; end
67
+
135
68
  def before_processing(name=:unnamed, idx=-1, &block)
136
69
  @before_processes ||= []
137
70
  @before_processes.insert(idx, [name, block])
@@ -144,64 +77,373 @@ module Middleman::Base
144
77
  inst.instance_exec(resolved_template, &block)
145
78
  end
146
79
  end
80
+ end
81
+
82
+ def set(key, value=nil, &block)
83
+ setter = "#{key}=".to_sym
84
+ self.class.send(:attr_accessor, key) if !respond_to?(setter)
85
+ value = block if block_given?
86
+ send(setter, value)
87
+ end
88
+
89
+ # Basic Sinatra config
90
+ set :root, Dir.pwd
91
+ set :source, "source"
92
+ set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development
93
+ set :logging, false
94
+
95
+ # Middleman-specific options
96
+ set :index_file, "index.html" # What file responds to folder requests
97
+ # Such as the homepage (/) or subfolders (/about/)
98
+
99
+ # These directories are passed directly to Compass
100
+ set :js_dir, "javascripts" # Where to look for javascript files
101
+ set :css_dir, "stylesheets" # Where to look for CSS files
102
+ set :images_dir, "images" # Where to look for images
103
+
104
+ set :build_dir, "build" # Which folder are builds output to
105
+ set :http_prefix, nil # During build, add a prefix for absolute paths
106
+
107
+ set :views, "source"
108
+
109
+ set :default_features, [
110
+ :lorem,
111
+ # :sitemap_tree
112
+ ]
113
+
114
+ # Default layout name
115
+ set :layout, :layout
116
+
117
+ # Activate custom features and extensions
118
+ include Middleman::CoreExtensions::Features
119
+
120
+ # Add Builder Callbacks
121
+ register Middleman::CoreExtensions::Builder
122
+
123
+ # Add Guard Callbacks
124
+ register Middleman::CoreExtensions::FileWatcher
125
+
126
+ # Sitemap
127
+ register Middleman::CoreExtensions::Sitemap
128
+
129
+ # Activate Data package
130
+ register Middleman::CoreExtensions::Data
131
+
132
+ # Setup custom rendering
133
+ register Middleman::CoreExtensions::Rendering
134
+
135
+ # Compass framework
136
+ register Middleman::CoreExtensions::Compass
137
+
138
+ # Sprockets asset handling
139
+ register Middleman::CoreExtensions::Sprockets
140
+
141
+ # Setup asset path pipeline
142
+ register Middleman::CoreExtensions::Assets
143
+
144
+ # Activate built-in helpers
145
+ register Middleman::CoreExtensions::DefaultHelpers
146
+
147
+ # with_layout and page routing
148
+ register Middleman::CoreExtensions::Routing
149
+
150
+ # Parse YAML from templates
151
+ register Middleman::CoreExtensions::FrontMatter
152
+
153
+ def initialize(&block)
154
+ self.class.superclass.defaults.each do |k, v|
155
+ set(k, v)
156
+ end
157
+
158
+ instance_exec(&block) if block_given?
159
+
160
+ set :source_dir, File.join(root, source)
161
+
162
+ super
147
163
 
148
- # Convenience method to check if we're in build mode
149
- def build?; environment == :build; end
164
+ run_hook :initialized
150
165
  end
151
166
 
152
- module InstanceMethods
153
- def forward
154
- raise ::Sinatra::NotFound
167
+ attr :env
168
+ attr :req
169
+ attr :res
170
+ attr :options
171
+ attr :locals
172
+
173
+ def call(env)
174
+ @env = env
175
+ @req = Rack::Request.new(env)
176
+ @res = Rack::Response.new
177
+
178
+ catch(:halt) do
179
+ process_request
180
+
181
+ res.status = 404
182
+ res.finish
155
183
  end
184
+ end
185
+
186
+ def halt(response)
187
+ throw :halt, response
188
+ end
189
+
190
+ # Convenience methods to check if we're in a mode
191
+ def development?; environment == :development; end
192
+ def build?; environment == :build; end
156
193
 
157
- # Internal method to look for templates and evaluate them if found
158
- def process_request(options={})
159
- if !settings.views.include?(settings.root)
160
- settings.set :views, File.join(settings.root, settings.views)
161
- end
194
+ # Internal method to look for templates and evaluate them if found
195
+ def process_request
196
+ # Normalize the path and add index if we're looking at a directory
197
+ @original_path = env["PATH_INFO"].dup
198
+ @request_path = full_path(env["PATH_INFO"].gsub("%20", " "))
199
+
200
+ run_hook :before
201
+
202
+ return not_found if sitemap.ignored_path?(@request_path)
203
+
204
+ if sitemap.path_is_proxy?(@request_path)
205
+ @request_path = "/" + sitemap.path_target(@request_path)
206
+ end
207
+
208
+ found_template = resolve_template(@request_path)
209
+ return not_found unless found_template
210
+
211
+ @current_path = @request_path.dup
212
+ path, engine = found_template
213
+
214
+ # Static File
215
+ return send_file(path) if engine.nil?
216
+
217
+ return unless self.class.execute_before_processing!(self, found_template)
218
+
219
+ context = sitemap.get_context(full_path(@original_path.gsub("%20", " "))) || {}
220
+
221
+ @options = context.has_key?(:options) ? context[:options] : {}
222
+ @locals = context.has_key?(:locals) ? context[:locals] : {}
223
+
224
+ provides_metadata.each do |callback, matcher|
225
+ next if !matcher.nil? && !path.match(matcher)
226
+ instance_exec(path, &callback)
227
+ end
228
+
229
+ local_layout = if options.has_key?(:layout)
230
+ options[:layout]
231
+ elsif %w(.js .css .txt).include?(File.extname(@request_path))
232
+ false
233
+ else
234
+ layout
235
+ end
236
+
237
+ if context.has_key?(:block) && context[:block]
238
+ instance_eval(&context[:block])
239
+ end
240
+
241
+ output = if local_layout
242
+ engine_options = respond_to?(engine.to_sym) ? send(engine.to_sym) : {}
162
243
 
163
- # Normalize the path and add index if we're looking at a directory
164
- request.path_info = self.class.path_to_index(request.path)
244
+ layout_engine = if options.has_key?(:layout_engine)
245
+ options[:layout_engine]
246
+ elsif engine_options.has_key?(:layout_engine)
247
+ engine_options[:layout_engine]
248
+ else
249
+ engine
250
+ end
165
251
 
166
- request_path = request.path_info.gsub("%20", " ")
167
- found_template = resolve_template(request_path, :raise_exceptions => false)
168
- return status(404) unless found_template
169
- return unless settings.execute_before_processing!(self, found_template)
252
+ layout_path, *etc = resolve_template(local_layout, :preferred_engine => layout_engine)
170
253
 
171
- options.merge!(request['custom_options'] || {})
172
-
173
- old_layout = settings.layout
174
- settings.set :layout, options[:layout] if !options[:layout].nil?
175
-
176
- local_layout = if settings.layout
177
- if options[:layout] == false || request.path_info =~ /\.(css|js)$/
178
- false
254
+ if !layout_path
255
+ local_layout = File.join("layouts", local_layout.to_s)
256
+ layout_path, *etc = resolve_template(local_layout, :preferred_engine => layout_engine)
257
+ end
258
+
259
+ throw "Could not locate layout: #{local_layout}" unless layout_path
260
+
261
+ render(layout_path, locals, options) do
262
+ render(path, locals, options)
263
+ end
264
+ else
265
+ render(path, locals)
266
+ end
267
+
268
+ content_type mime_type(File.extname(@request_path))
269
+ res.status = 200
270
+ res.write output
271
+ halt res.finish
272
+ end
273
+
274
+ public
275
+ def extensionless_path(file)
276
+ @_extensionless_path_cache ||= {}
277
+
278
+ if @_extensionless_path_cache.has_key?(file)
279
+ @_extensionless_path_cache[file]
280
+ else
281
+ path = file.dup
282
+ end_of_the_line = false
283
+ while !end_of_the_line
284
+ if !Tilt[path].nil?
285
+ path = path.sub(File.extname(path), "")
179
286
  else
180
- settings.fetch_layout_path(settings.layout).to_sym
287
+ end_of_the_line = true
181
288
  end
182
- else
183
- false
184
289
  end
290
+
291
+ @_extensionless_path_cache[file] = path
292
+ path
293
+ end
294
+ end
185
295
 
186
- render_options = { :layout => local_layout }
187
- render_options[:layout_engine] = options[:layout_engine] if options.has_key? :layout_engine
296
+ def logging?
297
+ logging
298
+ end
299
+
300
+ def current_path
301
+ @current_path || nil
302
+ end
303
+
304
+ def raw_templates_cache
305
+ @_raw_templates_cache ||= {}
306
+ end
307
+
308
+ def read_raw_template(path)
309
+ if raw_templates_cache.has_key?(path)
310
+ raw_templates_cache[path]
311
+ else
312
+ File.read(path)
313
+ end
314
+ end
315
+
316
+ def map(map, &block)
317
+ self.class.map(map, &block)
318
+ end
319
+
320
+ def full_path(path)
321
+ parts = path ? path.split('/') : []
322
+ if parts.last.nil? || parts.last.split('.').length == 1
323
+ path = File.join(path, index_file)
324
+ end
325
+ "/" + path.sub(%r{^/}, '')
326
+ end
327
+
328
+ def not_found
329
+ @res.status == 404
330
+ @res.write "<html><body><h1>File Not Found</h1><p>#{@request_path}</p></body>"
331
+ @res.finish
332
+ end
333
+
334
+ def resolve_template(request_path, options={})
335
+ request_path = request_path.to_s
336
+ @_resolved_templates ||= {}
337
+ if !@_resolved_templates.has_key?(request_path)
338
+ relative_path = request_path.sub(%r{^/}, "")
339
+ on_disk_path = File.expand_path(relative_path, source_dir)
188
340
 
189
- path, engine = found_template
190
- locals = request['custom_locals'] || {}
341
+ preferred_engine = if options.has_key?(:preferred_engine)
342
+ extension_class = Tilt[options[:preferred_engine]]
343
+ matched_exts = []
344
+
345
+ # TODO: Cache this
346
+ Tilt.mappings.each do |ext, engines|
347
+ next unless engines.include? extension_class
348
+ matched_exts << ext
349
+ end
350
+
351
+ "{" + matched_exts.join(",") + "}"
352
+ else
353
+ "*"
354
+ end
191
355
 
192
- begin
193
- result = render(engine, path, render_options, locals)
356
+ path_with_ext = on_disk_path + "." + preferred_engine
357
+
358
+ found_path = Dir[path_with_ext].find do |path|
359
+ ::Tilt[path]
360
+ end
361
+
362
+ result = if found_path || File.exists?(on_disk_path)
363
+ engine = found_path ? File.extname(found_path)[1..-1].to_sym : nil
364
+ [ found_path || on_disk_path, engine ]
365
+ else
366
+ false
367
+ end
194
368
 
195
- if result
196
- content_type mime_type(File.extname(request_path)), :charset => 'utf-8'
197
- status 200
198
- body result
199
- end
200
- # rescue
201
- # status(404)
202
- ensure
203
- settings.set :layout, old_layout
369
+ @_resolved_templates[request_path] = result
370
+ end
371
+
372
+ @_resolved_templates[request_path]
373
+ end
374
+
375
+ def send_file(path)
376
+ matched_mime = mime_type(File.extname(path))
377
+ matched_mime = "application/octet-stream" if matched_mime.nil?
378
+ content_type matched_mime
379
+
380
+ file = ::Rack::File.new nil
381
+ file.path = path
382
+ halt file.serving(env)
383
+ end
384
+
385
+ def render(path, locals = {}, options = {}, &block)
386
+ path = path.to_s
387
+
388
+ options.merge!(options_for_ext(File.extname(path)))
389
+
390
+ body = read_raw_template(path)
391
+ template = ::Tilt.new(path, 1, options) { body }
392
+ template.render(self, locals, &block)
393
+ end
394
+
395
+ def options_for_ext(ext)
396
+ @_options_for_ext_cache ||= {}
397
+
398
+ if !@_options_for_ext_cache.has_key?(ext)
399
+ options = {}
400
+ extension_class = Tilt[ext]
401
+ matched_exts = []
402
+ Tilt.mappings.each do |ext, engines|
403
+ next unless engines.include? extension_class
404
+ engine_options = respond_to?(ext.to_sym) ? send(ext.to_sym) : {}
405
+ options.merge!(engine_options)
204
406
  end
407
+
408
+ @_options_for_ext_cache[ext] = options
409
+ end
410
+
411
+ @_options_for_ext_cache[ext]
412
+ end
413
+
414
+ def mime_type(type, value=nil)
415
+ return type if type.nil? || type.to_s.include?('/')
416
+ type = ".#{type}" unless type.to_s[0] == ?.
417
+ return ::Rack::Mime.mime_type(type, nil) unless value
418
+ ::Rack::Mime::MIME_TYPES[type] = value
419
+ end
420
+
421
+ def content_type(type = nil, params={})
422
+ return res['Content-Type'] unless type
423
+ default = params.delete :default
424
+ mime_type = mime_type(type) || default
425
+ throw "Unknown media type: %p" % type if mime_type.nil?
426
+ mime_type = mime_type.dup
427
+ unless params.include? :charset
428
+ params[:charset] = params.delete('charset') || "utf-8"
429
+ end
430
+ params.delete :charset if mime_type.include? 'charset'
431
+ unless params.empty?
432
+ mime_type << (mime_type.include?(';') ? ', ' : ';')
433
+ mime_type << params.map { |kv| kv.join('=') }.join(', ')
205
434
  end
435
+ res['Content-Type'] = mime_type
436
+ end
437
+
438
+ def helpers(*extensions, &block)
439
+ self.class.helpers(*extensions, &block)
440
+ end
441
+
442
+ def use(middleware, *args, &block)
443
+ self.class.use(middleware, *args, &block)
444
+ end
445
+
446
+ def map(map, &block)
447
+ self.class.map(map, &block)
206
448
  end
207
449
  end