middleman-core 3.1.0.rc.2 → 3.1.0.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +2 -1
  3. data/features/capture_html.feature +18 -0
  4. data/features/content_for.feature +3 -3
  5. data/features/v4_extension_callbacks.feature +8 -0
  6. data/fixtures/capture-html-app/config.rb +7 -0
  7. data/fixtures/capture-html-app/source/capture_html_erb.html.erb +5 -0
  8. data/fixtures/capture-html-app/source/capture_html_haml.html.haml +4 -0
  9. data/fixtures/capture-html-app/source/capture_html_slim.html.slim +4 -0
  10. data/fixtures/capture-html-app/source/layouts/capture_html.erb +4 -0
  11. data/fixtures/content-for-app/source/content_for_erb.html.erb +1 -1
  12. data/fixtures/content-for-app/source/content_for_haml.html.haml +1 -1
  13. data/fixtures/content-for-app/source/content_for_slim.html.slim +2 -1
  14. data/fixtures/v4-extension-callbacks/config.rb +26 -0
  15. data/fixtures/v4-extension-callbacks/source/index.html.erb +2 -0
  16. data/lib/middleman-core/core_extensions/extensions.rb +6 -1
  17. data/lib/middleman-core/core_extensions/file_watcher.rb +1 -0
  18. data/lib/middleman-core/core_extensions/rendering.rb +1 -2
  19. data/lib/middleman-core/core_extensions/request.rb +2 -2
  20. data/lib/middleman-core/extensions.rb +21 -0
  21. data/lib/middleman-core/meta_pages/sitemap_resource.rb +4 -1
  22. data/lib/middleman-core/version.rb +1 -1
  23. data/lib/middleman-more/core_extensions/default_helpers.rb +17 -3
  24. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/.document +0 -0
  25. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/.gitignore +0 -0
  26. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/.yardopts +0 -0
  27. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/LICENSE.txt +0 -0
  28. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/README.rdoc +0 -0
  29. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/Rakefile +0 -0
  30. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/bin/padrino +0 -0
  31. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core.rb +58 -4
  32. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/application.rb +40 -16
  33. data/lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/flash.rb +229 -0
  34. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/application/rendering.rb +39 -11
  35. data/lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/rendering/extensions/erubis.rb +55 -0
  36. data/lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/rendering/extensions/haml.rb +26 -0
  37. data/lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/application/rendering/extensions/slim.rb +14 -0
  38. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/application/routing.rb +133 -37
  39. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/application/showexceptions.rb +0 -0
  40. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/caller.rb +0 -0
  41. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/cli/adapter.rb +0 -0
  42. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/cli/base.rb +41 -38
  43. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/cli/console.rb +0 -0
  44. data/lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/cli/rake.rb +47 -0
  45. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/cli/rake_tasks.rb +9 -14
  46. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/command.rb +0 -0
  47. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/images/404.png +0 -0
  48. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/images/500.png +0 -0
  49. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/loader.rb +23 -9
  50. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/cs.yml +0 -0
  51. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/da.yml +0 -0
  52. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/de.yml +6 -6
  53. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/en.yml +0 -0
  54. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/es.yml +0 -0
  55. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/fr.yml +1 -1
  56. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/hu.yml +0 -0
  57. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/it.yml +0 -0
  58. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/ja.yml +0 -0
  59. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/lv.yml +0 -0
  60. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/nl.yml +0 -0
  61. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/no.yml +0 -0
  62. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/pl.yml +0 -0
  63. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/pt_br.yml +0 -0
  64. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/ro.yml +0 -0
  65. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/ru.yml +1 -1
  66. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/sv.yml +0 -0
  67. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/tr.yml +0 -0
  68. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/uk.yml +0 -0
  69. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/zh_cn.yml +11 -11
  70. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/locale/zh_tw.yml +0 -0
  71. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/logger.rb +48 -32
  72. data/lib/vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/module.rb +58 -0
  73. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/mounter.rb +15 -5
  74. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/reloader.rb +139 -52
  75. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/router.rb +0 -0
  76. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/server.rb +5 -5
  77. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/support_lite.rb +59 -6
  78. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/tasks.rb +0 -0
  79. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/lib/padrino-core/version.rb +1 -1
  80. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/padrino-core.gemspec +10 -5
  81. data/lib/vendored-middleman-deps/padrino-core-0.11.2/test/fixtures/app_gem/Gemfile +4 -0
  82. data/lib/vendored-middleman-deps/padrino-core-0.11.2/test/fixtures/app_gem/app/app.rb +3 -0
  83. data/lib/vendored-middleman-deps/padrino-core-0.11.2/test/fixtures/app_gem/app_gem.gemspec +17 -0
  84. data/lib/vendored-middleman-deps/padrino-core-0.11.2/test/fixtures/app_gem/lib/app_gem.rb +7 -0
  85. data/lib/vendored-middleman-deps/padrino-core-0.11.2/test/fixtures/app_gem/lib/app_gem/version.rb +3 -0
  86. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/apps/.components +0 -0
  87. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/apps/.gitignore +0 -0
  88. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/apps/complex.rb +0 -0
  89. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/apps/simple.rb +0 -0
  90. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/dependencies/a.rb +0 -0
  91. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/dependencies/b.rb +0 -0
  92. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/dependencies/c.rb +0 -0
  93. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/dependencies/circular/e.rb +0 -0
  94. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/dependencies/circular/f.rb +0 -0
  95. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/dependencies/circular/g.rb +0 -0
  96. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/fixtures/dependencies/d.rb +0 -0
  97. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/helper.rb +0 -0
  98. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/mini_shoulda.rb +2 -2
  99. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_application.rb +38 -21
  100. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_core.rb +0 -0
  101. data/lib/vendored-middleman-deps/padrino-core-0.11.2/test/test_csrf_protection.rb +80 -0
  102. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_dependencies.rb +0 -0
  103. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_filters.rb +70 -0
  104. data/lib/vendored-middleman-deps/padrino-core-0.11.2/test/test_flash.rb +168 -0
  105. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_locale.rb +0 -0
  106. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_logger.rb +27 -0
  107. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_mounter.rb +24 -2
  108. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_reloader_complex.rb +0 -0
  109. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_reloader_simple.rb +4 -4
  110. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_rendering.rb +75 -4
  111. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_restful_routing.rb +0 -0
  112. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_router.rb +0 -0
  113. data/lib/vendored-middleman-deps/{padrino-core-0.10.7 → padrino-core-0.11.2}/test/test_routing.rb +209 -35
  114. data/lib/vendored-middleman-deps/padrino-core-0.11.2/test/test_support_lite.rb +56 -0
  115. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/.document +0 -0
  116. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/.gitignore +0 -0
  117. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/.yardopts +0 -0
  118. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/LICENSE.txt +0 -0
  119. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/README.rdoc +0 -0
  120. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/Rakefile +0 -0
  121. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers.rb +2 -1
  122. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/asset_tag_helpers.rb +58 -66
  123. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/breadcrumb_helpers.rb +171 -0
  124. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/form_builder/abstract_form_builder.rb +84 -26
  125. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/form_builder/standard_form_builder.rb +0 -0
  126. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/form_helpers.rb +94 -19
  127. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/format_helpers.rb +9 -5
  128. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/cs.yml +0 -0
  129. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/da.yml +0 -0
  130. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/de.yml +0 -0
  131. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/en.yml +0 -0
  132. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/es.yml +0 -0
  133. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/fr.yml +12 -12
  134. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/hu.yml +0 -0
  135. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/it.yml +0 -0
  136. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/ja.yml +0 -0
  137. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/lv.yml +0 -0
  138. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/nl.yml +0 -0
  139. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/no.yml +0 -0
  140. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/pl.yml +0 -0
  141. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/pt_br.yml +2 -2
  142. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/ro.yml +0 -0
  143. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/ru.yml +0 -0
  144. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/sv.yml +0 -0
  145. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/tr.yml +0 -0
  146. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/uk.yml +0 -0
  147. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/zh_cn.yml +13 -14
  148. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/locale/zh_tw.yml +0 -0
  149. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/number_helpers.rb +0 -0
  150. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/output_helpers.rb +45 -5
  151. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/output_helpers/abstract_handler.rb +0 -0
  152. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/output_helpers/erb_handler.rb +3 -3
  153. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/output_helpers/haml_handler.rb +0 -0
  154. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/output_helpers/slim_handler.rb +6 -7
  155. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/render_helpers.rb +2 -2
  156. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/tag_helpers.rb +34 -6
  157. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/lib/padrino-helpers/translation_helpers.rb +0 -0
  158. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/padrino-helpers.gemspec +0 -0
  159. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/app.rb +13 -6
  160. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/capture_concat.erb +2 -2
  161. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/capture_concat.haml +2 -2
  162. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/capture_concat.slim +4 -5
  163. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/content_for.erb +0 -0
  164. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/content_for.haml +0 -0
  165. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/content_for.slim +4 -4
  166. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/content_tag.erb +0 -0
  167. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/content_tag.haml +0 -0
  168. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/content_tag.slim +9 -0
  169. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/current_engine.erb +0 -0
  170. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/current_engine.haml +1 -1
  171. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/current_engine.slim +0 -0
  172. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/fields_for.erb +0 -0
  173. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/fields_for.haml +0 -0
  174. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/fields_for.slim +15 -0
  175. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/form_for.erb +0 -0
  176. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/form_for.haml +0 -0
  177. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_for.slim +59 -0
  178. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/form_tag.erb +0 -0
  179. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/form_tag.haml +0 -0
  180. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/form_tag.slim +70 -0
  181. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/link_to.erb +0 -0
  182. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/link_to.haml +0 -0
  183. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/link_to.slim +4 -0
  184. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/mail_to.erb +0 -0
  185. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/mail_to.haml +0 -0
  186. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/mail_to.slim +3 -0
  187. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/meta_tag.erb +0 -0
  188. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/meta_tag.haml +0 -0
  189. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/meta_tag.slim +3 -0
  190. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/partials/_erb.erb +0 -0
  191. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/partials/_haml.haml +0 -0
  192. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/partials/_slim.slim +1 -0
  193. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/simple_partial.erb +0 -0
  194. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/markup_app/views/simple_partial.haml +0 -0
  195. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/markup_app/views/simple_partial.slim +1 -0
  196. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/app.rb +7 -0
  197. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/current_engine.haml +0 -0
  198. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/current_engines/_erb.erb +0 -0
  199. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/current_engines/_haml.haml +0 -0
  200. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/current_engines/_slim.slim +0 -0
  201. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_erb.erb +3 -0
  202. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_haml.haml +2 -0
  203. data/lib/vendored-middleman-deps/padrino-helpers-0.11.2/test/fixtures/render_app/views/double_capture_slim.slim +2 -0
  204. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/erb/test.erb +0 -0
  205. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/explicit_engine.haml +0 -0
  206. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/haml/test.haml +0 -0
  207. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/template/_user.haml +0 -0
  208. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/template/haml_template.haml +0 -0
  209. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/fixtures/render_app/views/template/some_template.haml +0 -0
  210. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/helper.rb +1 -0
  211. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_asset_tag_helpers.rb +24 -5
  212. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_form_builder.rb +41 -1
  213. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_form_helpers.rb +36 -0
  214. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_format_helpers.rb +14 -0
  215. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_locale.rb +0 -0
  216. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_number_helpers.rb +0 -0
  217. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_output_helpers.rb +5 -3
  218. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_render_helpers.rb +18 -0
  219. data/lib/vendored-middleman-deps/{padrino-helpers-0.10.7 → padrino-helpers-0.11.2}/test/test_tag_helpers.rb +11 -0
  220. data/middleman-core.gemspec +1 -1
  221. metadata +218 -184
  222. data/lib/vendored-middleman-deps/padrino-core-0.10.7/lib/padrino-core/cli/rake.rb +0 -25
  223. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/content_tag.slim +0 -9
  224. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/fields_for.slim +0 -15
  225. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_for.slim +0 -59
  226. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/form_tag.slim +0 -70
  227. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/link_to.slim +0 -4
  228. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/mail_to.slim +0 -3
  229. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/meta_tag.slim +0 -3
  230. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/partials/_slim.slim +0 -1
  231. data/lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/fixtures/markup_app/views/simple_partial.slim +0 -1
  232. data/spec/middleman-core/sitemap_spec.rb +0 -0
