middleman-core 3.2.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. checksums.yaml +4 -4
  2. data/features/cli_init.feature +18 -8
  3. data/features/helpers_select_tag.feature +1 -1
  4. data/features/layouts_dir.feature +8 -0
  5. data/features/markdown_redcarpet.feature +2 -2
  6. data/fixtures/asciidoc-app/source/layouts/default.erb +0 -1
  7. data/fixtures/capture-html-app/source/capture_html_haml.html.haml +1 -1
  8. data/fixtures/content-for-app/source/content_for_haml.html.haml +1 -1
  9. data/fixtures/frontmatter-settings-app/source/layouts/override.erb +1 -2
  10. data/fixtures/frontmatter-settings-neighbor-app/source/layouts/override.erb +1 -2
  11. data/fixtures/layouts-dir-app/source/ambiguous.html.erb +5 -0
  12. data/fixtures/layouts-dir-app/source/layouts/other.erb +3 -0
  13. data/fixtures/layouts-dir-app/source/other.erb +3 -0
  14. data/fixtures/link-to-app/source/link_to_haml.html.haml +1 -1
  15. data/fixtures/link-to-app/source/link_to_slim.html.slim +1 -1
  16. data/fixtures/nested-layout-app/source/layouts/inner_haml.haml +1 -1
  17. data/fixtures/nested-layout-app/source/layouts/inner_slim.slim +1 -1
  18. data/fixtures/nested-layout-app/source/layouts/outer_haml.haml +1 -1
  19. data/fixtures/nested-layout-app/source/layouts/outer_slim.slim +1 -1
  20. data/lib/middleman-core/application.rb +12 -3
  21. data/lib/middleman-core/cli/build.rb +5 -3
  22. data/lib/middleman-core/cli/console.rb +1 -1
  23. data/lib/middleman-core/cli/init.rb +1 -1
  24. data/lib/middleman-core/core_extensions.rb +0 -1
  25. data/lib/middleman-core/core_extensions/file_watcher.rb +11 -11
  26. data/lib/middleman-core/core_extensions/rendering.rb +40 -66
  27. data/lib/middleman-core/extension.rb +167 -0
  28. data/lib/middleman-core/extensions.rb +2 -151
  29. data/lib/middleman-core/logger.rb +2 -2
  30. data/lib/middleman-core/meta_pages/assets/config.css +13 -0
  31. data/lib/middleman-core/meta_pages/assets/meta.css +19 -3
  32. data/lib/middleman-core/meta_pages/assets/sitemap.css +18 -1
  33. data/lib/middleman-core/meta_pages/config_setting.rb +7 -9
  34. data/lib/middleman-core/meta_pages/sitemap_resource.rb +24 -15
  35. data/lib/middleman-core/meta_pages/sitemap_tree.rb +5 -1
  36. data/lib/middleman-core/meta_pages/templates/config.html.erb +2 -2
  37. data/lib/middleman-core/meta_pages/templates/index.html.erb +18 -8
  38. data/lib/middleman-core/meta_pages/templates/sitemap.html.erb +4 -5
  39. data/lib/middleman-core/preview_server.rb +6 -3
  40. data/lib/middleman-core/renderers/erb.rb +12 -14
  41. data/lib/middleman-core/renderers/haml.rb +10 -0
  42. data/lib/middleman-core/renderers/markdown.rb +5 -1
  43. data/lib/middleman-core/renderers/sass.rb +0 -4
  44. data/lib/middleman-core/renderers/slim.rb +16 -3
  45. data/lib/middleman-core/sitemap/resource.rb +1 -1
  46. data/lib/middleman-core/step_definitions.rb +2 -1
  47. data/lib/middleman-core/templates.rb +3 -1
  48. data/lib/middleman-core/templates/shared/Gemfile.tt +4 -1
  49. data/lib/middleman-core/templates/shared/config.tt +3 -1
  50. data/lib/middleman-core/templates/shared/gitignore +2 -1
  51. data/lib/middleman-core/util.rb +22 -16
  52. data/lib/middleman-core/version.rb +1 -1
  53. data/lib/middleman-more/core_extensions/compass.rb +3 -3
  54. data/lib/middleman-more/core_extensions/default_helpers.rb +18 -15
  55. data/lib/middleman-more/extensions/asset_hash.rb +1 -0
  56. data/middleman-core.gemspec +9 -6
  57. metadata +69 -227
  58. data/features/sass_cache_path.feature +0 -22
  59. data/fixtures/sass-cache-path-custom-app/config.rb +0 -3
  60. data/fixtures/sass-cache-path-custom-app/source/stylesheets/plain.css.sass +0 -4
  61. data/fixtures/sass-cache-path-default-app/config.rb +0 -3
  62. data/fixtures/sass-cache-path-default-app/source/stylesheets/plain.css.sass +0 -4
  63. data/lib/vendored-middleman-deps/hooks-0.2.0/CHANGES.textile +0 -9
  64. data/lib/vendored-middleman-deps/hooks-0.2.0/Gemfile +0 -3
  65. data/lib/vendored-middleman-deps/hooks-0.2.0/README.rdoc +0 -107
  66. data/lib/vendored-middleman-deps/hooks-0.2.0/Rakefile +0 -12
  67. data/lib/vendored-middleman-deps/hooks-0.2.0/hooks.gemspec +0 -22
  68. data/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks.rb +0 -109
  69. data/lib/vendored-middleman-deps/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +0 -33
  70. data/lib/vendored-middleman-deps/hooks-0.2.0/test/hooks_test.rb +0 -141
  71. data/lib/vendored-middleman-deps/hooks-0.2.0/test/inheritable_attribute_test.rb +0 -55
  72. data/lib/vendored-middleman-deps/hooks-0.2.0/test/test_helper.rb +0 -10
  73. data/lib/vendored-middleman-deps/padrino-core-0.11.4/.document +0 -5
  74. data/lib/vendored-middleman-deps/padrino-core-0.11.4/.gitignore +0 -22
  75. data/lib/vendored-middleman-deps/padrino-core-0.11.4/.yardopts +0 -1
  76. data/lib/vendored-middleman-deps/padrino-core-0.11.4/LICENSE.txt +0 -20
  77. data/lib/vendored-middleman-deps/padrino-core-0.11.4/README.rdoc +0 -294
  78. data/lib/vendored-middleman-deps/padrino-core-0.11.4/Rakefile +0 -5
  79. data/lib/vendored-middleman-deps/padrino-core-0.11.4/bin/padrino +0 -9
  80. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core.rb +0 -200
  81. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application.rb +0 -297
  82. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/flash.rb +0 -229
  83. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering.rb +0 -317
  84. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/erubis.rb +0 -64
  85. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/haml.rb +0 -28
  86. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/rendering/extensions/slim.rb +0 -14
  87. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/routing.rb +0 -1077
  88. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/application/showexceptions.rb +0 -21
  89. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/caller.rb +0 -53
  90. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/adapter.rb +0 -24
  91. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/base.rb +0 -159
  92. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/console.rb +0 -20
  93. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake.rb +0 -47
  94. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/cli/rake_tasks.rb +0 -52
  95. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/command.rb +0 -38
  96. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/images/404.png +0 -0
  97. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/images/500.png +0 -0
  98. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/loader.rb +0 -224
  99. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/cs.yml +0 -33
  100. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/da.yml +0 -33
  101. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/de.yml +0 -33
  102. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/en.yml +0 -33
  103. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/es.yml +0 -33
  104. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/fr.yml +0 -33
  105. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/hu.yml +0 -33
  106. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/it.yml +0 -39
  107. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ja.yml +0 -33
  108. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/lv.yml +0 -33
  109. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/nl.yml +0 -33
  110. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/no.yml +0 -33
  111. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/pl.yml +0 -33
  112. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/pt_br.yml +0 -39
  113. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ro.yml +0 -33
  114. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/ru.yml +0 -34
  115. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/sv.yml +0 -33
  116. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/tr.yml +0 -33
  117. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/uk.yml +0 -33
  118. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_cn.yml +0 -33
  119. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/locale/zh_tw.yml +0 -33
  120. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/logger.rb +0 -438
  121. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/module.rb +0 -58
  122. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/mounter.rb +0 -234
  123. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/reloader.rb +0 -341
  124. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/router.rb +0 -95
  125. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/server.rb +0 -77
  126. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/support_lite.rb +0 -260
  127. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/tasks.rb +0 -21
  128. data/lib/vendored-middleman-deps/padrino-core-0.11.4/lib/padrino-core/version.rb +0 -20
  129. data/lib/vendored-middleman-deps/padrino-core-0.11.4/padrino-core.gemspec +0 -43
  130. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/Gemfile +0 -4
  131. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/app/app.rb +0 -3
  132. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/app_gem.gemspec +0 -17
  133. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem.rb +0 -7
  134. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/app_gem/lib/app_gem/version.rb +0 -3
  135. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/.components +0 -6
  136. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/.gitignore +0 -7
  137. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/complex.rb +0 -32
  138. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/apps/simple.rb +0 -33
  139. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/a.rb +0 -9
  140. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/b.rb +0 -4
  141. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/c.rb +0 -1
  142. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/e.rb +0 -13
  143. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/f.rb +0 -2
  144. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/circular/g.rb +0 -2
  145. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/fixtures/dependencies/d.rb +0 -4
  146. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/helper.rb +0 -83
  147. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/mini_shoulda.rb +0 -45
  148. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_application.rb +0 -125
  149. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_core.rb +0 -77
  150. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_csrf_protection.rb +0 -80
  151. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_dependencies.rb +0 -44
  152. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_filters.rb +0 -348
  153. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_flash.rb +0 -168
  154. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_locale.rb +0 -21
  155. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_logger.rb +0 -210
  156. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_mounter.rb +0 -199
  157. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_complex.rb +0 -75
  158. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_reloader_simple.rb +0 -98
  159. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering.rb +0 -545
  160. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_rendering_extensions.rb +0 -14
  161. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_restful_routing.rb +0 -33
  162. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_router.rb +0 -146
  163. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_routing.rb +0 -1927
  164. data/lib/vendored-middleman-deps/padrino-core-0.11.4/test/test_support_lite.rb +0 -56
  165. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.document +0 -5
  166. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.gitignore +0 -21
  167. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/.yardopts +0 -1
  168. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/LICENSE.txt +0 -20
  169. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/README.rdoc +0 -239
  170. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/Rakefile +0 -5
  171. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers.rb +0 -57
  172. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/asset_tag_helpers.rb +0 -401
  173. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/breadcrumb_helpers.rb +0 -183
  174. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/abstract_form_builder.rb +0 -317
  175. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_builder/standard_form_builder.rb +0 -40
  176. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/form_helpers.rb +0 -919
  177. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/format_helpers.rb +0 -372
  178. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/cs.yml +0 -103
  179. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/da.yml +0 -91
  180. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/de.yml +0 -81
  181. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/en.yml +0 -103
  182. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/es.yml +0 -103
  183. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/fr.yml +0 -79
  184. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/hu.yml +0 -103
  185. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/it.yml +0 -89
  186. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ja.yml +0 -103
  187. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/lv.yml +0 -103
  188. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/nl.yml +0 -82
  189. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/no.yml +0 -91
  190. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/pl.yml +0 -95
  191. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/pt_br.yml +0 -103
  192. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ro.yml +0 -103
  193. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/ru.yml +0 -103
  194. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/sv.yml +0 -103
  195. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/tr.yml +0 -103
  196. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/uk.yml +0 -103
  197. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/zh_cn.yml +0 -103
  198. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/locale/zh_tw.yml +0 -103
  199. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/number_helpers.rb +0 -283
  200. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers.rb +0 -207
  201. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/abstract_handler.rb +0 -96
  202. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/erb_handler.rb +0 -78
  203. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/haml_handler.rb +0 -63
  204. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/output_helpers/slim_handler.rb +0 -78
  205. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/render_helpers.rb +0 -59
  206. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/tag_helpers.rb +0 -292
  207. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/lib/padrino-helpers/translation_helpers.rb +0 -36
  208. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/padrino-helpers.gemspec +0 -27
  209. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/app.rb +0 -84
  210. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.erb +0 -8
  211. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.haml +0 -5
  212. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/button_to.slim +0 -6
  213. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.erb +0 -14
  214. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.haml +0 -12
  215. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/capture_concat.slim +0 -12
  216. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.erb +0 -14
  217. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.haml +0 -12
  218. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_for.slim +0 -12
  219. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.erb +0 -11
  220. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.haml +0 -9
  221. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/content_tag.slim +0 -9
  222. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.erb +0 -5
  223. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.haml +0 -5
  224. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/current_engine.slim +0 -5
  225. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.erb +0 -20
  226. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.haml +0 -15
  227. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/fields_for.slim +0 -15
  228. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.erb +0 -72
  229. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.haml +0 -59
  230. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_for.slim +0 -59
  231. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.erb +0 -95
  232. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.haml +0 -78
  233. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/form_tag.slim +0 -79
  234. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.erb +0 -5
  235. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.haml +0 -4
  236. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/link_to.slim +0 -4
  237. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.erb +0 -3
  238. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.haml +0 -3
  239. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/mail_to.slim +0 -3
  240. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.erb +0 -3
  241. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.haml +0 -3
  242. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/meta_tag.slim +0 -3
  243. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_erb.erb +0 -1
  244. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_haml.haml +0 -1
  245. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/partials/_slim.slim +0 -1
  246. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.erb +0 -1
  247. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.haml +0 -1
  248. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/markup_app/views/simple_partial.slim +0 -1
  249. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/app.rb +0 -58
  250. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engine.haml +0 -5
  251. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_erb.erb +0 -1
  252. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_haml.haml +0 -1
  253. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/current_engines/_slim.slim +0 -1
  254. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_erb.erb +0 -3
  255. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_haml.haml +0 -2
  256. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/double_capture_slim.slim +0 -2
  257. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/erb/test.erb +0 -1
  258. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/explicit_engine.haml +0 -5
  259. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/haml/test.haml +0 -1
  260. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/_user.haml +0 -7
  261. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/haml_template.haml +0 -1
  262. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/fixtures/render_app/views/template/some_template.haml +0 -2
  263. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/helper.rb +0 -67
  264. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_asset_tag_helpers.rb +0 -359
  265. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_breadcrumb_helpers.rb +0 -134
  266. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_builder.rb +0 -1178
  267. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_form_helpers.rb +0 -1030
  268. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_format_helpers.rb +0 -241
  269. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_locale.rb +0 -20
  270. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_number_helpers.rb +0 -143
  271. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_output_helpers.rb +0 -154
  272. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_render_helpers.rb +0 -94
  273. data/lib/vendored-middleman-deps/padrino-helpers-0.11.4/test/test_tag_helpers.rb +0 -117
