middleman 3.0.0.alpha.6 → 3.0.0.alpha.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (635) hide show
  1. data/lib/middleman.rb +3 -243
  2. data/middleman.gemspec +3 -32
  3. metadata +21 -1350
  4. data/.gemtest +0 -0
  5. data/.gitignore +0 -16
  6. data/.travis.yml +0 -5
  7. data/.yardopts +0 -11
  8. data/CHANGELOG.md +0 -101
  9. data/Gemfile +0 -3
  10. data/LICENSE +0 -20
  11. data/README.md +0 -93
  12. data/Rakefile +0 -17
  13. data/bin/middleman +0 -64
  14. data/features/3rd_party_cli.feature +0 -5
  15. data/features/asset_host.feature +0 -14
  16. data/features/auto_layout.feature +0 -37
  17. data/features/automatic_image_sizes.feature +0 -16
  18. data/features/builder.feature +0 -56
  19. data/features/cache_buster.feature +0 -26
  20. data/features/chained_templates.feature +0 -19
  21. data/features/clean_build.feature +0 -31
  22. data/features/cli.feature +0 -120
  23. data/features/coffee-script.feature +0 -17
  24. data/features/content_for.feature +0 -16
  25. data/features/current_page_request_path_backwards.feature +0 -6
  26. data/features/custom_layout_engines.feature +0 -13
  27. data/features/data.feature +0 -27
  28. data/features/directory_index.feature +0 -36
  29. data/features/dynamic_pages.feature +0 -35
  30. data/features/fonts.feature +0 -13
  31. data/features/former_padrino_helpers.feature +0 -10
  32. data/features/front-matter.feature +0 -35
  33. data/features/helpers_auto_javascript_include_tag.feature +0 -27
  34. data/features/helpers_auto_stylesheet_link_tag.feature +0 -27
  35. data/features/helpers_external.feature +0 -6
  36. data/features/helpers_lorem.feature +0 -5
  37. data/features/helpers_page_classes.feature +0 -17
  38. data/features/instance_vars.feature +0 -20
  39. data/features/liquid.feature +0 -6
  40. data/features/markdown.feature +0 -27
  41. data/features/minify_css.feature +0 -29
  42. data/features/minify_javascript.feature +0 -55
  43. data/features/mount_rack.feature +0 -8
  44. data/features/nested_layouts.feature +0 -24
  45. data/features/page_alias_and_layouts.feature +0 -44
  46. data/features/partials.feature +0 -41
  47. data/features/preview_changes.feature +0 -18
  48. data/features/relative_assets.feature +0 -50
  49. data/features/scss-support.feature +0 -12
  50. data/features/sitemap_traversal.features +0 -56
  51. data/features/slim.feature +0 -7
  52. data/features/sprockets.feature +0 -52
  53. data/features/sprockets_gems.feature +0 -10
  54. data/features/step_definitions/asset_host_steps.rb +0 -9
  55. data/features/step_definitions/page_layout_steps.rb +0 -15
  56. data/features/support/env.rb +0 -3
  57. data/features/wildcard_page_helper.feature +0 -19
  58. data/fixtures/3rd-party-command/config.rb +0 -10
  59. data/fixtures/build-with-errors-app/config.rb +0 -1
  60. data/fixtures/build-with-errors-app/source/index.html.erb +0 -1
  61. data/fixtures/chained-app/config.rb +0 -0
  62. data/fixtures/chained-app/data/article.yml +0 -2
  63. data/fixtures/chained-app/source/index.html.markdown.erb +0 -8
  64. data/fixtures/clean-app/config-complications.rb +0 -11
  65. data/fixtures/clean-app/config-empty.rb +0 -0
  66. data/fixtures/clean-app/config.rb +0 -11
  67. data/fixtures/clean-app/source/index.html.haml +0 -1
  68. data/fixtures/clean-app/source/layout.haml +0 -6
  69. data/fixtures/clean-app/source/layouts/custom.haml +0 -5
  70. data/fixtures/clean-app/source/real.html +0 -1
  71. data/fixtures/clean-app/source/real/index.html.erb +0 -5
  72. data/fixtures/clean-app/source/should_be_ignored.html +0 -1
  73. data/fixtures/clean-app/source/should_be_ignored2.html +0 -1
  74. data/fixtures/clean-app/source/should_be_ignored3.html +0 -1
  75. data/fixtures/clean-app/source/static.html +0 -1
  76. data/fixtures/clean-dir-app/config.rb +0 -2
  77. data/fixtures/clean-dir-app/source/about.html +0 -1
  78. data/fixtures/custom-layout-app/config.rb +0 -1
  79. data/fixtures/custom-layout-app/source/index.html.erb +0 -1
  80. data/fixtures/custom-layout-app/source/layout.haml +0 -6
  81. data/fixtures/data-app/config.rb +0 -3
  82. data/fixtures/data-app/data/pages.yml +0 -6
  83. data/fixtures/data-app/source/index.html.haml +0 -1
  84. data/fixtures/data-app/source/layout.haml +0 -3
  85. data/fixtures/different-engine-layout/config.rb +0 -0
  86. data/fixtures/different-engine-layout/source/index.html.haml +0 -1
  87. data/fixtures/different-engine-layout/source/layout.erb +0 -9
  88. data/fixtures/different-engine-partial/config.rb +0 -0
  89. data/fixtures/different-engine-partial/source/index.html.erb +0 -1
  90. data/fixtures/different-engine-partial/source/layouts/layout.erb +0 -7
  91. data/fixtures/different-engine-partial/source/shared/_footer.slim +0 -1
  92. data/fixtures/different-engine-partial/source/shared/_header.erb +0 -1
  93. data/fixtures/empty-app/not-config.rb +0 -0
  94. data/fixtures/engine-matching-layout/config.rb +0 -0
  95. data/fixtures/engine-matching-layout/source/index.html.erb +0 -1
  96. data/fixtures/engine-matching-layout/source/layout.erb +0 -9
  97. data/fixtures/external-helpers/config.rb +0 -4
  98. data/fixtures/external-helpers/lib/hello_helper.rb +0 -5
  99. data/fixtures/external-helpers/source/index.html.erb +0 -1
  100. data/fixtures/fonts-app/config.rb +0 -0
  101. data/fixtures/fonts-app/source/fonts/StMarie-Thin.otf +0 -0
  102. data/fixtures/fonts-app/source/stylesheets/fonts.css.sass +0 -3
  103. data/fixtures/glob-app/config.rb +0 -1
  104. data/fixtures/glob-app/source/index.html.haml +0 -6
  105. data/fixtures/glob-app/source/stylesheets/site.css.sass +0 -1
  106. data/fixtures/ignore-app/config.rb +0 -2
  107. data/fixtures/ignore-app/source/articles/template.html.erb +0 -1
  108. data/fixtures/ignore-app/source/template.html.erb +0 -1
  109. data/fixtures/indexable-app/config.rb +0 -2
  110. data/fixtures/indexable-app/source/.htaccess +0 -1
  111. data/fixtures/indexable-app/source/a_folder/needs_index.html +0 -1
  112. data/fixtures/indexable-app/source/leave_me_alone.html +0 -1
  113. data/fixtures/indexable-app/source/needs_index.html +0 -1
  114. data/fixtures/indexable-app/source/regular/index.html +0 -1
  115. data/fixtures/instance-vars-app/config.rb +0 -0
  116. data/fixtures/instance-vars-app/source/_vartial.erb +0 -5
  117. data/fixtures/instance-vars-app/source/instance-var-set.html.erb +0 -2
  118. data/fixtures/instance-vars-app/source/layout.erb +0 -3
  119. data/fixtures/instance-vars-app/source/no-instance-var.html.erb +0 -1
  120. data/fixtures/manual-layout-missing/config.rb +0 -1
  121. data/fixtures/manual-layout-missing/source/index.html.erb +0 -1
  122. data/fixtures/manual-layout-override/config.rb +0 -3
  123. data/fixtures/manual-layout-override/source/index.html.erb +0 -1
  124. data/fixtures/manual-layout-override/source/layouts/another.erb +0 -9
  125. data/fixtures/manual-layout-override/source/layouts/custom.erb +0 -9
  126. data/fixtures/manual-layout/config.rb +0 -1
  127. data/fixtures/manual-layout/source/index.html.erb +0 -1
  128. data/fixtures/manual-layout/source/layouts/custom.erb +0 -9
  129. data/fixtures/markdown-app/config.rb +0 -9
  130. data/fixtures/markdown-app/source/autolink.html.markdown +0 -5
  131. data/fixtures/markdown-app/source/fenced_code_blocks.html.markdown +0 -7
  132. data/fixtures/markdown-app/source/index.html.markdown +0 -4
  133. data/fixtures/markdown-app/source/no_intra_emphasis.html.markdown +0 -5
  134. data/fixtures/markdown-app/source/smarty_pants.html.markdown +0 -5
  135. data/fixtures/markdown-app/source/space_after_headers.html.markdown +0 -5
  136. data/fixtures/markdown-app/source/strikethrough.html.markdown +0 -5
  137. data/fixtures/markdown-app/source/superscript.html.markdown +0 -5
  138. data/fixtures/markdown-app/source/tables.html.markdown +0 -8
  139. data/fixtures/multiple-layouts/config.rb +0 -0
  140. data/fixtures/multiple-layouts/source/index.html.erb +0 -1
  141. data/fixtures/multiple-layouts/source/layout.erb +0 -9
  142. data/fixtures/multiple-layouts/source/layout.haml +0 -6
  143. data/fixtures/nested-layout-app/config.rb +0 -1
  144. data/fixtures/nested-layout-app/source/data-one.html.erb +0 -5
  145. data/fixtures/nested-layout-app/source/data-two.html.erb +0 -5
  146. data/fixtures/nested-layout-app/source/index.html.erb +0 -1
  147. data/fixtures/nested-layout-app/source/layouts/inner.erb +0 -4
  148. data/fixtures/nested-layout-app/source/layouts/master.erb +0 -3
  149. data/fixtures/nested-layout-app/source/layouts/outer.erb +0 -4
  150. data/fixtures/no-layout/config.rb +0 -0
  151. data/fixtures/no-layout/source/index.html.erb +0 -1
  152. data/fixtures/partials-app/config.rb +0 -0
  153. data/fixtures/partials-app/source/_locals.erb +0 -1
  154. data/fixtures/partials-app/source/_main.erb +0 -1
  155. data/fixtures/partials-app/source/_main.haml +0 -1
  156. data/fixtures/partials-app/source/index.html.erb +0 -3
  157. data/fixtures/partials-app/source/locals.html.erb +0 -1
  158. data/fixtures/partials-app/source/second.html.haml +0 -3
  159. data/fixtures/partials-app/source/shared/_footer.erb +0 -1
  160. data/fixtures/partials-app/source/shared/_header.erb +0 -1
  161. data/fixtures/partials-app/source/sub/_local.erb +0 -1
  162. data/fixtures/partials-app/source/sub/index.html.erb +0 -3
  163. data/fixtures/passthrough-app/config.rb +0 -17
  164. data/fixtures/passthrough-app/source/.htaccess +0 -1
  165. data/fixtures/passthrough-app/source/inline-coffeescript.html.haml +0 -3
  166. data/fixtures/passthrough-app/source/inline-css.html.haml +0 -4
  167. data/fixtures/passthrough-app/source/inline-js.html.haml +0 -7
  168. data/fixtures/passthrough-app/source/javascripts/coffee_test.js.coffee +0 -3
  169. data/fixtures/passthrough-app/source/javascripts/js_test.js +0 -8
  170. data/fixtures/passthrough-app/source/stylesheets/site.css.sass +0 -1
  171. data/fixtures/preview-app/config.rb +0 -0
  172. data/fixtures/preview-app/source/content.html.erb +0 -1
  173. data/fixtures/preview-app/source/layout.erb +0 -1
  174. data/fixtures/relative-app/config.rb +0 -0
  175. data/fixtures/relative-app/source/images/blank.gif +0 -0
  176. data/fixtures/relative-app/source/stylesheets/relative_assets.css.sass +0 -3
  177. data/fixtures/sinatra-app/config.rb +0 -11
  178. data/fixtures/sinatra-app/source/index.html.erb +0 -5
  179. data/fixtures/sprockets-app/config.rb +0 -2
  180. data/fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss +0 -1
  181. data/fixtures/sprockets-app/source/library/css/plain.css +0 -3
  182. data/fixtures/sprockets-app/source/library/css/sprockets_base1.css.scss +0 -1
  183. data/fixtures/sprockets-app/source/library/css/sprockets_base2.css.scss +0 -1
  184. data/fixtures/sprockets-app/source/library/css/sprockets_sub.css.scss +0 -1
  185. data/fixtures/sprockets-app/source/library/js/jquery_include.js +0 -1
  186. data/fixtures/sprockets-app/source/library/js/plain.js +0 -3
  187. data/fixtures/sprockets-app/source/library/js/sprockets_base.js +0 -5
  188. data/fixtures/sprockets-app/source/library/js/sprockets_sub.js +0 -3
  189. data/fixtures/test-app/config.rb +0 -59
  190. data/fixtures/test-app/data/test.yml +0 -4
  191. data/fixtures/test-app/data/test2.json +0 -4
  192. data/fixtures/test-app/source/.htaccess +0 -1
  193. data/fixtures/test-app/source/_liquid_partial.liquid +0 -1
  194. data/fixtures/test-app/source/_partial.haml +0 -1
  195. data/fixtures/test-app/source/a_folder/needs_index.html +0 -1
  196. data/fixtures/test-app/source/asset_host.html.haml +0 -1
  197. data/fixtures/test-app/source/auto-css.html.haml +0 -1
  198. data/fixtures/test-app/source/auto-css/auto-css.html.haml +0 -1
  199. data/fixtures/test-app/source/auto-css/index.html.haml +0 -1
  200. data/fixtures/test-app/source/auto-css/sub/auto-css.html.haml +0 -1
  201. data/fixtures/test-app/source/auto-image-sizes.html.haml +0 -1
  202. data/fixtures/test-app/source/auto-js.html.haml +0 -1
  203. data/fixtures/test-app/source/auto-js/auto-js.html.haml +0 -1
  204. data/fixtures/test-app/source/auto-js/index.html.haml +0 -1
  205. data/fixtures/test-app/source/auto-js/sub/auto-js.html.haml +0 -1
  206. data/fixtures/test-app/source/cache-buster.html.haml +0 -2
  207. data/fixtures/test-app/source/content_for_erb.html.erb +0 -5
  208. data/fixtures/test-app/source/content_for_haml.html.haml +0 -4
  209. data/fixtures/test-app/source/content_for_slim.html.slim +0 -4
  210. data/fixtures/test-app/source/custom-layout-dir/index.html.haml +0 -1
  211. data/fixtures/test-app/source/custom-layout.html.haml +0 -1
  212. data/fixtures/test-app/source/data.html.erb +0 -1
  213. data/fixtures/test-app/source/data2.html.liquid +0 -2
  214. data/fixtures/test-app/source/data3.html.erb +0 -1
  215. data/fixtures/test-app/source/former_padrino_test.html.haml +0 -5
  216. data/fixtures/test-app/source/front-matter-2.php.erb +0 -7
  217. data/fixtures/test-app/source/front-matter-change.html.erb +0 -5
  218. data/fixtures/test-app/source/front-matter.html.erb +0 -6
  219. data/fixtures/test-app/source/images/Child folder/regular_file(example).txt +0 -1
  220. data/fixtures/test-app/source/images/Chrome_Logo.svg +0 -231
  221. data/fixtures/test-app/source/images/Read me (example).txt +0 -1
  222. data/fixtures/test-app/source/images/blank.gif +0 -0
  223. data/fixtures/test-app/source/images/cfb_tomb-perennial-energy.svgz +0 -0
  224. data/fixtures/test-app/source/img/blank.gif +0 -0
  225. data/fixtures/test-app/source/index.html.slim +0 -9
  226. data/fixtures/test-app/source/inline-coffeescript.html.haml +0 -3
  227. data/fixtures/test-app/source/inline-css.html.haml +0 -4
  228. data/fixtures/test-app/source/inline-js.html.haml +0 -7
  229. data/fixtures/test-app/source/javascripts/auto-js.js +0 -1
  230. data/fixtures/test-app/source/javascripts/auto-js/auto-js.js +0 -1
  231. data/fixtures/test-app/source/javascripts/auto-js/index.js +0 -1
  232. data/fixtures/test-app/source/javascripts/auto-js/sub/auto-js.js +0 -1
  233. data/fixtures/test-app/source/javascripts/broken-coffee.js.coffee +0 -3
  234. data/fixtures/test-app/source/javascripts/coffee_test.js.coffee +0 -3
  235. data/fixtures/test-app/source/javascripts/jquery.plugin.with.dots.js +0 -1
  236. data/fixtures/test-app/source/javascripts/jquery_base.js +0 -5
  237. data/fixtures/test-app/source/javascripts/js_test.js +0 -8
  238. data/fixtures/test-app/source/javascripts/multiple_engines.js.coffee.erb +0 -1
  239. data/fixtures/test-app/source/javascripts/sprockets_base.js +0 -5
  240. data/fixtures/test-app/source/javascripts/sprockets_sub.js +0 -3
  241. data/fixtures/test-app/source/layout.haml +0 -6
  242. data/fixtures/test-app/source/layouts/content_for.erb +0 -4
  243. data/fixtures/test-app/source/layouts/custom.haml +0 -5
  244. data/fixtures/test-app/source/liquid_master.html.liquid +0 -1
  245. data/fixtures/test-app/source/lorem.html.erb +0 -12
  246. data/fixtures/test-app/source/needs_index.html +0 -1
  247. data/fixtures/test-app/source/page-classes.html.haml +0 -1
  248. data/fixtures/test-app/source/real.html +0 -1
  249. data/fixtures/test-app/source/real/index.html.erb +0 -5
  250. data/fixtures/test-app/source/relative_image.html.erb +0 -1
  251. data/fixtures/test-app/source/request-path.html.erb +0 -1
  252. data/fixtures/test-app/source/services/index.html.haml +0 -1
  253. data/fixtures/test-app/source/should_be_ignored.html +0 -1
  254. data/fixtures/test-app/source/should_be_ignored2.html +0 -1
  255. data/fixtures/test-app/source/should_be_ignored3.html +0 -1
  256. data/fixtures/test-app/source/slim.html.slim +0 -7
  257. data/fixtures/test-app/source/spaces in file.html.erb +0 -1
  258. data/fixtures/test-app/source/static.html +0 -1
  259. data/fixtures/test-app/source/stylesheets/asset_host.css.sass +0 -3
  260. data/fixtures/test-app/source/stylesheets/auto-css.css +0 -3
  261. data/fixtures/test-app/source/stylesheets/auto-css/auto-css.css +0 -3
  262. data/fixtures/test-app/source/stylesheets/auto-css/index.css +0 -0
  263. data/fixtures/test-app/source/stylesheets/auto-css/sub/auto-css.css +0 -3
  264. data/fixtures/test-app/source/stylesheets/layout.css.sass +0 -2
  265. data/fixtures/test-app/source/stylesheets/relative_assets.css.sass +0 -3
  266. data/fixtures/test-app/source/stylesheets/site.css.sass +0 -1
  267. data/fixtures/test-app/source/stylesheets/site_scss.css.scss +0 -1
  268. data/fixtures/test-app/source/stylesheets/sprockets_base1.css.scss +0 -1
  269. data/fixtures/test-app/source/stylesheets/sprockets_base2.css.scss +0 -1
  270. data/fixtures/test-app/source/stylesheets/sprockets_sub.css.scss +0 -1
  271. data/fixtures/test-app/source/stylesheets/static.css +0 -2
  272. data/fixtures/test-app/source/sub1/page-classes.html.haml +0 -1
  273. data/fixtures/test-app/source/sub1/sub2/page-classes.html.haml +0 -1
  274. data/fixtures/test-app/source/tiny_src.html.haml +0 -1
  275. data/fixtures/traversal-app/config.rb +0 -2
  276. data/fixtures/traversal-app/source/index.html.erb +0 -0
  277. data/fixtures/traversal-app/source/layout.erb +0 -13
  278. data/fixtures/traversal-app/source/proxied.html.erb +0 -0
  279. data/fixtures/traversal-app/source/root.html.erb +0 -0
  280. data/fixtures/traversal-app/source/sub/index.html.erb +0 -0
  281. data/fixtures/traversal-app/source/sub/sibling.html.erb +0 -0
  282. data/fixtures/traversal-app/source/sub/sibling2.html.erb +0 -0
  283. data/fixtures/traversal-app/source/sub/sub2/index.html.erb +0 -0
  284. data/fixtures/traversal-app/source/sub/sub3/deep.html.erb +0 -0
  285. data/fixtures/wildcard-app/config.rb +0 -1
  286. data/fixtures/wildcard-app/source/admin/index.html.erb +0 -1
  287. data/fixtures/wildcard-app/source/admin/page.html.erb +0 -1
  288. data/fixtures/wildcard-app/source/index.html.erb +0 -1
  289. data/fixtures/wildcard-app/source/layouts/admin.erb +0 -2
  290. data/fixtures/wildcard-app/source/layouts/layout.erb +0 -2
  291. data/fixtures/wildcard-directory-index-app/config.rb +0 -2
  292. data/fixtures/wildcard-directory-index-app/source/admin/index.html.erb +0 -1
  293. data/fixtures/wildcard-directory-index-app/source/admin/page.html.erb +0 -1
  294. data/fixtures/wildcard-directory-index-app/source/index.html.erb +0 -1
  295. data/fixtures/wildcard-directory-index-app/source/layouts/admin.erb +0 -2
  296. data/fixtures/wildcard-directory-index-app/source/layouts/layout.erb +0 -2
  297. data/lib/middleman/base.rb +0 -497
  298. data/lib/middleman/cache.rb +0 -57
  299. data/lib/middleman/cli.rb +0 -47
  300. data/lib/middleman/cli/build.rb +0 -191
  301. data/lib/middleman/cli/init.rb +0 -47
  302. data/lib/middleman/cli/server.rb +0 -40
  303. data/lib/middleman/core_extensions/assets.rb +0 -30
  304. data/lib/middleman/core_extensions/builder.rb +0 -49
  305. data/lib/middleman/core_extensions/compass.rb +0 -71
  306. data/lib/middleman/core_extensions/data.rb +0 -219
  307. data/lib/middleman/core_extensions/default_helpers.rb +0 -119
  308. data/lib/middleman/core_extensions/extensions.rb +0 -140
  309. data/lib/middleman/core_extensions/file_watcher.rb +0 -83
  310. data/lib/middleman/core_extensions/front_matter.rb +0 -136
  311. data/lib/middleman/core_extensions/rendering.rb +0 -256
  312. data/lib/middleman/core_extensions/routing.rb +0 -69
  313. data/lib/middleman/core_extensions/show_exceptions.rb +0 -16
  314. data/lib/middleman/core_extensions/sitemap.rb +0 -54
  315. data/lib/middleman/core_extensions/sprockets.rb +0 -118
  316. data/lib/middleman/extensions/asset_host.rb +0 -34
  317. data/lib/middleman/extensions/automatic_image_sizes.rb +0 -38
  318. data/lib/middleman/extensions/automatic_image_sizes/fastimage.rb +0 -287
  319. data/lib/middleman/extensions/cache_buster.rb +0 -59
  320. data/lib/middleman/extensions/directory_indexes.rb +0 -62
  321. data/lib/middleman/extensions/lorem.rb +0 -130
  322. data/lib/middleman/extensions/minify_css.rb +0 -17
  323. data/lib/middleman/extensions/minify_css/cssmin.rb +0 -55
  324. data/lib/middleman/extensions/minify_javascript.rb +0 -56
  325. data/lib/middleman/extensions/relative_assets.rb +0 -46
  326. data/lib/middleman/guard.rb +0 -137
  327. data/lib/middleman/renderers/erb.rb +0 -19
  328. data/lib/middleman/renderers/haml.rb +0 -13
  329. data/lib/middleman/renderers/liquid.rb +0 -21
  330. data/lib/middleman/renderers/markdown.rb +0 -28
  331. data/lib/middleman/renderers/sass.rb +0 -53
  332. data/lib/middleman/sitemap/page.rb +0 -162
  333. data/lib/middleman/sitemap/store.rb +0 -143
  334. data/lib/middleman/sitemap/template.rb +0 -77
  335. data/lib/middleman/step_definitions.rb +0 -12
  336. data/lib/middleman/step_definitions/builder_steps.rb +0 -42
  337. data/lib/middleman/step_definitions/middleman_steps.rb +0 -15
  338. data/lib/middleman/step_definitions/server_steps.rb +0 -66
  339. data/lib/middleman/templates.rb +0 -82
  340. data/lib/middleman/templates/default.rb +0 -29
  341. data/lib/middleman/templates/default/source/images/background.png +0 -0
  342. data/lib/middleman/templates/default/source/images/middleman.png +0 -0
  343. data/lib/middleman/templates/default/source/index.html.erb +0 -10
  344. data/lib/middleman/templates/default/source/javascripts/all.js +0 -1
  345. data/lib/middleman/templates/default/source/layouts/layout.erb +0 -19
  346. data/lib/middleman/templates/default/source/stylesheets/_animate.scss +0 -23
  347. data/lib/middleman/templates/default/source/stylesheets/_normalize.scss +0 -431
  348. data/lib/middleman/templates/default/source/stylesheets/all.css.scss +0 -40
  349. data/lib/middleman/templates/html5.rb +0 -25
  350. data/lib/middleman/templates/html5/source/404.html +0 -38
  351. data/lib/middleman/templates/html5/source/README.md +0 -388
  352. data/lib/middleman/templates/html5/source/apple-touch-icon-114x114-precomposed.png +0 -0
  353. data/lib/middleman/templates/html5/source/apple-touch-icon-57x57-precomposed.png +0 -0
  354. data/lib/middleman/templates/html5/source/apple-touch-icon-72x72-precomposed.png +0 -0
  355. data/lib/middleman/templates/html5/source/apple-touch-icon-precomposed.png +0 -0
  356. data/lib/middleman/templates/html5/source/apple-touch-icon.png +0 -0
  357. data/lib/middleman/templates/html5/source/crossdomain.xml +0 -25
  358. data/lib/middleman/templates/html5/source/css/style.css +0 -293
  359. data/lib/middleman/templates/html5/source/favicon.ico +0 -0
  360. data/lib/middleman/templates/html5/source/humans.txt +0 -43
  361. data/lib/middleman/templates/html5/source/img/.gitignore +0 -2
  362. data/lib/middleman/templates/html5/source/index.html +0 -79
  363. data/lib/middleman/templates/html5/source/js/libs/jquery-1.6.2.js +0 -8981
  364. data/lib/middleman/templates/html5/source/js/libs/jquery-1.6.2.min.js +0 -18
  365. data/lib/middleman/templates/html5/source/js/libs/modernizr-2.0.6.min.js +0 -4
  366. data/lib/middleman/templates/html5/source/js/mylibs/.gitignore +0 -2
  367. data/lib/middleman/templates/html5/source/js/plugins.js +0 -20
  368. data/lib/middleman/templates/html5/source/js/script.js +0 -8
  369. data/lib/middleman/templates/html5/source/robots.txt +0 -5
  370. data/lib/middleman/templates/html5/source/test/index.html +0 -31
  371. data/lib/middleman/templates/html5/source/test/qunit/qunit.css +0 -148
  372. data/lib/middleman/templates/html5/source/test/qunit/qunit.js +0 -1265
  373. data/lib/middleman/templates/html5/source/test/tests.js +0 -24
  374. data/lib/middleman/templates/local.rb +0 -21
  375. data/lib/middleman/templates/mobile.rb +0 -25
  376. data/lib/middleman/templates/mobile/source/404.html +0 -37
  377. data/lib/middleman/templates/mobile/source/README.markdown +0 -21
  378. data/lib/middleman/templates/mobile/source/crossdomain.xml +0 -25
  379. data/lib/middleman/templates/mobile/source/css/style.css +0 -315
  380. data/lib/middleman/templates/mobile/source/humans.txt +0 -43
  381. data/lib/middleman/templates/mobile/source/img/h/apple-touch-icon.png +0 -0
  382. data/lib/middleman/templates/mobile/source/img/h/splash.png +0 -0
  383. data/lib/middleman/templates/mobile/source/img/l/apple-touch-icon-precomposed.png +0 -0
  384. data/lib/middleman/templates/mobile/source/img/l/apple-touch-icon.png +0 -0
  385. data/lib/middleman/templates/mobile/source/img/l/splash.png +0 -0
  386. data/lib/middleman/templates/mobile/source/img/m/apple-touch-icon.png +0 -0
  387. data/lib/middleman/templates/mobile/source/index.html +0 -92
  388. data/lib/middleman/templates/mobile/source/js/libs/modernizr-custom.js +0 -14
  389. data/lib/middleman/templates/mobile/source/js/libs/respond.min.js +0 -7
  390. data/lib/middleman/templates/mobile/source/js/mylibs/helper.js +0 -171
  391. data/lib/middleman/templates/mobile/source/js/plugins.js +0 -20
  392. data/lib/middleman/templates/mobile/source/js/script.js +0 -0
  393. data/lib/middleman/templates/mobile/source/robots.txt +0 -4
  394. data/lib/middleman/templates/mobile/source/sitemap.xml +0 -9
  395. data/lib/middleman/templates/mobile/source/test/index.html +0 -31
  396. data/lib/middleman/templates/mobile/source/test/qunit/qunit.css +0 -148
  397. data/lib/middleman/templates/mobile/source/test/qunit/qunit.js +0 -1265
  398. data/lib/middleman/templates/mobile/source/test/tests.js +0 -21
  399. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF +0 -0
  400. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet +0 -31
  401. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet +0 -2
  402. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx +0 -195
  403. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx +0 -44
  404. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp +0 -225
  405. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet +0 -35
  406. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet +0 -2
  407. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp +0 -51
  408. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php +0 -176
  409. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet +0 -30
  410. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet +0 -4
  411. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php +0 -44
  412. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl +0 -195
  413. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet +0 -27
  414. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet +0 -1
  415. data/lib/middleman/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl +0 -38
  416. data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING +0 -202
  417. data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js +0 -559
  418. data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html +0 -43
  419. data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js +0 -57
  420. data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png +0 -0
  421. data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png +0 -0
  422. data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images +0 -33
  423. data/lib/middleman/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png +0 -0
  424. data/lib/middleman/templates/mobile/source/tools/wspl/README +0 -27
  425. data/lib/middleman/templates/mobile/source/tools/wspl/databasefactory.js +0 -45
  426. data/lib/middleman/templates/mobile/source/tools/wspl/dbworker.js +0 -324
  427. data/lib/middleman/templates/mobile/source/tools/wspl/dbworker_test.html +0 -393
  428. data/lib/middleman/templates/mobile/source/tools/wspl/dbworkerstarter.js +0 -32
  429. data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapper_gears.js +0 -595
  430. data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html +0 -404
  431. data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapper_html5.js +0 -203
  432. data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html +0 -468
  433. data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapperapi.js +0 -202
  434. data/lib/middleman/templates/mobile/source/tools/wspl/dbwrapperapi_test.html +0 -51
  435. data/lib/middleman/templates/mobile/source/tools/wspl/gears_resultset.js +0 -71
  436. data/lib/middleman/templates/mobile/source/tools/wspl/gears_resultset_test.html +0 -86
  437. data/lib/middleman/templates/mobile/source/tools/wspl/gears_transaction.js +0 -196
  438. data/lib/middleman/templates/mobile/source/tools/wspl/gears_transaction_test.html +0 -221
  439. data/lib/middleman/templates/mobile/source/tools/wspl/gearsutils.js +0 -94
  440. data/lib/middleman/templates/mobile/source/tools/wspl/gearsutils_test.html +0 -84
  441. data/lib/middleman/templates/mobile/source/tools/wspl/global_functions.js +0 -72
  442. data/lib/middleman/templates/mobile/source/tools/wspl/simplenotes/index.html +0 -347
  443. data/lib/middleman/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js +0 -503
  444. data/lib/middleman/templates/mobile/source/tools/wspl/simplenotes/styles.css +0 -66
  445. data/lib/middleman/templates/mobile/source/tools/wspl/simplenotes/template.js +0 -75
  446. data/lib/middleman/templates/shared/Gemfile.tt +0 -3
  447. data/lib/middleman/templates/shared/config.ru +0 -4
  448. data/lib/middleman/templates/shared/config.tt +0 -92
  449. data/lib/middleman/vendor/hooks-0.2.0/CHANGES.textile +0 -9
  450. data/lib/middleman/vendor/hooks-0.2.0/Gemfile +0 -3
  451. data/lib/middleman/vendor/hooks-0.2.0/README.rdoc +0 -107
  452. data/lib/middleman/vendor/hooks-0.2.0/Rakefile +0 -12
  453. data/lib/middleman/vendor/hooks-0.2.0/hooks.gemspec +0 -22
  454. data/lib/middleman/vendor/hooks-0.2.0/lib/hooks.rb +0 -109
  455. data/lib/middleman/vendor/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +0 -33
  456. data/lib/middleman/vendor/hooks-0.2.0/test/hooks_test.rb +0 -141
  457. data/lib/middleman/vendor/hooks-0.2.0/test/inheritable_attribute_test.rb +0 -55
  458. data/lib/middleman/vendor/hooks-0.2.0/test/test_helper.rb +0 -10
  459. data/lib/middleman/vendor/padrino-core-0.10.5/.document +0 -5
  460. data/lib/middleman/vendor/padrino-core-0.10.5/.gitignore +0 -22
  461. data/lib/middleman/vendor/padrino-core-0.10.5/.yardopts +0 -1
  462. data/lib/middleman/vendor/padrino-core-0.10.5/LICENSE.txt +0 -20
  463. data/lib/middleman/vendor/padrino-core-0.10.5/README.rdoc +0 -294
  464. data/lib/middleman/vendor/padrino-core-0.10.5/Rakefile +0 -5
  465. data/lib/middleman/vendor/padrino-core-0.10.5/bin/padrino +0 -9
  466. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core.rb +0 -167
  467. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application.rb +0 -270
  468. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/rendering.rb +0 -292
  469. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/routing.rb +0 -934
  470. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/showexceptions.rb +0 -20
  471. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/caller.rb +0 -53
  472. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/adapter.rb +0 -24
  473. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/base.rb +0 -151
  474. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/console.rb +0 -20
  475. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/rake.rb +0 -24
  476. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/rake_tasks.rb +0 -59
  477. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/command.rb +0 -38
  478. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/images/404.png +0 -0
  479. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/images/500.png +0 -0
  480. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/loader.rb +0 -210
  481. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/cs.yml +0 -34
  482. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/da.yml +0 -34
  483. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/de.yml +0 -34
  484. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/en.yml +0 -34
  485. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/es.yml +0 -34
  486. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/fr.yml +0 -34
  487. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/hu.yml +0 -34
  488. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/it.yml +0 -40
  489. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/ja.yml +0 -34
  490. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/lv.yml +0 -34
  491. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/nl.yml +0 -34
  492. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/no.yml +0 -35
  493. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/pl.yml +0 -34
  494. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/pt_br.yml +0 -40
  495. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/ru.yml +0 -35
  496. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/tr.yml +0 -34
  497. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/uk.yml +0 -34
  498. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/zh_cn.yml +0 -34
  499. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/zh_tw.yml +0 -34
  500. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/logger.rb +0 -345
  501. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/mounter.rb +0 -224
  502. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/reloader.rb +0 -254
  503. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/router.rb +0 -98
  504. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/server.rb +0 -79
  505. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/support_lite.rb +0 -199
  506. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/tasks.rb +0 -21
  507. data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/version.rb +0 -20
  508. data/lib/middleman/vendor/padrino-core-0.10.5/padrino-core.gemspec +0 -38
  509. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/.components +0 -6
  510. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/.gitignore +0 -7
  511. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/complex.rb +0 -32
  512. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/simple.rb +0 -33
  513. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/a.rb +0 -9
  514. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/b.rb +0 -4
  515. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/c.rb +0 -1
  516. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/e.rb +0 -13
  517. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/f.rb +0 -2
  518. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/g.rb +0 -2
  519. data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/d.rb +0 -4
  520. data/lib/middleman/vendor/padrino-core-0.10.5/test/helper.rb +0 -81
  521. data/lib/middleman/vendor/padrino-core-0.10.5/test/mini_shoulda.rb +0 -45
  522. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_application.rb +0 -108
  523. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_core.rb +0 -79
  524. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_dependencies.rb +0 -44
  525. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_filters.rb +0 -278
  526. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_locale.rb +0 -21
  527. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_logger.rb +0 -100
  528. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_mounter.rb +0 -177
  529. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_reloader_complex.rb +0 -75
  530. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_reloader_simple.rb +0 -98
  531. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_rendering.rb +0 -461
  532. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_restful_routing.rb +0 -33
  533. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_router.rb +0 -146
  534. data/lib/middleman/vendor/padrino-core-0.10.5/test/test_routing.rb +0 -1673
  535. data/lib/middleman/vendor/padrino-helpers-0.10.5/.document +0 -5
  536. data/lib/middleman/vendor/padrino-helpers-0.10.5/.gitignore +0 -21
  537. data/lib/middleman/vendor/padrino-helpers-0.10.5/.yardopts +0 -1
  538. data/lib/middleman/vendor/padrino-helpers-0.10.5/LICENSE.txt +0 -20
  539. data/lib/middleman/vendor/padrino-helpers-0.10.5/README.rdoc +0 -239
  540. data/lib/middleman/vendor/padrino-helpers-0.10.5/Rakefile +0 -5
  541. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers.rb +0 -58
  542. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/asset_tag_helpers.rb +0 -420
  543. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_builder/abstract_form_builder.rb +0 -220
  544. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_builder/standard_form_builder.rb +0 -43
  545. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_helpers.rb +0 -602
  546. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/format_helpers.rb +0 -381
  547. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/cs.yml +0 -103
  548. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/da.yml +0 -91
  549. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/de.yml +0 -81
  550. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/en.yml +0 -103
  551. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/es.yml +0 -103
  552. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/fr.yml +0 -80
  553. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/hu.yml +0 -103
  554. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/it.yml +0 -89
  555. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/ja.yml +0 -103
  556. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/lv.yml +0 -103
  557. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/nl.yml +0 -82
  558. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/no.yml +0 -91
  559. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/pl.yml +0 -95
  560. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/pt_br.yml +0 -103
  561. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/ru.yml +0 -103
  562. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/tr.yml +0 -103
  563. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/uk.yml +0 -103
  564. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/zh_cn.yml +0 -104
  565. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/zh_tw.yml +0 -103
  566. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/number_helpers.rb +0 -288
  567. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers.rb +0 -175
  568. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/abstract_handler.rb +0 -98
  569. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/erb_handler.rb +0 -79
  570. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/haml_handler.rb +0 -63
  571. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/slim_handler.rb +0 -81
  572. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/render_helpers.rb +0 -60
  573. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/tag_helpers.rb +0 -103
  574. data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/translation_helpers.rb +0 -38
  575. data/lib/middleman/vendor/padrino-helpers-0.10.5/padrino-helpers.gemspec +0 -27
  576. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/app.rb +0 -73
  577. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.erb +0 -14
  578. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.haml +0 -12
  579. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.slim +0 -13
  580. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.erb +0 -14
  581. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.haml +0 -12
  582. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.slim +0 -12
  583. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.erb +0 -11
  584. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.haml +0 -9
  585. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.slim +0 -9
  586. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.erb +0 -5
  587. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.haml +0 -5
  588. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.slim +0 -5
  589. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.erb +0 -20
  590. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.haml +0 -15
  591. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.slim +0 -15
  592. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.erb +0 -56
  593. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.haml +0 -47
  594. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.slim +0 -47
  595. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.erb +0 -56
  596. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.haml +0 -45
  597. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.slim +0 -45
  598. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.erb +0 -5
  599. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.haml +0 -4
  600. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.slim +0 -4
  601. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.erb +0 -3
  602. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.haml +0 -3
  603. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.slim +0 -3
  604. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.erb +0 -3
  605. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.haml +0 -3
  606. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.slim +0 -3
  607. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_erb.erb +0 -1
  608. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_haml.haml +0 -1
  609. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_slim.slim +0 -1
  610. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.erb +0 -1
  611. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.haml +0 -1
  612. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.slim +0 -1
  613. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/app.rb +0 -50
  614. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engine.haml +0 -5
  615. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_erb.erb +0 -1
  616. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_haml.haml +0 -1
  617. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_slim.slim +0 -1
  618. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/erb/test.erb +0 -1
  619. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/explicit_engine.haml +0 -5
  620. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/haml/test.haml +0 -1
  621. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/_user.haml +0 -7
  622. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/haml_template.haml +0 -1
  623. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/some_template.haml +0 -2
  624. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/helper.rb +0 -66
  625. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_asset_tag_helpers.rb +0 -320
  626. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_form_builder.rb +0 -996
  627. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_form_helpers.rb +0 -645
  628. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_format_helpers.rb +0 -227
  629. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_locale.rb +0 -20
  630. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_number_helpers.rb +0 -136
  631. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_output_helpers.rb +0 -153
  632. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_render_helpers.rb +0 -76
  633. data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb +0 -105
  634. data/lib/middleman/version.rb +0 -13
  635. data/middleman-x86-mingw32.gemspec +0 -56