@@ -0,0 +1,56 @@
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
@@ -4,7 +4,6 @@ require 'i18n'
4
4
  require 'enumerator'
5
5
  require 'active_support/time_with_zone' # next extension depends on this
6
6
  require 'active_support/core_ext/string/conversions' # to_date
7
- require 'active_support/core_ext/float/rounding' # round
8
7
  require 'active_support/option_merger' # with_options
9
8
  require 'active_support/core_ext/object/with_options' # with_options
10
9
  require 'active_support/inflector' # humanize
@@ -32,6 +31,7 @@ module Padrino
32
31
  # Padrino::Helpers::FormatHelpers
33
32
  # Padrino::Helpers::RenderHelpers
34
33
  # Padrino::Helpers::NumberHelpers
34
+ # Padrino::Helpers::Breadcrumbs
35
35
  #
36
36
  # @param [Sinatra::Application] app
37
37
  # The specified padrino application
@@ -52,6 +52,7 @@ module Padrino
52
52
  app.helpers Padrino::Helpers::RenderHelpers
53
53
  app.helpers Padrino::Helpers::NumberHelpers
54
54
  app.helpers Padrino::Helpers::TranslationHelpers
55
+ app.helpers Padrino::Helpers::Breadcrumbs
55
56
  end
56
57
  alias :included :registered