@@ -1,56 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
2
-
3
- describe "ObjectSpace" do
4
- def setup
5
- end
6
-
7
- def teardown
8
- end
9
-
10
- context "#classes" do
11
- should "take an snapshot of the current loaded classes" do
12
- snapshot = ObjectSpace.classes
13
- assert_equal snapshot.include?(Padrino::Logger), true
14
- end
15
-
16
- should "return a Set object" do
17
- snapshot = ObjectSpace.classes
18
- assert_equal snapshot.kind_of?(Set), true
19
- end
20
-
21
- should "be able to process a the class name given a block" do
22
- klasses = ObjectSpace.classes do |klass|
23
- if klass.name =~ /^Padrino::/
24
- klass
25
- end
26
- end
27
-
28
- assert_equal (klasses.size > 1), true
29
- klasses.each do |klass|
30
- assert_match /^Padrino::/, klass.to_s
31
- end
32
- end
33
- end
34
-
35
- context "#new_classes" do
36
- setup do
37
- @snapshot = ObjectSpace.classes
38
- end
39
-
40
- should "return list of new classes" do
41
- class OSTest; end
42
- module OSTestModule; class B; end; end
43
-
44
- new_classes = ObjectSpace.new_classes(@snapshot)
45
-
46
- assert_equal new_classes.size, 2
47
- assert_equal new_classes.include?(OSTest), true
48
- assert_equal new_classes.include?(OSTestModule::B), true
49
- end
50
-
51
- should "return a Set object" do
52
- new_classes = ObjectSpace.new_classes(@snapshot)
53
- assert_equal new_classes.kind_of?(Set), true
54
- end
55
- end
56
- end
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- README.rdoc
5
- LICENSE.txt
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
@@ -1 +0,0 @@
1
- --title 'Padrino Helpers Documentation' --protected
@@ -1,20 +0,0 @@
1
- Copyright (c) 2011 Padrino
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,239 +0,0 @@
1
- = Application Extensions and Helpers (padrino-helpers)
2
-
3
- === Overview
4
-
5
- This component provides a great deal of view helpers related to html markup generation.
6
- There are helpers for generating tags, forms, links, images, and more. Most of the basic
7
- methods should be very familiar to anyone who has used rails view helpers.
8
-
9
- === Output Helpers
10
-
11
- Output helpers are a collection of important methods for managing, capturing and displaying output
12
- in various ways and is used frequently to support higher-level helper functions. There are
13
- three output helpers worth mentioning: <tt>content_for</tt>, <tt>capture_html</tt>, and <tt>concat_content</tt>
14
-
15
- The content_for functionality supports capturing content and then rendering this into a different place
16
- such as within a layout. One such popular example is including assets onto the layout from a template:
17
-
18
- # app/views/site/index.erb
19
- ...
20
- <% content_for :assets do %>
21
- <%= stylesheet_link_tag 'index', 'custom' %>
22
- <% end %>
23
- ...
24
-
25
- Added to a template, this will capture the includes from the block and allow them to be yielded into the layout:
26
-
27
- # app/views/layout.erb
28
- ...
29
- <head>
30
- <title>Example</title>
31
- <%= stylesheet_link_tag 'style' %>
32
- <%= yield_content :assets %>
33
- </head>
34
- ...
35
-
36
- This will automatically insert the contents of the block (in this case a stylesheet include) into the
37
- location the content is yielded within the layout. You can also check if content exists for a block using
38
- <tt>content_for?(true)</tt> which returns true if content exists.
39
-
40
- The capture_html and the concat_content methods allow content to be manipulated and stored for use in building
41
- additional helpers accepting blocks or displaying information in a template. One example is the use of
42
- these in constructing a simplified 'form_tag' helper which accepts a block.
43
-
44
- # form_tag '/register' do ... end
45
- def form_tag(url, options={}, &block)
46
- # ... truncated ...
47
- inner_form_html = capture_html(&block)
48
- concat_content '<form>' + inner_form_html + '</form>'
49
- end
50
-
51
- This will capture the template body passed into the form_tag block and then append the content
52
- to the template through the use of <tt>concat_content</tt>. Note have been built to work for both haml and erb
53
- templates using the same syntax.
54
-
55
- For more information on using output helpers, check out the guide for
56
- {Padrino Helpers}[http://www.padrinorb.com/guides/application-helpers].
57
-
58
- === Tag Helpers
59
-
60
- Tag helpers are the basic building blocks used to construct html 'tags' within a view template. There
61
- are three major functions for this category: <tt>tag</tt>, <tt>content_tag</tt> and <tt>input_tag</tt>.
62
-
63
- The tag and content_tag are for building arbitrary html tags with a name and specified options. If
64
- the tag contains 'content' within then <tt>content_tag</tt> is used. For example:
65
-
66
- tag(:br, :style => 'clear:both') => <br style="clear:both" />
67
- content_tag(:p, "demo", :class => 'light') => <p class="light">demo</p>
68
-
69
- The input_tag is used to build tags that are related to accepting input from the user:
70
-
71
- input_tag :text, :class => "demo" => <input type='text' class='demo' />
72
- input_tag :password, :value => "secret", :class => "demo"
73
-
74
- Note that all of these accept html options and result in returning a string containing html tags.
75
-
76
- For more information on using tag helpers, check out the guide for
77
- {Padrino Helpers}[http://www.padrinorb.com/guides/application-helpers].
78
-
79
- === Asset Helpers
80
-
81
- Asset helpers are intended to help insert useful html onto a view template such as 'flash' notices,
82
- hyperlinks, mail_to links, images, stylesheets and javascript. An example of their uses would be on a
83
- simple view template:
84
-
85
- # app/views/example.haml
86
- ...
87
- %head
88
- = stylesheet_link_tag 'layout'
89
- = javascript_include_tag 'application'
90
- %body
91
- ...
92
- = flash_tag :notice
93
- %p= link_to 'Blog', '/blog', :class => 'example'
94
- %p Mail me at #{mail_to 'fake@faker.com', "Fake Email Link", :cc => "test@demo.com"}
95
- %p= image_tag 'padrino.png', :width => '35', :class => 'logo'
96
-
97
- For more information on using asset helpers, check out the guide for
98
- {Padrino Helpers}[http://www.padrinorb.com/guides/application-helpers].
99
-
100
- === Form Helpers
101
-
102
- Form helpers are the 'standard' form tag helpers you would come to expect when building forms. A simple
103
- example of constructing a non-object form would be:
104
-
105
- - form_tag '/destroy', :class => 'destroy-form', :method => 'delete' do
106
- = flash_tag(:notice)
107
- - field_set_tag do
108
- %p
109
- = label_tag :username, :class => 'first'
110
- = text_field_tag :username, :value => params[:username]
111
- %p
112
- = label_tag :password, :class => 'first'
113
- = password_field_tag :password, :value => params[:password]
114
- %p
115
- = label_tag :strategy
116
- = select_tag :strategy, :options => ['delete', 'destroy'], :selected => 'delete'
117
- %p
118
- = check_box_tag :confirm_delete
119
- - field_set_tag(:class => 'buttons') do
120
- = submit_tag "Remove"
121
-
122
- For more information on using form helpers, check out the guide for
123
- {Padrino Helpers}[http://www.padrinorb.com/guides/application-helpers].
124
-
125
- === FormBuilders
126
-
127
- Form builders are full-featured objects allowing the construction of complex object-based forms
128
- using a simple, intuitive syntax.
129
-
130
- A form_for using these basic fields might look like:
131
-
132
- - form_for @user, '/register', :id => 'register' do |f|
133
- = f.error_messages
134
- %p
135
- = f.label :username, :caption => "Nickname"
136
- = f.text_field :username
137
- %p
138
- = f.label :email
139
- = f.text_field :email
140
- %p
141
- = f.label :password
142
- = f.password_field :password
143
- %p
144
- = f.label :is_admin, :caption => "Admin User?"
145
- = f.check_box :is_admin
146
- %p
147
- = f.label :color, :caption => "Favorite Color?"
148
- = f.select :color, :options => ['red', 'black']
149
- %p
150
- - fields_for @user.location do |location|
151
- = location.text_field :street
152
- = location.text_field :city
153
- %p
154
- = f.submit "Create", :class => 'button'
155
-
156
- Forms can also accept nested attributes using `fields_for` within the form builder in recent releases. Check out the guide for {Padrino Helpers}[http://www.padrinorb.com/guides/application-helpers] to learn more about nested forms.
157
-
158
- There is also an additional StandardFormBuilder which builds on the abstract fields that can be used within a form_for.
159
-
160
- A form_for using these standard fields might be:
161
-
162
- - form_for @user, '/register', :id => 'register' do |f|
163
- = f.error_messages
164
- = f.text_field_block :name, :caption => "Full name"
165
- = f.text_field_block :email
166
- = f.check_box_block :remember_me
167
- = f.select_block :fav_color, :options => ['red', 'blue']
168
- = f.password_field_block :password
169
- = f.submit_block "Create", :class => 'button'
170
-
171
- and would generate this html (with each input contained in a paragraph and containing a label):
172
-
173
- <form id="register" action="/register" method="post">
174
- <p><label for="user_name">Full name: </label><input type="text" id="user_name" name="user[name]"></p>
175
- ...omitted...
176
- <p><input type="submit" value="Create" class="button"></p>
177
- </form>
178
-
179
- You can also easily build your own FormBuilder which allows for customized fields and behavior.
180
-
181
- For more information on using the Padrino form builders, check out the guide for
182
- {Padrino Helpers}[http://www.padrinorb.com/guides/application-helpers].
183
-
184
- === Format Helpers
185
-
186
- Format helpers are several useful utilities for manipulating the format of text to achieve a goal.
187
- The four format helpers are <tt>escape_html</tt>, <tt>time_ago_in_words</tt>, and <tt>js_escape_html</tt>.
188
-
189
- The escape_html and js_escape_html function are for taking an html string and escaping certain characters.
190
- <tt>escape_html</tt> will escape ampersands, brackets and quotes to their HTML/XML entities. This is useful
191
- to sanitize user content before displaying this on a template. <tt>js_escape_html</tt> is used for
192
- passing javascript information from a js template to a javascript function.
193
-
194
- escape_html('<hello>&<goodbye>') # => &lt;hello&gt;&amp;&lt;goodbye&gt;
195
-
196
- There is also an alias for escape_html called <tt>h</tt> for even easier usage within templates.
197
-
198
- Format helpers also includes a number of useful text manipulation functions such as <tt>simple_format</tt>,
199
- <tt>pluralize</tt>, <tt>word_wrap</tt>, <tt>truncate</tt> and <tt>truncate_words</tt>.
200
-
201
- simple_format("hello\nworld") # => "<p>hello<br/>world</p>"
202
- pluralize(2, 'person') => '2 people'
203
- word_wrap('Once upon a time', :line_width => 8) => "Once upon\na time"
204
- truncate("Once upon a time in a world far far away", :length => 8) => "Once upon..."
205
- truncate_words("Once upon a time in a world far far away", :length => 4) => "Once upon a time..."
206
-
207
- These helpers can be invoked from any route or view within your application.
208
-
209
- For more information on using the format helpers, check out the guide for
210
- {Padrino Helpers}[http://www.padrinorb.com/guides/application-helpers].
211
-
212
- === Render Helpers
213
-
214
- This component provides a number of rendering helpers making the process of displaying templates a bit easier.
215
- This plugin also has support for useful additions such as partials (with support for :collection) for the templating system.
216
-
217
- Using render plugin helpers is extremely simple. If you want to render an erb template in your view path:
218
-
219
- render :erb, 'path/to/erb/template'
220
-
221
- or using haml templates works just as well:
222
-
223
- render :haml, 'path/to/haml/template'
224
-
225
- There is also a method which renders the first view matching the path and removes the need to define an engine:
226
-
227
- render 'path/to/any/template'
228
-
229
- Finally, we have the all-important partials support for rendering mini-templates onto a page:
230
-
231
- partial 'photo/_item', :object => @photo, :locals => { :foo => 'bar' }
232
- partial 'photo/_item', :collection => @photos
233
-
234
- For more information on using the render and partial helpers, check out the guide for
235
- {Padrino Helpers}[http://www.padrinorb.com/guides/application-helpers].
236
-
237
- == Copyright
238
-
239
- Copyright (c) 2011-2013 Padrino. See LICENSE for details.
@@ -1,5 +0,0 @@
1
- # coding:utf-8
2
- RAKE_ROOT = __FILE__
3
-
4
- require 'rubygems'
5
- require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
@@ -1,57 +0,0 @@
1
- require 'padrino-core/support_lite' unless defined?(SupportLite)
2
- require 'i18n'
3
- require 'enumerator'
4
- require 'active_support/time_with_zone' # next extension depends on this
5
- require 'active_support/core_ext/string/conversions' # to_date
6
- require 'active_support/option_merger' # with_options
7
- require 'active_support/core_ext/object/with_options' # with_options
8
- require 'active_support/inflector' # humanize
9
-
10
- FileSet.glob_require('padrino-helpers/**/*.rb', __FILE__)
11
- I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-helpers/locale/*.yml"]
12
-
13
- module Padrino
14
- ##
15
- # This component provides a variety of view helpers related to html markup generation.
16
- # There are helpers for generating tags, forms, links, images, and more.
17
- # Most of the basic methods should be very familiar to anyone who has used rails view helpers.
18
- #
19
- module Helpers
20
- class << self
21
- ##
22
- # Registers these helpers into your application:
23
- #
24
- # Padrino::Helpers::OutputHelpers
25
- # Padrino::Helpers::TagHelpers
26
- # Padrino::Helpers::AssetTagHelpers
27
- # Padrino::Helpers::FormHelpers
28
- # Padrino::Helpers::FormatHelpers
29
- # Padrino::Helpers::RenderHelpers
30
- # Padrino::Helpers::NumberHelpers
31
- # Padrino::Helpers::Breadcrumbs
32
- #
33
- # @param [Sinatra::Application] app
34
- # The specified Padrino application.
35
- #
36
- # @example Register the helper module
37
- # require 'padrino-helpers'
38
- # class Padrino::Application
39
- # register Padrino::Helpers
40
- # end
41
- #
42
- def registered(app)
43
- app.set :default_builder, 'StandardFormBuilder'
44
- app.helpers Padrino::Helpers::OutputHelpers
45
- app.helpers Padrino::Helpers::TagHelpers
46
- app.helpers Padrino::Helpers::AssetTagHelpers
47
- app.helpers Padrino::Helpers::FormHelpers
48
- app.helpers Padrino::Helpers::FormatHelpers
49
- app.helpers Padrino::Helpers::RenderHelpers
50
- app.helpers Padrino::Helpers::NumberHelpers
51
- app.helpers Padrino::Helpers::TranslationHelpers
52
- app.helpers Padrino::Helpers::Breadcrumbs
53
- end
54
- alias :included :registered
55
- end
56
- end
57
- end
@@ -1,401 +0,0 @@
1
- module Padrino
2
- module Helpers
3
- ###
4
- # Helpers related to producing assets (images, stylesheets, js, etc) within templates.
5
- #
6
- module AssetTagHelpers
7
- FRAGMENT_HASH = "#".html_safe.freeze
8
- APPEND_ASSET_EXTENSIONS = ["js", "css"]
9
- ABSOLUTE_URL_PATTERN = %r{^(https?://)}
10
-
11
- ##
12
- # Creates a div to display the flash of given type if it exists.
13
- #
14
- # @param [Symbol] kind
15
- # The type of flash to display in the tag.
16
- # @param [Hash] options
17
- # The html options for this section.
18
- # use :bootstrap => true to support Twitter's bootstrap dismiss alert button.
19
- #
20
- # @return [String] Flash tag html with specified +options+.
21
- #
22
- # @example
23
- # flash_tag(:notice, :id => 'flash-notice')
24
- # # Generates: <div class="notice">flash-notice</div>
25
- # flash_tag(:error, :success)
26
- # # Generates: <div class="error">flash-error</div>
27
- # # <div class="success">flash-success</div>
28
- #
29
- def flash_tag(*args)
30
- options = args.extract_options!
31
- bootstrap = options.delete(:bootstrap) if options[:bootstrap]
32
- args.inject(''.html_safe) do |html,kind|
33
- flash_text = flash[kind]
34
- next html if flash_text.blank?
35
- flash_text << safe_content_tag(:button, "&times;", {:type => :button, :class => :close, :'data-dismiss' => :alert}) if bootstrap
36
- html << safe_content_tag(:div, flash_text, options.reverse_merge(:class => kind))
37
- end
38
- end
39
-
40
- ##
41
- # Creates a link element with given name, url and options.
42
- #
43
- # @overload link_to(caption, url, options={})
44
- # @param [String] caption The text caption.
45
- # @param [String] url The url href.
46
- # @param [Hash] options The html options.
47
- # @overload link_to(url, options={}, &block)
48
- # @param [String] url The url href.
49
- # @param [Hash] options The html options.
50
- # @param [Proc] block The link content.
51
- #
52
- # @option options [String] :anchor
53
- # The anchor for the link (i.e #something).
54
- # @option options [String] :fragment
55
- # Synonym for anchor.
56
- # @option options [Boolean] :if
57
- # If true, the link will appear, otherwise not.
58
- # @option options [Boolean] :unless
59
- # If false, the link will appear, otherwise not.
60
- # @option options [Boolean] :remote
61
- # If true, this link should be handled by an ajax ujs handler.
62
- # @option options [String] :confirm
63
- # Instructs ujs handler to alert confirm message.
64
- # @option options [Symbol] :method
65
- # Instructs ujs handler to use different http method (i.e :post, :delete).
66
- #
67
- # @return [String] Link tag html with specified +options+.
68
- #
69
- # @example
70
- # link_to('click me', '/dashboard', :class => 'linky')
71
- # link_to('click me', '/dashboard', :remote => true)
72
- # link_to('click me', '/dashboard', :method => :delete)
73
- # link_to('click me', :class => 'blocky') do; end
74
- #
75
- # Note that you can pass :+if+ or :+unless+ conditions, but if you provide :current as
76
- # condition padrino return true/false if the request.path_info match the given url.
77
- #
78
- def link_to(*args, &block)
79
- options = args.extract_options!
80
- fragment = options.delete(:anchor).to_s if options[:anchor]
81
- fragment = options.delete(:fragment).to_s if options[:fragment]
82
-
83
- url = ActiveSupport::SafeBuffer.new
84
- if block_given?
85
- if args[0]
86
- url.concat(args[0])
87
- url.concat(FRAGMENT_HASH).concat(fragment) if fragment
88
- else
89
- url.concat(FRAGMENT_HASH)
90
- url.concat(fragment) if fragment
91
- end
92
- options.reverse_merge!(:href => url)
93
- link_content = capture_html(&block)
94
- return '' unless parse_conditions(url, options)
95
- result_link = content_tag(:a, link_content, options)
96
- block_is_template?(block) ? concat_content(result_link) : result_link
97
- else
98
- if args[1]
99
- url.concat(args[1])
100
- url.safe_concat(FRAGMENT_HASH).concat(fragment) if fragment
101
- else
102
- url = FRAGMENT_HASH
103
- url.concat(fragment) if fragment
104
- end
105
- name = args[0]
106
- return name unless parse_conditions(url, options)
107
- options.reverse_merge!(:href => url)
108
- content_tag(:a, name, options)
109
- end
110
- end
111
-
112
- ##
113
- # Creates a link tag that browsers and news readers can use to auto-detect an RSS or ATOM feed.
114
- #
115
- # @param [Symbol] mime
116
- # The mime type of the feed (i.e :atom or :rss).
117
- # @param [String] url
118
- # The url for the feed tag to reference.
119
- # @param[Hash] options
120
- # The options for the feed tag.
121
- # @option options [String] :rel ("alternate")
122
- # Specify the relation of this link.
123
- # @option options [String] :type
124
- # Override the auto-generated mime type.
125
- # @option options [String] :title
126
- # Specify the title of the link, defaults to the type.
127
- #
128
- # @return [String] Feed link html tag with specified +options+.
129
- #
130
- # @example
131
- # feed_tag :atom, url(:blog, :posts, :format => :atom), :title => "ATOM"
132
- # # Generates: <link type="application/atom+xml" rel="alternate" href="/blog/posts.atom" title="ATOM" />
133
- # feed_tag :rss, url(:blog, :posts, :format => :rss)
134
- # # Generates: <link type="application/rss+xml" rel="alternate" href="/blog/posts.rss" title="rss" />
135
- #
136
- def feed_tag(mime, url, options={})
137
- full_mime = (mime == :atom) ? 'application/atom+xml' : 'application/rss+xml'
138
- tag(:link, options.reverse_merge(:rel => 'alternate', :type => full_mime, :title => mime, :href => url))
139
- end
140
-
141
- ##
142
- # Creates a mail link element with given name and caption.
143
- #
144
- # @param [String] email
145
- # The email address for the link.
146
- # @param [String] caption
147
- # The caption for the link.
148
- # @param [Hash] mail_options
149
- # The options for the mail link. Accepts html options.
150
- # @option mail_options [String] cc The cc recipients.
151
- # @option mail_options [String] bcc The bcc recipients.
152
- # @option mail_options [String] subject The subject line.
153
- # @option mail_options [String] body The email body.
154
- #
155
- # @return [String] Mail link html tag with specified +options+.
156
- #
157
- # @example
158
- # # Generates: <a href="mailto:me@demo.com">me@demo.com</a>
159
- # mail_to "me@demo.com"
160
- # # Generates: <a href="mailto:me@demo.com">My Email</a>
161
- # mail_to "me@demo.com", "My Email"
162
- #
163
- def mail_to(email, caption=nil, mail_options={})
164
- html_options = mail_options.slice!(:cc, :bcc, :subject, :body)
165
- mail_query = Rack::Utils.build_query(mail_options).gsub(/\+/, '%20').gsub('%40', '@').gsub('&', '&amp;')
166
- mail_href = "mailto:#{email}"; mail_href << "?#{mail_query}" if mail_query.present?
167
- link_to((caption || email), mail_href, html_options)
168
- end
169
-
170
- ##
171
- # Creates a meta element with the content and given options.
172
- #
173
- # @param [String] content
174
- # The content for the meta tag.
175
- # @param [Hash] options
176
- # The html options for the meta tag.
177
- #
178
- # @return [String] Meta html tag with specified +options+.
179
- #
180
- # @example
181
- # # Generates: <meta name="keywords" content="weblog,news" />
182
- # meta_tag "weblog,news", :name => "keywords"
183
- #
184
- # # Generates: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
185
- # meta_tag "text/html; charset=UTF-8", 'http-equiv' => "Content-Type"
186
- #
187
- def meta_tag(content, options={})
188
- options.reverse_merge!("content" => content)
189
- tag(:meta, options)
190
- end
191
-
192
- ##
193
- # Generates a favicon link. Looks inside images folder
194
- #
195
- # @param [String] source
196
- # The source image path for the favicon link tag.
197
- # @param [Hash] options
198
- # The html options for the favicon link tag.
199
- #
200
- # @return [String] The favicon link html tag with specified +options+.
201
- #
202
- # @example
203
- # favicon_tag 'favicon.png'
204
- # favicon_tag 'icons/favicon.png'
205
- # # or override some options
206
- # favicon_tag 'favicon.png', :type => 'image/ico'
207
- #
208
- def favicon_tag(source, options={})
209
- type = File.extname(source).gsub('.','')
210
- options = options.dup.reverse_merge!(:href => image_path(source), :rel => 'icon', :type => "image/#{type}")
211
- tag(:link, options)
212
- end
213
-
214
- ##
215
- # Creates an image element with given url and options.
216
- #
217
- # @param [String] url
218
- # The source path for the image tag.
219
- # @param [Hash] options
220
- # The html options for the image tag.
221
- #
222
- # @return [String] Image html tag with +url+ and specified +options+.
223
- #
224
- # @example
225
- # image_tag('icons/avatar.png')
226
- #
227
- def image_tag(url, options={})
228
- options.reverse_merge!(:src => image_path(url))
229
- tag(:img, options)
230
- end
231
-
232
- ##
233
- # Returns an html script tag for each of the sources provided.
234
- # You can pass in the filename without extension or a symbol and we search it in your +appname.public_folder+
235
- # like app/public/stylesheets for inclusion. You can provide also a full path.
236
- #
237
- # @overload stylesheet_link_tag(*sources, options={})
238
- # @param [Array<String>] sources Splat of css source paths
239
- # @param [Hash] options The html options for the link tag
240
- #
241
- # @return [String] Stylesheet link html tag for +sources+ with specified +options+.
242
- #
243
- # @example
244
- # stylesheet_link_tag 'style', 'application', 'layout'
245
- #
246
- # @api public.
247
- def stylesheet_link_tag(*sources)
248
- options = sources.extract_options!.symbolize_keys
249
- options.reverse_merge!(:media => 'screen', :rel => 'stylesheet', :type => 'text/css')
250
- sources.flatten.map { |source|
251
- tag(:link, options.reverse_merge(:href => asset_path(:css, source)))
252
- }.join("\n").html_safe
253
- end
254
-
255
- ##
256
- # Returns an html script tag for each of the sources provided.
257
- # You can pass in the filename without extension or a symbol and we search it in your +appname.public_folder+
258
- # like app/public/javascript for inclusion. You can provide also a full path.
259
- #
260
- # @overload javascript_include_tag(*sources, options={})
261
- # @param [Array<String>] sources Splat of js source paths
262
- # @param [Hash] options The html options for the script tag
263
- #
264
- # @return [String] Script tag for +sources+ with specified +options+.
265
- #
266
- # @example
267
- # javascript_include_tag 'application', :extjs
268
- #
269
- def javascript_include_tag(*sources)
270
- options = sources.extract_options!.symbolize_keys
271
- options.reverse_merge!(:type => 'text/javascript')
272
- sources.flatten.map { |source|
273
- content_tag(:script, nil, options.reverse_merge(:src => asset_path(:js, source)))
274
- }.join("\n").html_safe
275
- end
276
-
277
- ##
278
- # Returns the path to the image, either relative or absolute. We search it in your +appname.public_folder+
279
- # like app/public/images for inclusion. You can provide also a full path.
280
- #
281
- # @param [String] src
282
- # The path to the image file (relative or absolute).
283
- #
284
- # @return [String] Path to an image given the +kind+ and +source+.
285
- #
286
- # @example
287
- # # Generates: /images/foo.jpg?1269008689
288
- # image_path("foo.jpg")
289
- #
290
- # @api public
291
- def image_path(src)
292
- asset_path(:images, src)
293
- end
294
-
295
- ##
296
- # Returns the path to the specified asset (css or javascript).
297
- #
298
- # @param [String] kind
299
- # The kind of asset (i.e :images, :js, :css).
300
- # @param [String] source
301
- # The path to the asset (relative or absolute).
302
- #
303
- # @return [String] Path for the asset given the +kind+ and +source+.
304
- #
305
- # @example
306
- # # Generates: /javascripts/application.js?1269008689
307
- # asset_path :js, :application
308
- #
309
- # # Generates: /stylesheets/application.css?1269008689
310
- # asset_path :css, :application
311
- #
312
- # # Generates: /images/example.jpg?1269008689
313
- # asset_path :images, 'example.jpg'
314
- #
315
- def asset_path(kind, source)
316
- source = asset_normalize_extension(kind, URI.escape(source.to_s))
317
- return source if source =~ ABSOLUTE_URL_PATTERN || source =~ /^\// # absolute source
318
- source = File.join(asset_folder_name(kind), source)
319
- timestamp = asset_timestamp(source)
320
- result_path = uri_root_path(source)
321
- "#{result_path}#{timestamp}"
322
- end
323
-
324
- private
325
- ##
326
- # Returns the URI root of the application with optional paths appended.
327
- #
328
- # @example
329
- # uri_root_path("/some/path") => "/root/some/path"
330
- # uri_root_path("javascripts", "test.js") => "/uri/root/javascripts/test.js"
331
- #
332
- def uri_root_path(*paths)
333
- root_uri = self.class.uri_root if self.class.respond_to?(:uri_root)
334
- File.join(ENV['RACK_BASE_URI'].to_s, root_uri || '/', *paths)
335
- end
336
-
337
- ##
338
- # Returns the timestamp mtime for an asset.
339
- #
340
- # @example
341
- # asset_timestamp("some/path/to/file.png") => "?154543678"
342
- #
343
- def asset_timestamp(file_path)
344
- return nil if file_path =~ /\?/ || (self.class.respond_to?(:asset_stamp) && !self.class.asset_stamp)
345
- public_path = self.class.public_folder if self.class.respond_to?(:public_folder)
346
- public_path ||= Padrino.root("public") if Padrino.respond_to?(:root)
347
- public_file_path = File.join(public_path, file_path) if public_path
348
- stamp = File.mtime(public_file_path).to_i if public_file_path && File.exist?(public_file_path)
349
- stamp ||= Time.now.to_i
350
- "?#{stamp}"
351
- end
352
-
353
- ###
354
- # Returns the asset folder given a kind.
355
- #
356
- # @example
357
- # asset_folder_name(:css) => 'stylesheets'
358
- # asset_folder_name(:js) => 'javascripts'
359
- # asset_folder_name(:images) => 'images'
360
- #
361
- def asset_folder_name(kind)
362
- case kind
363
- when :css then 'stylesheets'
364
- when :js then 'javascripts'
365
- else kind.to_s
366
- end
367
- end
368
-
369
- ##
370
- # Normalizes the extension for a given asset.
371
- #
372
- # @example
373
- #
374
- # asset_normalize_extension(:images, "/foo/bar/baz.png") => "/foo/bar/baz.png"
375
- # asset_normalize_extension(:js, "/foo/bar/baz") => "/foo/bar/baz.js"
376
- #
377
- def asset_normalize_extension(kind, source)
378
- ignore_extension = !APPEND_ASSET_EXTENSIONS.include?(kind.to_s)
379
- source << ".#{kind}" unless ignore_extension || source =~ /\.#{kind}/ || source =~ ABSOLUTE_URL_PATTERN
380
- source
381
- end
382
-
383
- ##
384
- # Parses link_to options for given correct conditions.
385
- #
386
- # @example
387
- # parse_conditions("/some/url", :if => false) => true
388
- #
389
- def parse_conditions(url, options)
390
- if options.has_key?(:if)
391
- condition = options.delete(:if)
392
- condition == :current ? url == request.path_info : condition
393
- elsif condition = options.delete(:unless)
394
- condition == :current ? url != request.path_info : !condition
395
- else
396
- true
397
- end
398
- end
399
- end
400
- end
401
- end