@@ -1,292 +0,0 @@
1
- require 'padrino-core/support_lite' unless defined?(SupportLite)
2
-
3
- module Padrino
4
- ##
5
- # Padrino enhances the Sinatra 'render' method to have support for
6
- # automatic template engine detection, enhanced layout functionality,
7
- # locale enabled rendering, among other features.
8
- #
9
- module Rendering
10
- ##
11
- # Exception responsible for when an expected template did not exist.
12
- #
13
- class TemplateNotFound < RuntimeError
14
- end
15
-
16
- ##
17
- # This is an array of file patterns to ignore. If your editor add a
18
- # suffix during editing to your files please add it like:
19
- #
20
- # @example
21
- # Padrino::Rendering::IGNORE_FILE_PATTERN << /~$/
22
- #
23
- IGNORE_FILE_PATTERN = [
24
- /~$/ # This is for Gedit
25
- ] unless defined?(IGNORE_FILE_PATTERN)
26
-
27
- ##
28
- # Default rendering options used in the #render-method.
29
- #
30
- DEFAULT_RENDERING_OPTIONS = { :strict_format => false, :raise_exceptions => true } unless defined?(DEFAULT_RENDERING_OPTIONS)
31
-
32
- class << self
33
- ##
34
- # Main class that register this extension.
35
- #
36
- def registered(app)
37
- app.send(:include, InstanceMethods)
38
- app.extend(ClassMethods)
39
- end
40
- alias :included :registered
41
- end
42
-
43
- ##
44
- # Class methods responsible for rendering templates as part of a request.
45
- #
46
- module ClassMethods
47
- ##
48
- # Use layout like rails does or if a block given then like sinatra.
49
- # If used without a block, sets the current layout for the route.
50
- #
51
- # By default, searches in your:
52
- #
53
- # +app+/+views+/+layouts+/+application+.(+haml+|+erb+|+xxx+)
54
- # +app+/+views+/+layout_name+.(+haml+|+erb+|+xxx+)
55
- #
56
- # If you define +layout+ :+custom+ then searches for your layouts in
57
- # +app+/+views+/+layouts+/+custom+.(+haml+|+erb+|+xxx+)
58
- # +app+/+views+/+custom+.(+haml+|+erb+|+xxx+)
59
- #
60
- # @param [Symbol] name (:layout)
61
- # The layout to use.
62
- #
63
- # @yield []
64
- #
65
- def layout(name=:layout, &block)
66
- return super(name, &block) if block_given?
67
- @layout = name
68
- end
69
-
70
- ##
71
- # Returns the cached template file to render for a given url, content_type and locale.
72
- #
73
- # @param [Array<template_path, content_type, locale>] render_options
74
- #
75
- def fetch_template_file(render_options)
76
- (@_cached_templates ||= {})[render_options]
77
- end
78
-
79
- ##
80
- # Caches the template file for the given rendering options
81
- #
82
- # @param [String] template_file
83
- # The path of the template file.
84
- #
85
- # @param [Array<template_path, content_type, locale>] render_options
86
- #
87
- def cache_template_file!(template_file, render_options)
88
- (@_cached_templates ||= {})[render_options] = template_file || []
89
- end
90
-
91
- ##
92
- # Returns the cached layout path.
93
- #
94
- # @param [Symbol, nil] given_layout
95
- # The requested layout.
96
- #
97
- def fetch_layout_path(given_layout=nil)
98
- layout_name = given_layout || @layout || :application
99
- @_cached_layout ||= {}
100
- cached_layout_path = @_cached_layout[layout_name]
101
- return cached_layout_path if cached_layout_path
102
- has_layout_at_root = Dir["#{views}/#{layout_name}.*"].any?
103
- layout_path = has_layout_at_root ? layout_name.to_sym : File.join('layouts', layout_name.to_s).to_sym
104
- @_cached_layout[layout_name] = layout_path unless reload_templates?
105
- layout_path
106
- end
107
- end
108
-
109
- # Instance methods that allow enhanced rendering to function properly in Padrino.
110
- module InstanceMethods
111
- attr_reader :current_engine
112
-
113
- ##
114
- # Get/Set the content_type
115
- #
116
- # @param [String, nil] type
117
- # The Content-Type to use.
118
- #
119
- # @param [Symbol, nil] type.
120
- # Look and parse the given symbol to the matched Content-Type.
121
- #
122
- # @param [Hash] params
123
- # Additional params to append to the Content-Type.
124
- #
125
- # @example
126
- # case content_type
127
- # when :js then do_some
128
- # when :css then do_another
129
- # end
130
- #
131
- # content_type :js
132
- # # => set the response with 'application/javascript' Content-Type
133
- # content_type 'text/html'
134
- #
135
- # # => set directly the Content-Type to 'text/html'
136
- #
137
- def content_type(type=nil, params={})
138
- unless type.nil?
139
- super(type, params)
140
- @_content_type = type
141
- end
142
- @_content_type
143
- end
144
-
145
- private
146
- ##
147
- # Enhancing Sinatra render functionality for:
148
- #
149
- # * Using layout similar to rails
150
- # * Use render 'path/to/my/template' (without symbols)
151
- # * Use render 'path/to/my/template' (with engine lookup)
152
- # * Use render 'path/to/template.haml' (with explicit engine lookup)
153
- # * Use render 'path/to/template', :layout => false
154
- # * Use render 'path/to/template', :layout => false, :engine => 'haml'
155
- # * Use render { :a => 1, :b => 2, :c => 3 } # => return a json string
156
- #
157
- def render(engine, data=nil, options={}, locals={}, &block)
158
- # If engine is a hash then render data converted to json
159
- content_type(:json, :charset => 'utf-8') and return engine.to_json if engine.is_a?(Hash)
160
-
161
- # If engine is nil, ignore engine parameter and shift up all arguments
162
- # render nil, "index", { :layout => true }, { :localvar => "foo" }
163
- engine, data, options = data, options, locals if engine.nil? && data
164
-
165
- # Data is a hash of options when no engine isn't explicit
166
- # render "index", { :layout => true }, { :localvar => "foo" }
167
- # Data is options, and options is locals in this case
168
- data, options, locals = nil, data, options if data.is_a?(Hash)
169
-
170
- # If data is unassigned then this is a likely a template to be resolved
171
- # This means that no engine was explicitly defined
172
- data, engine = *resolve_template(engine, options.dup) if data.nil?
173
-
174
- # Setup root
175
- root = settings.respond_to?(:root) ? settings.root : ""
176
-
177
- # Use @layout if it exists
178
- options[:layout] = @layout if options[:layout].nil?
179
-
180
- # Resolve layouts similar to in Rails
181
- if (options[:layout].nil? || options[:layout] == true) && !settings.templates.has_key?(:layout)
182
- layout_path, layout_engine = *resolved_layout
183
- options[:layout] = layout_path || false # We need to force layout false so sinatra don't try to render it
184
- options[:layout] = false unless layout_engine == engine # TODO allow different layout engine
185
- options[:layout_engine] = layout_engine || engine if options[:layout]
186
- elsif options[:layout].present?
187
- options[:layout] = settings.fetch_layout_path(options[:layout] || @layout)
188
- end
189
-
190
- # Cleanup the template
191
- @current_engine, engine_was = engine, @current_engine
192
- @_out_buf, _buf_was = "", @_out_buf
193
-
194
- # Pass arguments to Sinatra render method
195
- super(engine, data, options.dup, locals, &block)
196
- ensure
197
- @current_engine = engine_was
198
- @_out_buf = _buf_was
199
- end
200
-
201
- ##
202
- # Returns the located layout tuple to be used for the rendered template
203
- # (if available).
204
- #
205
- # @example
206
- # resolve_layout
207
- # # => ["/layouts/custom", :erb]
208
- # # => [nil, nil]
209
- #
210
- def resolved_layout
211
- located_layout = resolve_template(settings.fetch_layout_path, :raise_exceptions => false, :strict_format => true)
212
- located_layout ? located_layout : [nil, nil]
213
- end
214
-
215
- ##
216
- # Returns the template path and engine that match content_type (if present),
217
- # I18n.locale.
218
- #
219
- # @param [String] template_path
220
- # The path of the template.
221
- #
222
- # @param [Hash] options
223
- # Additional options.
224
- #
225
- # @option options [Boolean] :strict_format (false)
226
- # The resolved template must match the content_type of the request.
227
- #
228
- # @option options [Boolean] :raise_exceptions (false)
229
- # Raises a {TemplateNotFound} exception if the template cannot be located.
230
- #
231
- # @return [Array<Symbol, Symbol>]
232
- # The path and format of the template.
233
- #
234
- # @raise [TemplateNotFound]
235
- # The template could not be found.
236
- #
237
- # @example
238
- # get "/foo", :provides => [:html, :js] do; render 'path/to/foo'; end
239
- # # If you request "/foo.js" with I18n.locale == :ru => [:"/path/to/foo.ru.js", :erb]
240
- # # If you request "/foo" with I18n.locale == :de => [:"/path/to/foo.de.haml", :haml]
241
- #
242
- def resolve_template(template_path, options={})
243
- began_at = Time.now
244
- # Fetch cached template for rendering options
245
- template_path = template_path.to_s[0] == ?/ ? template_path.to_s : "/#{template_path}"
246
- rendering_options = [template_path, content_type, locale]
247
- cached_template = settings.fetch_template_file(rendering_options)
248
- if cached_template
249
- logger.debug :cached, began_at, cached_template[0] if settings.logging? && defined?(logger)
250
- return cached_template
251
- end
252
-
253
- # Resolve view path and options
254
- options.reverse_merge!(DEFAULT_RENDERING_OPTIONS)
255
- view_path = options.delete(:views) || settings.views || "./views"
256
- target_extension = File.extname(template_path)[1..-1] || "none" # explicit template extension
257
- template_path = template_path.chomp(".#{target_extension}")
258
-
259
- # Generate potential template candidates
260
- templates = Dir[File.join(view_path, template_path) + ".*"].map do |file|
261
- template_engine = File.extname(file)[1..-1].to_sym # retrieves engine extension
262
- template_file = file.sub(view_path, '').chomp(".#{template_engine}").to_sym # retrieves template filename
263
- [template_file, template_engine] unless IGNORE_FILE_PATTERN.any? { |pattern| template_engine.to_s =~ pattern }
264
- end
265
-
266
- # Check if we have a simple content type
267
- simple_content_type = [:html, :plain].include?(content_type)
268
-
269
- # Resolve final template to render
270
- located_template =
271
- templates.find { |file, e| file.to_s == "#{template_path}.#{locale}.#{content_type}" } ||
272
- templates.find { |file, e| file.to_s == "#{template_path}.#{locale}" && simple_content_type } ||
273
- templates.find { |file, e| File.extname(file.to_s) == ".#{target_extension}" or e.to_s == target_extension.to_s } ||
274
- templates.find { |file, e| file.to_s == "#{template_path}.#{content_type}" } ||
275
- templates.find { |file, e| file.to_s == "#{template_path}" && simple_content_type } ||
276
- (!options[:strict_format] && templates.first) # If not strict, fall back to the first located template
277
-
278
- raise TemplateNotFound, "Template '#{template_path}' not found in '#{view_path}'!" if !located_template && options[:raise_exceptions]
279
- settings.cache_template_file!(located_template, rendering_options) unless settings.reload_templates?
280
- logger.debug :template, began_at, located_template[0] if located_template && settings.logging? && defined?(logger)
281
- located_template
282
- end
283
-
284
- ##
285
- # Return the I18n.locale if I18n is defined.
286
- #
287
- def locale
288
- I18n.locale if defined?(I18n)
289
- end
290
- end # InstanceMethods
291
- end # Rendering
292
- end # Padrino
@@ -1,934 +0,0 @@
1
- require 'http_router' unless defined?(HttpRouter)
2
- require 'padrino-core/support_lite' unless defined?(SupportLite)
3
-
4
- ##
5
- # Adds to Sinatra +controller+ informations
6
- #
7
- # @private
8
- class Sinatra::Request
9
- attr_accessor :route_obj
10
-
11
- def controller
12
- route_obj && route_obj.controller
13
- end
14
- end
15
-
16
- ##
17
- # HttpRouter adapter
18
- #
19
- # @private
20
- class HttpRouter
21
- def rewrite_partial_path_info(env, request); end
22
- def rewrite_path_info(env, request); end
23
-
24
- def process_destination_path(path, env)
25
- Thread.current['padrino.instance'].instance_eval do
26
- request.route_obj = path.route
27
- @_response_buffer = nil
28
- @route = path.route
29
- @params ||= {}
30
- @params.update(env['router.params'])
31
- @block_params = if path.route.is_a?(HttpRouter::RegexRoute)
32
- params_list = env['router.request'].extra_env['router.regex_match'].to_a
33
- params_list.shift
34
- @params[:captures] = params_list
35
- params_list
36
- else
37
- env['router.request'].params
38
- end
39
- # Provide access to the current controller to the request
40
- # Now we can eval route, but because we have "throw halt" we need to be
41
- # (en)sure to reset old layout and run controller after filters.
42
- original_params = @params
43
- parent_layout = @layout
44
- successful = false
45
- begin
46
- filter! :before
47
- (@route.before_filters - settings.filters[:before]).each { |block| instance_eval(&block) }
48
- @layout = path.route.use_layout if path.route.use_layout
49
- @route.custom_conditions.each { |block| pass if block.bind(self).call == false } if @route.custom_conditions
50
- @block_params = @block_params[0, @route.dest.arity] if @route.dest.arity > 0
51
- halt_response = catch(:halt) { route_eval { @route.dest[self, @block_params] } }
52
- @_response_buffer = halt_response.is_a?(Array) ? halt_response.last : halt_response
53
- successful = true
54
- halt halt_response
55
- ensure
56
- (@route.after_filters - settings.filters[:after]).each { |block| instance_eval(&block) } if successful
57
- @layout = parent_layout
58
- @params = original_params
59
- end
60
- end
61
- end
62
-
63
- # @private
64
- class Route
65
- attr_accessor :use_layout, :controller, :cache, :cache_key, :cache_expires_in
66
-
67
- def before_filters(&block)
68
- @_before_filters ||= []
69
- @_before_filters << block if block_given?
70
-
71
- @_before_filters
72
- end
73
-
74
- def after_filters(&block)
75
- @_after_filters ||= []
76
- @_after_filters << block if block_given?
77
-
78
- @_after_filters
79
- end
80
-
81
- def custom_conditions(&block)
82
- @_custom_conditions ||= []
83
- @_custom_conditions << block if block_given?
84
-
85
- @_custom_conditions
86
- end
87
- end
88
- end
89
-
90
- module Padrino
91
- class Filter # @private
92
- attr_reader :block
93
-
94
- def initialize(mode, scoped_controller, options, args, &block)
95
- @mode, @scoped_controller, @options, @args, @block = mode, scoped_controller, options, args, block
96
- end
97
-
98
- def apply?(request)
99
- detect = @args.any? do |arg|
100
- case arg
101
- when Symbol then request.route_obj && (request.route_obj.named == arg or request.route_obj.named == [@scoped_controller, arg].flatten.join("_").to_sym)
102
- else arg === request.path_info
103
- end
104
- end || @options.any? do |name, val|
105
- case name
106
- when :agent then val === request.user_agent
107
- else val === request.send(name)
108
- end
109
- end
110
- detect ^ !@mode
111
- end
112
-
113
- def to_proc
114
- if @args.empty? && @options.empty?
115
- block
116
- else
117
- filter = self
118
- proc { instance_eval(&filter.block) if filter.apply?(request) }
119
- end
120
- end
121
- end
122
-
123
- ##
124
- # Padrino provides advanced routing definition support to make routes and
125
- # url generation much easier. This routing system supports named route
126
- # aliases and easy access to url paths. The benefits of this is that instead
127
- # of having to hard-code route urls into every area of your application, now
128
- # we can just define the urls in a single spot and then attach an alias
129
- # which can be used to refer to the url throughout the application.
130
- #
131
- module Routing
132
- # Defines common content-type alias mappings
133
- CONTENT_TYPE_ALIASES = { :htm => :html } unless defined?(CONTENT_TYPE_ALIASES)
134
- # Defines the available route priorities supporting route deferrals.
135
- ROUTE_PRIORITY = {:high => 0, :normal => 1, :low => 2} unless defined?(ROUTE_PRIORITY)
136
-
137
- # Raised when a route was invalid or cannot be processed.
138
- class UnrecognizedException < RuntimeError; end
139
-
140
- class Parent < String # @private
141
- attr_reader :map
142
- attr_reader :optional
143
- attr_reader :options
144
-
145
- alias_method :optional?, :optional
146
-
147
- def initialize(value, options={})
148
- super(value.to_s)
149
- @map = options.delete(:map)
150
- @optional = options.delete(:optional)
151
- @options = options
152
- end
153
- end
154
-
155
- class << self
156
- ##
157
- # Main class that register this extension.
158
- #
159
- def registered(app)
160
- app.send(:include, InstanceMethods)
161
- app.extend(ClassMethods)
162
- end
163
- alias :included :registered
164
- end
165
-
166
- # Class methods responsible for enhanced routing for controllers.
167
- module ClassMethods
168
- ##
169
- # Method for organize in a better way our routes.
170
- #
171
- # @param [Array] args
172
- # Controller arguments.
173
- #
174
- # @yield []
175
- # The given block will be used to define the routes within the
176
- # Controller.
177
- #
178
- # @example
179
- # controller :admin do
180
- # get :index do; ...; end
181
- # get :show, :with => :id do; ...; end
182
- # end
183
- #
184
- # url(:admin_index) # => "/admin"
185
- # url(:admin_show, :id => 1) # "/admin/show/1"
186
- #
187
- # @example Using named routes follow the sinatra way:
188
- # controller "/admin" do
189
- # get "/index" do; ...; end
190
- # get "/show/:id" do; ...; end
191
- # end
192
- #
193
- # @example Supply +:provides+ to all controller routes:
194
- # controller :provides => [:html, :xml, :json] do
195
- # get :index do; "respond to html, xml and json"; end
196
- # post :index do; "respond to html, xml and json"; end
197
- # get :foo do; "respond to html, xml and json"; end
198
- # end
199
- #
200
- # @example Specify parent resources in padrino with the +:parent+ option on the controller:
201
- # controllers :product, :parent => :user do
202
- # get :index do
203
- # # url is generated as "/user/#{params[:user_id]}/product"
204
- # # url_for(:product, :index, :user_id => 5) => "/user/5/product"
205
- # end
206
- # get :show, :with => :id do
207
- # # url is generated as "/user/#{params[:user_id]}/product/show/#{params[:id]}"
208
- # # url_for(:product, :show, :user_id => 5, :id => 10) => "/user/5/product/show/10"
209
- # end
210
- # end
211
- #
212
- # @example Specify conditions to run for all routes:
213
- # controller :conditions => {:protect => true} do
214
- # def self.protect(protected)
215
- # condition do
216
- # halt 403, "No secrets for you!" unless params[:key] == "s3cr3t"
217
- # end if protected
218
- # end
219
- #
220
- # # This route will only return "secret stuff" if the user goes to
221
- # # `/private?key=s3cr3t`.
222
- # get("/private") { "secret stuff" }
223
- #
224
- # # And this one, too!
225
- # get("/also-private") { "secret stuff" }
226
- #
227
- # # But you can override the conditions for each route as needed.
228
- # # This route will be publicly accessible without providing the
229
- # # secret key.
230
- # get :index, :protect => false do
231
- # "Welcome!"
232
- # end
233
- # end
234
- #
235
- # @example Supply default values:
236
- # controller :lang => :de do
237
- # get :index, :map => "/:lang" do; "params[:lang] == :de"; end
238
- # end
239
- #
240
- # In a controller before and after filters are scoped and didn't affect other controllers or main app.
241
- # In a controller layout are scoped and didn't affect others controllers and main app.
242
- #
243
- # @example
244
- # controller :posts do
245
- # layout :post
246
- # before { foo }
247
- # after { bar }
248
- # end
249
- #
250
- def controller(*args, &block)
251
- if block_given?
252
- options = args.extract_options!
253
-
254
- # Controller defaults
255
- @_controller, original_controller = args, @_controller
256
- @_parents, original_parent = options.delete(:parent), @_parents
257
- @_provides, original_provides = options.delete(:provides), @_provides
258
- @_use_format, original_use_format = options.delete(:use_format), @_use_format
259
- @_cache, original_cache = options.delete(:cache), @_cache
260
- @_map, original_map = options.delete(:map), @_map
261
- @_conditions, original_conditions = options.delete(:conditions), @_conditions
262
- @_defaults, original_defaults = options, @_defaults
263
-
264
- # Application defaults
265
- @filters, original_filters = { :before => @filters[:before].dup, :after => @filters[:after].dup }, @filters
266
- @layout, original_layout = nil, @layout
267
-
268
- instance_eval(&block)
269
-
270
- # Application defaults
271
- @filters = original_filters
272
- @layout = original_layout
273
-
274
- # Controller defaults
275
- @_controller, @_parents, @_cache = original_controller, original_parent, original_cache
276
- @_defaults, @_provides, @_map = original_defaults, original_provides, original_map
277
- @_conditions, @_use_format = original_conditions, original_use_format
278
- else
279
- include(*args) if extensions.any?
280
- end
281
- end
282
- alias :controllers :controller
283
-
284
- ##
285
- # Add a before filter hook
286
- #
287
- # @see #construct_filter
288
- #
289
- def before(*args, &block)
290
- add_filter :before, &(args.empty? ? block : construct_filter(*args, &block))
291
- end
292
-
293
- ##
294
- # Add an after filter hook
295
- #
296
- # @see #construct_filter
297
- #
298
- def after(*args, &block)
299
- add_filter :after, &(args.empty? ? block : construct_filter(*args, &block))
300
- end
301
-
302
- ##
303
- # Adds a filter hook to a request.
304
- #
305
- def add_filter(type, &block)
306
- filters[type] << block
307
- end
308
-
309
- ##
310
- # Creates a filter to process before/after the matching route.
311
- #
312
- # @param [Array] args
313
- #
314
- # @example We are be able to filter with String path
315
- # before('/') { 'only to :index' }
316
- # get(:index} { 'foo' } # => filter match only before this.
317
- # get(:main) { 'bar' }
318
- #
319
- # @example is the same of
320
- # before(:index) { 'only to :index' }
321
- # get(:index} { 'foo' } # => filter match only before this.
322
- # get(:main) { 'bar' }
323
- #
324
- # @example it works only for the given controller
325
- # controller :foo do
326
- # before(:index) { 'only to for :foo_index' }
327
- # get(:index} { 'foo' } # => filter match only before this.
328
- # get(:main) { 'bar' }
329
- # end
330
- #
331
- # controller :bar do
332
- # before(:index) { 'only to for :bar_index' }
333
- # get(:index} { 'foo' } # => filter match only before this.
334
- # get(:main) { 'bar' }
335
- # end
336
- #
337
- # @example if filters based on a symbol or regexp
338
- # before :index, /main/ do; ... end
339
- # # => match oly path that are +/+ or contains +main+
340
- #
341
- # @example filtering everything except an occurency
342
- # before :except => :index do; ...; end
343
- #
344
- # @example you can also filter using a request param
345
- # before :agent => /IE/ do; ...; end
346
- # # => match +HTTP_USER_AGENT+ containing +IE+
347
- #
348
- # @see http://www.padrinorb.com/guides/controllers#route-filters
349
- #
350
- def construct_filter(*args, &block)
351
- options = args.last.is_a?(Hash) ? args.pop : {}
352
- except = options.key?(:except) && Array(options.delete(:except))
353
- raise("You cannot use except with other options specified") if except && (!args.empty? || !options.empty?)
354
- options = except.last.is_a?(Hash) ? except.pop : {} if except
355
- Filter.new(!except, @_controller, options, Array(except || args), &block)
356
- end
357
-
358
- ##
359
- # Provides many parents with shallowing.
360
- #
361
- # @param [Symbol] name
362
- # The parent name.
363
- #
364
- # @param [Hash] options
365
- # Additional options.
366
- #
367
- # @example
368
- # controllers :product do
369
- # parent :shop, :optional => true, :map => "/my/stand"
370
- # parent :category, :optional => true
371
- # get :show, :with => :id do
372
- # # generated urls:
373
- # # "/product/show/#{params[:id]}"
374
- # # "/my/stand/#{params[:shop_id]}/product/show/#{params[:id]}"
375
- # # "/my/stand/#{params[:shop_id]}/category/#{params[:category_id]}/product/show/#{params[:id]}"
376
- # # url_for(:product, :show, :id => 10) => "/product/show/10"
377
- # # url_for(:product, :show, :shop_id => 5, :id => 10) => "/my/stand/5/product/show/10"
378
- # # url_for(:product, :show, :shop_id => 5, :category_id => 1, :id => 10) => "/my/stand/5/category/1/product/show/10"
379
- # end
380
- # end
381
- #
382
- def parent(name, options={})
383
- defaults = { :optional => false, :map => name.to_s }
384
- options = defaults.merge(options)
385
- @_parents = Array(@_parents) unless @_parents.is_a?(Array)
386
- @_parents << Parent.new(name, options)
387
- end
388
-
389
- ##
390
- # Using {HttpRouter}, for features and configurations.
391
- #
392
- # @example
393
- # router.add('/greedy/:greed')
394
- # router.recognize('/simple')
395
- #
396
- # @see http://github.com/joshbuddy/http_router
397
- #
398
- def router
399
- @router ||= HttpRouter.new
400
- block_given? ? yield(@router) : @router
401
- end
402
- alias :urls :router
403
-
404
- # Compiles the routes including deferred routes.
405
- def compiled_router
406
- if deferred_routes.empty?
407
- router
408
- else
409
- deferred_routes.each { |_, routes| routes.each { |(route, dest)| route.to(dest) } }
410
- @deferred_routes = nil
411
- router
412
- end
413
- end
414
-
415
- # Returns all routes that were deferred based on their priority.
416
- def deferred_routes
417
- @deferred_routes ||= Hash[ROUTE_PRIORITY.values.sort.map{|p| [p, []]}]
418
- end
419
-
420
- ##
421
- # Resets the http router and all deferred routes.
422
- #
423
- def reset_router!
424
- @deferred_routes = nil
425
- router.reset!
426
- end
427
-
428
- ##
429
- # Recognize a given path
430
- #
431
- # @param [String] path
432
- # Path+Query to parse
433
- #
434
- # @return [Symbol, Hash]
435
- # Returns controller and query params.
436
- #
437
- # @example Giving a controller like:
438
- # controller :foo do
439
- # get :bar, :map => 'foo-bar-:id'; ...; end
440
- # end
441
- #
442
- # @example You should be able to reverse:
443
- # MyApp.url(:foo_bar, :id => :mine)
444
- # # => /foo-bar-mine
445
- #
446
- # @example Into this:
447
- # MyApp.recognize_path('foo-bar-mine')
448
- # # => [:foo_bar, :id => :mine]
449
- #
450
- def recognize_path(path)
451
- responses = @router.recognize(Rack::MockRequest.env_for(path))
452
- [responses[0].path.route.named, responses[0].params]
453
- end
454
-
455
- ##
456
- # Instance method for url generation.
457
- #
458
- # @example
459
- # url(:show, :id => 1)
460
- # url(:show, :name => 'test', :id => 24)
461
- # url(:show, 1)
462
- # url(:controller_name, :show, :id => 21)
463
- # url(:controller_show, :id => 29)
464
- #
465
- def url(*args)
466
- params = args.extract_options! # parameters is hash at end
467
- names, params_array = args.partition{|a| a.is_a?(Symbol)}
468
- name = names.join("_").to_sym # route name is concatenated with underscores
469
- if params.is_a?(Hash)
470
- params[:format] = params[:format].to_s unless params[:format].nil?
471
- params = value_to_param(params)
472
- end
473
- url = if params_array.empty?
474
- compiled_router.url(name, params)
475
- else
476
- compiled_router.url(name, *(params_array << params))
477
- end
478
- url[0,0] = conform_uri(uri_root) if defined?(uri_root)
479
- url[0,0] = conform_uri(ENV['RACK_BASE_URI']) if ENV['RACK_BASE_URI']
480
- url = "/" if url.blank?
481
- url
482
- rescue HttpRouter::InvalidRouteException
483
- route_error = "route mapping for url(#{name.inspect}) could not be found!"
484
- raise Padrino::Routing::UnrecognizedException.new(route_error)
485
- end
486
- alias :url_for :url
487
-
488
- def get(path, *args, &block) # @private
489
- conditions = @conditions.dup
490
- route('GET', path, *args, &block)
491
-
492
- @conditions = conditions
493
- route('HEAD', path, *args, &block)
494
- end
495
-
496
- private
497
- # Parse params from the url method
498
- def value_to_param(value)
499
- case value
500
- when Array
501
- value.map { |v| value_to_param(v) }.compact
502
- when Hash
503
- value.inject({}) do |memo, (k,v)|
504
- v = value_to_param(v)
505
- memo[k] = v unless v.nil?
506
- memo
507
- end
508
- when nil then nil
509
- else value.respond_to?(:to_param) ? value.to_param : value
510
- end
511
- end
512
-
513
- # Add prefix slash if its not present and remove trailing slashes.
514
- def conform_uri(uri_string)
515
- uri_string.gsub(/^(?!\/)(.*)/, '/\1').gsub(/[\/]+$/, '')
516
- end
517
-
518
- ##
519
- # Rewrite default routes.
520
- #
521
- # @example
522
- # get :index # => "/"
523
- # get :index, "/" # => "/"
524
- # get :index, :map => "/" # => "/"
525
- # get :show, "/show-me" # => "/show-me"
526
- # get :show, :map => "/show-me" # => "/show-me"
527
- # get "/foo/bar" # => "/show"
528
- # get :index, :parent => :user # => "/user/:user_id/index"
529
- # get :show, :with => :id, :parent => :user # => "/user/:user_id/show/:id"
530
- # get :show, :with => :id # => "/show/:id"
531
- # get [:show, :id] # => "/show/:id"
532
- # get :show, :with => [:id, :name] # => "/show/:id/:name"
533
- # get [:show, :id, :name] # => "/show/:id/:name"
534
- # get :list, :provides => :js # => "/list.{:format,js)"
535
- # get :list, :provides => :any # => "/list(.:format)"
536
- # get :list, :provides => [:js, :json] # => "/list.{!format,js|json}"
537
- # get :list, :provides => [:html, :js, :json] # => "/list(.{!format,js|json})"
538
- # get :list, :priority => :low # Defers route to be last
539
- #
540
- def route(verb, path, *args, &block)
541
- options = case args.size
542
- when 2
543
- args.last.merge(:map => args.first)
544
- when 1
545
- map = args.shift if args.first.is_a?(String)
546
- if args.first.is_a?(Hash)
547
- map ? args.first.merge(:map => map) : args.first
548
- else
549
- {:map => map || args.first}
550
- end
551
- when 0
552
- {}
553
- else raise
554
- end
555
-
556
- # Do padrino parsing. We dup options so we can build HEAD request correctly
557
- route_options = options.dup
558
- route_options[:provides] = @_provides if @_provides
559
- path, *route_options[:with] = path if path.is_a?(Array)
560
- path, name, options = *parse_route(path, route_options, verb)
561
- options.reverse_merge!(@_conditions) if @_conditions
562
-
563
- # Sinatra defaults
564
- method_name = "#{verb} #{path}"
565
- unbound_method = generate_method(method_name, &block)
566
-
567
- block = block.arity != 0 ?
568
- proc { |a,p| unbound_method.bind(a).call(*p) } :
569
- proc { |a,p| unbound_method.bind(a).call }
570
-
571
- invoke_hook(:route_added, verb, path, block)
572
-
573
- # HTTPRouter route construction
574
- route = router.add(path)
575
- route.name(name) if name
576
- priority_name = options.delete(:priority) || :normal
577
- priority = ROUTE_PRIORITY[priority_name] or raise("Priority #{priority_name} not recognized, try #{ROUTE_PRIORITY.keys.join(', ')}")
578
- route.cache = options.key?(:cache) ? options.delete(:cache) : @_cache
579
- route.send(verb.downcase.to_sym)
580
- route.host(options.delete(:host)) if options.key?(:host)
581
- route.user_agent(options.delete(:agent)) if options.key?(:agent)
582
- if options.key?(:default_values)
583
- defaults = options.delete(:default_values)
584
- route.default(defaults) if defaults
585
- end
586
- options.delete_if do |option, args|
587
- if route.send(:significant_variable_names).include?(option)
588
- route.matching(option => Array(args).first)
589
- true
590
- end
591
- end
592
-
593
- # Add Sinatra conditions
594
- options.each { |o, a| route.respond_to?(o) ? route.send(o, *a) : send(o, *a) }
595
- conditions, @conditions = @conditions, []
596
- route.custom_conditions.concat(conditions)
597
-
598
- invoke_hook(:padrino_route_added, route, verb, path, args, options, block)
599
-
600
- # Add Application defaults
601
- route.before_filters.concat(@filters[:before])
602
- route.after_filters.concat(@filters[:after])
603
- if @_controller
604
- route.use_layout = @layout
605
- route.controller = Array(@_controller)[0].to_s
606
- end
607
-
608
- deferred_routes[priority] << [route, block]
609
-
610
- route
611
- end
612
-
613
- ##
614
- # Returns the final parsed route details (modified to reflect all
615
- # Padrino options) given the raw route. Raw route passed in could be
616
- # a named alias or a string and is parsed to reflect provides formats,
617
- # controllers, parents, 'with' parameters, and other options.
618
- #
619
- def parse_route(path, options, verb)
620
- # We need save our originals path/options so we can perform correctly cache.
621
- original = [path, options.dup]
622
-
623
- # We need check if path is a symbol, if that it's a named route
624
- map = options.delete(:map)
625
-
626
- if path.kind_of?(Symbol) # path i.e :index or :show
627
- name = path # The route name
628
- path = map ? map.dup : (path == :index ? '/' : path.to_s) # The route path
629
- end
630
-
631
- if path.kind_of?(String) # path i.e "/index" or "/show"
632
- # Now we need to parse our 'with' params
633
- if with_params = options.delete(:with)
634
- path = process_path_for_with_params(path, with_params)
635
- end
636
-
637
- # Now we need to parse our provides
638
- options.delete(:provides) if options[:provides].nil?
639
-
640
- if @_use_format or format_params = options[:provides]
641
- process_path_for_provides(path, format_params)
642
- options[:matching] ||= {}
643
- options[:matching][:format] = /[^\.]+/
644
- end
645
-
646
- # Build our controller
647
- controller = Array(@_controller).map { |c| c.to_s }
648
-
649
- absolute_map = map && map[0] == ?/
650
-
651
- unless controller.empty?
652
- # Now we need to add our controller path only if not mapped directly
653
- if map.blank? and !absolute_map
654
- controller_path = controller.join("/")
655
- path.gsub!(%r{^\(/\)|/\?}, "")
656
- path = File.join(controller_path, path)
657
- end
658
- # Here we build the correct name route
659
- if name
660
- controller_name = controller.join("_")
661
- name = "#{controller_name}_#{name}".to_sym unless controller_name.blank?
662
- end
663
- end
664
-
665
- # Now we need to parse our 'parent' params and parent scope
666
- if !absolute_map and parent_params = options.delete(:parent) || @_parents
667
- parent_params = Array(@_parents) + Array(parent_params)
668
- path = process_path_for_parent_params(path, parent_params)
669
- end
670
-
671
- # Add any controller level map to the front of the path
672
- path = "#{@_map}/#{path}".squeeze('/') unless absolute_map or @_map.blank?
673
-
674
- # Small reformats
675
- path.gsub!(%r{/\?$}, '(/)') # Remove index path
676
- path.gsub!(%r{//$}, '/') # Remove index path
677
- path[0,0] = "/" if path !~ %r{^\(?/} # Paths must start with a /
678
- path.sub!(%r{/(\))?$}, '\\1') if path != "/" # Remove latest trailing delimiter
679
- path.gsub!(/\/(\(\.|$)/, '\\1') # Remove trailing slashes
680
- path.squeeze!('/')
681
- end
682
-
683
- # Merge in option defaults
684
- options.reverse_merge!(:default_values => @_defaults)
685
-
686
- [path, name, options]
687
- end
688
-
689
- ##
690
- # Processes the existing path and appends the 'with' parameters onto the route
691
- # Used for calculating path in route method.
692
- #
693
- def process_path_for_with_params(path, with_params)
694
- File.join(path, Array(with_params).map(&:inspect).join("/"))
695
- end
696
-
697
- ##
698
- # Processes the existing path and prepends the 'parent' parameters onto the route
699
- # Used for calculating path in route method.
700
- #
701
- def process_path_for_parent_params(path, parent_params)
702
- parent_prefix = parent_params.flatten.compact.uniq.map do |param|
703
- map = (param.respond_to?(:map) && param.map ? param.map : param.to_s)
704
- part = "#{map}/:#{param.to_s.singularize}_id/"
705
- part = "(#{part})" if param.respond_to?(:optional) && param.optional?
706
- part
707
- end
708
-
709
- [parent_prefix, path].flatten.join("")
710
- end
711
-
712
- ##
713
- # Processes the existing path and appends the 'format' suffix onto the route
714
- # Used for calculating path in route method.
715
- #
716
- def process_path_for_provides(path, format_params)
717
- path << "(.:format)" unless path[-10, 10] == '(.:format)'
718
- end
719
-
720
- ##
721
- # Allows routing by MIME-types specified in the URL or ACCEPT header.
722
- #
723
- # By default, if a non-provided mime-type is specified in a URL, the
724
- # route will not match an thus return a 404.
725
- #
726
- # Setting the :treat_format_as_accept option to true allows treating
727
- # missing mime types specified in the URL as if they were specified
728
- # in the ACCEPT header and thus return 406.
729
- #
730
- # If no type is specified, the first in the provides-list will be
731
- # returned.
732
- #
733
- # @example
734
- # get "/a", :provides => [:html, :js]
735
- # # => GET /a => :html
736
- # # => GET /a.js => :js
737
- # # => GET /a.xml => 404
738
- #
739
- # get "/b", :provides => [:html]
740
- # # => GET /b; ACCEPT: html => html
741
- # # => GET /b; ACCEPT: js => 406
742
- #
743
- # enable :treat_format_as_accept
744
- # get "/c", :provides => [:html, :js]
745
- # # => GET /c.xml => 406
746
- #
747
- def provides(*types)
748
- @_use_format = true
749
- condition do
750
- mime_types = types.map { |t| mime_type(t) }
751
- url_format = params[:format].to_sym if params[:format]
752
- accepts = request.accept.map { |a| a.split(";")[0].strip }
753
-
754
- # per rfc2616-sec14:
755
- # Assume */* if no ACCEPT header is given.
756
- catch_all = (accepts.delete "*/*" || accepts.empty?)
757
- matching_types = accepts.empty? ? mime_types.slice(0,1) : (accepts & mime_types)
758
-
759
- if !url_format && matching_types.first
760
- type = ::Rack::Mime::MIME_TYPES.find { |k, v| v == matching_types.first }[0].sub(/\./,'').to_sym
761
- accept_format = CONTENT_TYPE_ALIASES[type] || type
762
- elsif catch_all
763
- type = types.first
764
- accept_format = CONTENT_TYPE_ALIASES[type] || type
765
- end
766
-
767
- matched_format = types.include?(:any) ||
768
- types.include?(accept_format) ||
769
- types.include?(url_format) ||
770
- ((!url_format) && request.accept.empty? && types.include?(:html))
771
-
772
- # per rfc2616-sec14:
773
- # answer with 406 if accept is given but types to not match any
774
- # provided type
775
- halt 406 if
776
- (!url_format && !accepts.empty? && !matched_format) ||
777
- (settings.respond_to?(:treat_format_as_accept) && settings.treat_format_as_accept && url_format && !matched_format)
778
-
779
- if matched_format
780
- @_content_type = url_format || accept_format || :html
781
- content_type(@_content_type, :charset => 'utf-8')
782
- end
783
-
784
- matched_format
785
- end
786
- end
787
- end
788
-
789
- ##
790
- # Instance methods related to recognizing and processing routes and serving static files.
791
- #
792
- module InstanceMethods
793
- ##
794
- # Instance method for url generation.
795
- #
796
- # @example
797
- # url(:show, :id => 1)
798
- # url(:show, :name => :test)
799
- # url(:show, 1)
800
- # url("/foo")
801
- #
802
- # @see Padrino::Routing::ClassMethods#url
803
- #
804
- def url(*args)
805
- # Delegate to Sinatra 1.2 for simple url("/foo")
806
- # http://www.sinatrarb.com/intro#Generating%20URLs
807
- return super if args.first.is_a?(String) && !args[1].is_a?(Hash)
808
-
809
- # Delegate to Padrino named route url generation
810
- settings.url(*args)
811
- end
812
- alias :url_for :url
813
-
814
- ##
815
- # Returns the recognized path for a route.
816
- #
817
- def recognize_path(path)
818
- settings.recognize_path(path)
819
- end
820
-
821
- ##
822
- # Returns the current path within a route from specified +path_params+.
823
- #
824
- def current_path(*path_params)
825
- if path_params.last.is_a?(Hash)
826
- path_params[-1] = params.merge(path_params[-1])
827
- else
828
- path_params << params
829
- end
830
- @route.url(*path_params)
831
- end
832
-
833
- ##
834
- # Returns the current route
835
- #
836
- # @example
837
- # -if route.controller == :press
838
- # %li=show_article
839
- #
840
- def route
841
- @route
842
- end
843
-
844
- ##
845
- # This is mostly just a helper so request.path_info isn't changed when
846
- # serving files from the public directory.
847
- #
848
- def static_file?(path_info)
849
- return if (public_dir = settings.public_folder).nil?
850
- public_dir = File.expand_path(public_dir)
851
- path = File.expand_path(public_dir + unescape(path_info))
852
- return if path[0, public_dir.length] != public_dir
853
- return unless File.file?(path)
854
- return path
855
- end
856
-
857
- #
858
- # Method for deliver static files.
859
- #
860
- def static!
861
- if path = static_file?(request.path_info)
862
- env['sinatra.static_file'] = path
863
- cache_control *settings.static_cache_control if settings.static_cache_control?
864
- send_file(path, :disposition => nil)
865
- end
866
- end
867
-
868
- ##
869
- # Return the request format, this is useful when we need to respond to
870
- # a given Content-Type.
871
- #
872
- # @param [Symbol, nil] type
873
- #
874
- # @param [Hash] params
875
- #
876
- # @example
877
- # get :index, :provides => :any do
878
- # case content_type
879
- # when :js then ...
880
- # when :json then ...
881
- # when :html then ...
882
- # end
883
- # end
884
- #
885
- def content_type(type=nil, params={})
886
- unless type.nil?
887
- super(type, params)
888
- @_content_type = type
889
- end
890
- @_content_type
891
- end
892
-
893
- private
894
- def filter!(type, base=settings)
895
- base.filters[type].each { |block| instance_eval(&block) }
896
- end
897
-
898
- def dispatch!
899
- static! if settings.static? && (request.get? || request.head?)
900
- route!
901
- rescue ::Exception => boom
902
- filter! :before
903
- handle_exception!(boom)
904
- ensure
905
- filter! :after unless env['sinatra.static_file']
906
- end
907
-
908
- def route!(base=settings, pass_block=nil)
909
- Thread.current['padrino.instance'] = self
910
- if base.compiled_router and match = base.compiled_router.call(@request.env)
911
- if match.respond_to?(:each)
912
- route_eval do
913
- match[1].each {|k,v| response[k] = v}
914
- status match[0]
915
- route_missing if match[0] == 404
916
- end
917
- end
918
- else
919
- filter! :before
920
- end
921
-
922
- # Run routes defined in superclass.
923
- if base.superclass.respond_to?(:router)
924
- route!(base.superclass, pass_block)
925
- return
926
- end
927
-
928
- route_eval(&pass_block) if pass_block
929
-
930
- route_missing
931
- end
932
- end # InstanceMethods
933
- end # Routing
934
- end # Padrino