57
58
  end
@@ -4,6 +4,10 @@ module Padrino
4
4
  # Helpers related to producing assets (images,stylesheets,js,etc) within templates.
5
5
  #
6
6
  module AssetTagHelpers
7
+ FRAGMENT_HASH = "#".html_safe.freeze
8
+ APPEND_ASSET_EXTENSIONS = ["js", "css"] # assets that require an appended extension
9
+ ABSOLUTE_URL_PATTERN = %r{^(https?://)} # absolute url regex
10
+
7
11
  ##
8
12
  # Creates a div to display the flash of given type if it exists
9
13
  #
@@ -11,6 +15,7 @@ module Padrino
11
15
  # The type of flash to display in the tag.
12
16
  # @param [Hash] options
13
17
  # The html options for this section.
18
+ # use :bootstrap => true to support Twitter's bootstrap dismiss alert button
14
19
  #
15
20
  # @return [String] Flash tag html with specified +options+.
16
21
  #
@@ -24,11 +29,13 @@ module Padrino
24
29
  # @api public
25
30
  def flash_tag(*args)
26
31
  options = args.extract_options!
27
- args.map do |kind|
32
+ bootstrap = options.delete(:bootstrap) if options[:bootstrap]
33
+ args.inject(''.html_safe) do |html,kind|
28
34
  flash_text = flash[kind]
29
- next if flash_text.blank?
30
- content_tag(:div, flash_text, options.reverse_merge(:class => kind))
31
- end.compact * "\n"
35
+ next html if flash_text.blank?
36
+ flash_text << safe_content_tag(:button, "&times;", {:type => :button, :class => :close, :'data-dismiss' => :alert}) if bootstrap
37
+ html << safe_content_tag(:div, flash_text, options.reverse_merge(:class => kind))
38
+ end
32
39
  end
33
40
 
34
41
  ##
@@ -45,6 +52,8 @@ module Padrino
45
52
  #
46
53
  # @option options [String] :anchor
47
54
  # The anchor for the link (i.e #something)
55
+ # @option options [String] :fragment
56
+ # Synonym for anchor
48
57
  # @option options [Boolean] :if
49
58
  # If true, the link will appear, otherwise not;
50
59
  # @option options [Boolean] :unless
@@ -70,66 +79,38 @@ module Padrino
70
79
  # @api public
71
80
  def link_to(*args, &block)
72
81
  options = args.extract_options!
73
- anchor = "##{CGI.escape options.delete(:anchor).to_s}" if options[:anchor]
82
+ fragment = options.delete(:anchor).to_s if options[:anchor]
83
+ fragment = options.delete(:fragment).to_s if options[:fragment]
74
84
 
85
+ url = ActiveSupport::SafeBuffer.new
75
86
  if block_given?
76
- url = args[0] ? args[0] + anchor.to_s : anchor || '#'
87
+ if args[0]
88
+ url.concat(args[0])
89
+ url.concat(FRAGMENT_HASH).concat(fragment) if fragment
90
+ else
91
+ url.concat(FRAGMENT_HASH)
92
+ url.concat(fragment) if fragment
93
+ end
77
94
  options.reverse_merge!(:href => url)
78
95
  link_content = capture_html(&block)
79
96
  return '' unless parse_conditions(url, options)
80
97
  result_link = content_tag(:a, link_content, options)
81
98
  block_is_template?(block) ? concat_content(result_link) : result_link
82
99
  else
83
- name, url = args[0], (args[1] ? args[1] + anchor.to_s : anchor || '#')
100
+ if args[1]
101
+ url.concat(args[1])
102
+ url.safe_concat(FRAGMENT_HASH).concat(fragment) if fragment
103
+ else
104
+ url = FRAGMENT_HASH
105
+ url.concat(fragment) if fragment
106
+ end
107
+ name = args[0]
84
108
  return name unless parse_conditions(url, options)
85
109
  options.reverse_merge!(:href => url)
86
110
  content_tag(:a, name, options)
87
111
  end
88
112
  end
89
113
 
90
- ##
91
- # Creates a form containing a single button that submits to the url.
92
- #
93
- # @overload button_to(name, url, options={})
94
- # @param [String] caption The text caption.
95
- # @param [String] url The url href.
96
- # @param [Hash] options The html options.
97
- # @overload button_to(name, options={}, &block)
98
- # @param [String] url The url href.
99
- # @param [Hash] options The html options.
100
- # @param [Proc] block The button content.
101
- #
102
- # @option options [Boolean] :multipart
103
- # If true, this form will support multipart encoding.
104
- # @option options [String] :remote
105
- # Instructs ujs handler to handle the submit as ajax.
106
- # @option options [Symbol] :method
107
- # Instructs ujs handler to use different http method (i.e :post, :delete).
108
- #
109
- # @return [String] Form and button html with specified +options+.
110
- #
111
- # @example
112
- # button_to 'Delete', url(:accounts_destroy, :id => account), :method => :delete, :class => :form
113
- # # Generates:
114
- # # <form class="form" action="/admin/accounts/destroy/2" method="post">
115
- # # <input type="hidden" value="delete" name="_method" />
116
- # # <input type="submit" value="Delete" />
117
- # # </form>
118
- #
119
- # @api public
120
- def button_to(*args, &block)
121
- name, url = args[0], args[1]
122
- options = args.extract_options!
123
- desired_method = options[:method]
124
- options.delete(:method) if options[:method].to_s !~ /get|post/i
125
- options.reverse_merge!(:method => 'post', :action => url)
126
- options[:enctype] = 'multipart/form-data' if options.delete(:multipart)
127
- options['data-remote'] = 'true' if options.delete(:remote)
128
- inner_form_html = hidden_form_method_field(desired_method)
129
- inner_form_html += block_given? ? capture_html(&block) : submit_tag(name)
130
- content_tag('form', inner_form_html, options)
131
- end
132
-
133
114
  ##
134
115
  # Creates a link tag that browsers and news readers can use to auto-detect an RSS or ATOM feed.
135
116
  #
@@ -185,7 +166,7 @@ module Padrino
185
166
  # @api public
186
167
  def mail_to(email, caption=nil, mail_options={})
187
168
  html_options = mail_options.slice!(:cc, :bcc, :subject, :body)
188
- mail_query = Rack::Utils.build_query(mail_options).gsub(/\+/, '%20').gsub('%40', '@')
169
+ mail_query = Rack::Utils.build_query(mail_options).gsub(/\+/, '%20').gsub('%40', '@').gsub('&', '&amp;')
189
170
  mail_href = "mailto:#{email}"; mail_href << "?#{mail_query}" if mail_query.present?
190
171
  link_to((caption || email), mail_href, html_options)
191
172
  end
@@ -275,7 +256,7 @@ module Padrino
275
256
  options.reverse_merge!(:media => 'screen', :rel => 'stylesheet', :type => 'text/css')
276
257
  sources.flatten.map { |source|
277
258
  tag(:link, options.reverse_merge(:href => asset_path(:css, source)))
278
- }.join("\n")
259
+ }.join("\n").html_safe
279
260
  end
280
261
 
281
262
  ##
@@ -298,7 +279,7 @@ module Padrino
298
279
  options.reverse_merge!(:type => 'text/javascript')
299
280
  sources.flatten.map { |source|
300
281
  content_tag(:script, nil, options.reverse_merge(:src => asset_path(:js, source)))
301
- }.join("\n")
282
+ }.join("\n").html_safe
302
283
  end
303
284
 
304
285
  ##
@@ -341,14 +322,11 @@ module Padrino
341
322
  #
342
323
  # @api semipublic
343
324
  def asset_path(kind, source)
344
- return source if source =~ /^http/
345
- is_absolute = source =~ %r{^/}
346
- asset_folder = asset_folder_name(kind)
347
- source = source.to_s.gsub(/\s/, '%20')
348
- ignore_extension = (asset_folder.to_s == kind.to_s) # don't append an extension
349
- source << ".#{kind}" unless ignore_extension or source =~ /\.#{kind}/
350
- result_path = is_absolute ? source : uri_root_path(asset_folder, source)
351
- timestamp = asset_timestamp(result_path, is_absolute)
325
+ source = asset_normalize_extension(kind, URI.escape(source.to_s))
326
+ return source if source =~ ABSOLUTE_URL_PATTERN || source =~ /^\// # absolute source
327
+ source = File.join(asset_folder_name(kind), source)
328
+ timestamp = asset_timestamp(source)
329
+ result_path = uri_root_path(source)
352
330
  "#{result_path}#{timestamp}"
353
331
  end
354
332
 
@@ -370,14 +348,15 @@ module Padrino
370
348
  #
371
349
  # @example
372
350
  # asset_timestamp("some/path/to/file.png") => "?154543678"
373
- # asset_timestamp("/some/absolute/path.png", true) => nil
374
351
  #
375
- def asset_timestamp(file_path, absolute=false)
352
+ def asset_timestamp(file_path)
376
353
  return nil if file_path =~ /\?/ || (self.class.respond_to?(:asset_stamp) && !self.class.asset_stamp)
377
- public_file_path = Padrino.root("public", file_path) if Padrino.respond_to?(:root)
354
+ public_path = self.class.public_folder if self.class.respond_to?(:public_folder)
355
+ public_path ||= Padrino.root("public") if Padrino.respond_to?(:root)
356
+ public_file_path = File.join(public_path, file_path) if public_path
378
357
  stamp = File.mtime(public_file_path).to_i if public_file_path && File.exist?(public_file_path)
379
- stamp ||= Time.now.to_i unless absolute
380
- "?#{stamp}" if stamp
358
+ stamp ||= Time.now.to_i
359
+ "?#{stamp}"
381
360
  end
382
361
 
383
362
  ###
@@ -396,6 +375,19 @@ module Padrino
396
375
  end
397
376
  end
398
377
 
378
+ # Normalizes the extension for a given asset
379
+ #
380
+ # @example
381
+ #
382
+ # asset_normalize_extension(:images, "/foo/bar/baz.png") => "/foo/bar/baz.png"
383
+ # asset_normalize_extension(:js, "/foo/bar/baz") => "/foo/bar/baz.js"
384
+ #
385
+ def asset_normalize_extension(kind, source)
386
+ ignore_extension = !APPEND_ASSET_EXTENSIONS.include?(kind.to_s)
387
+ source << ".#{kind}" unless ignore_extension || source =~ /\.#{kind}/ || source =~ ABSOLUTE_URL_PATTERN
388
+ source
389
+ end
390
+
399
391
  ##
400
392
  # Parses link_to options for given correct conditions
401
393
  #
@@ -0,0 +1,171 @@
1
+ module Padrino
2
+ module Helpers
3
+ class Breadcrumb
4
+
5
+ attr_accessor :home
6
+ attr_accessor :items
7
+
8
+ DEFAULT_URL = "/"
9
+ DEFAULT_CAPTION ="Home Page"
10
+
11
+ ##
12
+ # initialize breadcrumbs with default value
13
+ #
14
+ # @example
15
+ # before do
16
+ # @breadcrumbs = breadcrumbs.new
17
+ # end
18
+ #
19
+ # @api public
20
+ def initialize
21
+ self.home = { :url => DEFAULT_URL, :caption => DEFAULT_CAPTION, :name => :home }
22
+ reset
23
+ end
24
+
25
+ ##
26
+ # Set the custom home (Parent) link
27
+ #
28
+ # @param [String] url
29
+ # The url href
30
+ #
31
+ # @param [String] caption
32
+ # The text caption.
33
+ #
34
+ # @example
35
+ # breadcrumbs.set_home "/HomeFoo", "Foo Home"
36
+ #
37
+ #
38
+ # @api public
39
+ def set_home(url, caption)
40
+ self.home = { :url => url, :caption => caption.to_s.humanize.html_safe, :name => :home }
41
+ reset
42
+ end
43
+
44
+ ##
45
+ # Reset breadcrumbs to default or personal home
46
+ #
47
+ # @example
48
+ # breadcrumbs.reset
49
+ #
50
+ # @api public
51
+ def reset
52
+ self.items=[]
53
+ self.items << home
54
+ end
55
+
56
+ ##
57
+ # Reset breadcrumbs to default home
58
+ #
59
+ # @example
60
+ # breadcrumbs.reset!
61
+ #
62
+ # @api public
63
+ def reset!
64
+ self.home = { :url => DEFAULT_URL, :caption => DEFAULT_CAPTION, :name => :home }
65
+ reset
66
+ end
67
+
68
+ ##
69
+ # Add a new breadcrumbs
70
+ #
71
+ # @param [String] name
72
+ # The name of resource
73
+ # @param [Symbol] name
74
+ # The name of resource
75
+ #
76
+ # @param [String] url
77
+ # The url href.
78
+ #
79
+ # @param [String] caption
80
+ # The text caption
81
+ #
82
+ # @example
83
+ # breadcrumbs.add "foo", "/foo", "Foo Link"
84
+ # breadcrumbs.add :foo, "/foo", "Foo Link"
85
+ #
86
+ # @api public
87
+ def add(name, url, caption)
88
+ items << { :name => name, :url => url.to_s, :caption => caption.to_s.humanize.html_safe }
89
+ end
90
+
91
+ alias :<< :add
92
+
93
+ ##
94
+ # Remove a Breadcrumbs
95
+ #
96
+ # @param [String] name
97
+ # The name of resource to delete from breadcrumbs list
98
+ #
99
+ # @param [Symbol] name
100
+ # The name of resource to delete from breadcrumbs list
101
+ #
102
+ # @example
103
+ # breadcrumbs.del "foo"
104
+ # breadcrumbs.del :foo
105
+ #
106
+ # @api public
107
+ def del(name)
108
+ items.delete_if { |item| item[:name] == name.to_sym }
109
+ end
110
+
111
+ end # Breadcrumb
112
+
113
+
114
+ module Breadcrumbs
115
+
116
+ # Render breadcrumbs to view
117
+ #
118
+ # @param [Breadcrumbs] breadcrumbs
119
+ # The breadcrumbs to render into view
120
+ #
121
+ # @param [Boolean] bootstrap
122
+ # If true, render separation (usefull with Twitter Bootstrap)
123
+ #
124
+ # @param [String] active
125
+ # Css class style set to active breadcrumb
126
+ #
127
+ # @return [String] Unordered list with breadcrumbs
128
+ #
129
+ # @example
130
+ # = breadcrumbs @breacrumbs
131
+ # # Generates:
132
+ # # <ul>
133
+ # # <li><a herf="/foo" >Foo Link</a></li>
134
+ # # <li class="active" ><a herf="/bar">Bar Link</a></li>
135
+ # # </ul>
136
+ #
137
+ #
138
+ # @api public
139
+ def breadcrumbs(breadcrumbs, bootstrap=false, active="active")
140
+ content=""
141
+ breadcrumbs.items[0..-2].each do |item|
142
+ content << render_item(item, bootstrap)
143
+ end
144
+ last = link_to(breadcrumbs.items.last[:caption], breadcrumbs.items.last[:url])
145
+ content << safe_content_tag(:li, last, :class => active)
146
+ safe_content_tag(:ul, content, :class => "breadcrumb" )
147
+ end
148
+
149
+ private
150
+ ##
151
+ # Private method to return list item
152
+ #
153
+ # @param [Hash] item
154
+ # The breadcrumb item
155
+ #
156
+ # @param [Boolean] bootstrap
157
+ # If true, render separation (usefull with Twitter Bootstrap)
158
+ #
159
+ # @return [String] List item with breacrumb
160
+ #
161
+ # @api public
162
+ def render_item(item, bootstrap)
163
+ content = ""
164
+ content << link_to(item[:caption], item[:url])
165
+ content << safe_content_tag(:span, "/", :class => "divider") if bootstrap
166
+ safe_content_tag(:li, content )
167
+ end
168
+
169
+ end # Breadcrumb
170
+ end # Helpers
171
+ end # Padrino