middleman 2.0.7 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG +8 -0
  4. data/Gemfile +1 -1
  5. data/features/data.feature +6 -1
  6. data/features/markdown.feature +7 -0
  7. data/features/sprockets.feature +11 -1
  8. data/features/sprockets_gems.feature +3 -3
  9. data/fixtures/sprockets-app/source/jquery_include.js +1 -0
  10. data/fixtures/test-app/config.rb +2 -0
  11. data/fixtures/test-app/source/data2.html.liquid +1 -0
  12. data/fixtures/test-app/source/javascripts/multiple_engines.js.coffee.erb +1 -0
  13. data/fixtures/test-app/source/markdown.html.markdown +1 -0
  14. data/lib/middleman.rb +0 -6
  15. data/lib/middleman/base.rb +6 -1
  16. data/lib/middleman/builder.rb +6 -4
  17. data/lib/middleman/core_extensions/data.rb +35 -5
  18. data/lib/middleman/core_extensions/front_matter.rb +9 -2
  19. data/lib/middleman/core_extensions/sprockets.rb +25 -1
  20. data/lib/middleman/renderers/markdown.rb +25 -2
  21. data/lib/middleman/version.rb +1 -1
  22. data/middleman.gemspec +7 -6
  23. metadata +112 -251
  24. data/lib/middleman/vendor/padrino-core-0.10.0/.document +0 -5
  25. data/lib/middleman/vendor/padrino-core-0.10.0/.gitignore +0 -22
  26. data/lib/middleman/vendor/padrino-core-0.10.0/LICENSE +0 -20
  27. data/lib/middleman/vendor/padrino-core-0.10.0/README.rdoc +0 -294
  28. data/lib/middleman/vendor/padrino-core-0.10.0/Rakefile +0 -5
  29. data/lib/middleman/vendor/padrino-core-0.10.0/bin/padrino +0 -9
  30. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core.rb +0 -119
  31. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/application.rb +0 -259
  32. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/application/rendering.rb +0 -228
  33. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/application/routing.rb +0 -821
  34. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/application/showexceptions.rb +0 -18
  35. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/caller.rb +0 -45
  36. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/cli/adapter.rb +0 -24
  37. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/cli/base.rb +0 -152
  38. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/cli/console.rb +0 -20
  39. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/cli/rake.rb +0 -24
  40. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/cli/rake_tasks.rb +0 -59
  41. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/command.rb +0 -27
  42. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/images/404.png +0 -0
  43. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/images/500.png +0 -0
  44. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/loader.rb +0 -182
  45. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/cz.yml +0 -30
  46. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/da.yml +0 -30
  47. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/de.yml +0 -30
  48. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/en.yml +0 -30
  49. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/es.yml +0 -30
  50. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/fr.yml +0 -30
  51. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/hu.yml +0 -30
  52. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/it.yml +0 -37
  53. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/ja.yml +0 -30
  54. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/nl.yml +0 -30
  55. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/no.yml +0 -31
  56. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/pl.yml +0 -30
  57. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/pt_br.yml +0 -37
  58. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/ru.yml +0 -30
  59. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/tr.yml +0 -30
  60. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/uk.yml +0 -30
  61. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/zh_cn.yml +0 -30
  62. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/locale/zh_tw.yml +0 -30
  63. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/logger.rb +0 -344
  64. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/mounter.rb +0 -192
  65. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/reloader.rb +0 -247
  66. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/router.rb +0 -79
  67. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/server.rb +0 -70
  68. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/support_lite.rb +0 -135
  69. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/tasks.rb +0 -23
  70. data/lib/middleman/vendor/padrino-core-0.10.0/lib/padrino-core/version.rb +0 -15
  71. data/lib/middleman/vendor/padrino-core-0.10.0/padrino-core.gemspec +0 -38
  72. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/apps/.components +0 -6
  73. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/apps/.gitignore +0 -7
  74. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/apps/complex.rb +0 -27
  75. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/apps/simple.rb +0 -33
  76. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/dependencies/a.rb +0 -9
  77. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/dependencies/b.rb +0 -4
  78. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/dependencies/c.rb +0 -1
  79. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/dependencies/circular/e.rb +0 -13
  80. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/dependencies/circular/f.rb +0 -2
  81. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/dependencies/circular/g.rb +0 -2
  82. data/lib/middleman/vendor/padrino-core-0.10.0/test/fixtures/dependencies/d.rb +0 -4
  83. data/lib/middleman/vendor/padrino-core-0.10.0/test/helper.rb +0 -101
  84. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_application.rb +0 -83
  85. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_core.rb +0 -79
  86. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_dependencies.rb +0 -44
  87. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_filters.rb +0 -266
  88. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_logger.rb +0 -91
  89. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_mounter.rb +0 -176
  90. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_reloader_complex.rb +0 -66
  91. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_reloader_simple.rb +0 -97
  92. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_rendering.rb +0 -437
  93. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_router.rb +0 -146
  94. data/lib/middleman/vendor/padrino-core-0.10.0/test/test_routing.rb +0 -1491
  95. data/lib/middleman/vendor/padrino-helpers-0.10.0/.document +0 -5
  96. data/lib/middleman/vendor/padrino-helpers-0.10.0/.gitignore +0 -21
  97. data/lib/middleman/vendor/padrino-helpers-0.10.0/LICENSE +0 -20
  98. data/lib/middleman/vendor/padrino-helpers-0.10.0/README.rdoc +0 -239
  99. data/lib/middleman/vendor/padrino-helpers-0.10.0/Rakefile +0 -5
  100. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers.rb +0 -51
  101. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/asset_tag_helpers.rb +0 -288
  102. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/form_builder/abstract_form_builder.rb +0 -220
  103. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/form_builder/standard_form_builder.rb +0 -43
  104. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/form_helpers.rb +0 -446
  105. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/format_helpers.rb +0 -260
  106. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/cz.yml +0 -103
  107. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/da.yml +0 -91
  108. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/de.yml +0 -78
  109. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/en.yml +0 -103
  110. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/es.yml +0 -103
  111. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/fr.yml +0 -79
  112. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/hu.yml +0 -103
  113. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/it.yml +0 -85
  114. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/ja.yml +0 -103
  115. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/nl.yml +0 -78
  116. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/no.yml +0 -91
  117. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/pl.yml +0 -95
  118. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/pt_br.yml +0 -103
  119. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/ru.yml +0 -103
  120. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/tr.yml +0 -103
  121. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/uk.yml +0 -103
  122. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/zh_cn.yml +0 -103
  123. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/locale/zh_tw.yml +0 -103
  124. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/number_helpers.rb +0 -273
  125. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers.rb +0 -128
  126. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/abstract_handler.rb +0 -103
  127. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/erb_handler.rb +0 -79
  128. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/haml_handler.rb +0 -64
  129. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/output_helpers/slim_handler.rb +0 -82
  130. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/render_helpers.rb +0 -40
  131. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/tag_helpers.rb +0 -59
  132. data/lib/middleman/vendor/padrino-helpers-0.10.0/lib/padrino-helpers/translation_helpers.rb +0 -21
  133. data/lib/middleman/vendor/padrino-helpers-0.10.0/padrino-helpers.gemspec +0 -27
  134. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/app.rb +0 -73
  135. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.erb +0 -14
  136. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.haml +0 -12
  137. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/capture_concat.slim +0 -13
  138. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.erb +0 -11
  139. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.haml +0 -9
  140. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_for.slim +0 -9
  141. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.erb +0 -11
  142. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.haml +0 -9
  143. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/content_tag.slim +0 -9
  144. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.erb +0 -5
  145. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.haml +0 -5
  146. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/current_engine.slim +0 -5
  147. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.erb +0 -20
  148. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.haml +0 -15
  149. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/fields_for.slim +0 -15
  150. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.erb +0 -56
  151. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.haml +0 -47
  152. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_for.slim +0 -47
  153. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.erb +0 -56
  154. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.haml +0 -45
  155. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/form_tag.slim +0 -45
  156. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.erb +0 -5
  157. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.haml +0 -4
  158. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/link_to.slim +0 -4
  159. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.erb +0 -3
  160. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.haml +0 -3
  161. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/mail_to.slim +0 -3
  162. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.erb +0 -3
  163. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.haml +0 -3
  164. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/meta_tag.slim +0 -3
  165. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_erb.erb +0 -1
  166. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_haml.haml +0 -1
  167. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/partials/_slim.slim +0 -1
  168. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.erb +0 -1
  169. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.haml +0 -1
  170. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/markup_app/views/simple_partial.slim +0 -1
  171. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/app.rb +0 -45
  172. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engine.haml +0 -5
  173. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_erb.erb +0 -1
  174. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_haml.haml +0 -1
  175. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/current_engines/_slim.slim +0 -1
  176. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/erb/test.erb +0 -1
  177. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/explicit_engine.haml +0 -5
  178. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/haml/test.haml +0 -1
  179. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/_user.haml +0 -7
  180. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/haml_template.haml +0 -1
  181. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/fixtures/render_app/views/template/some_template.haml +0 -2
  182. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/helper.rb +0 -78
  183. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_asset_tag_helpers.rb +0 -320
  184. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_form_builder.rb +0 -998
  185. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_form_helpers.rb +0 -645
  186. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_format_helpers.rb +0 -227
  187. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_number_helpers.rb +0 -136
  188. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_output_helpers.rb +0 -133
  189. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_render_helpers.rb +0 -69
  190. data/lib/middleman/vendor/padrino-helpers-0.10.0/test/test_tag_helpers.rb +0 -100
@@ -1,260 +0,0 @@
1
- module Padrino
2
- module Helpers
3
- module FormatHelpers
4
- ##
5
- # Returns escaped text to protect against malicious content
6
- #
7
- def escape_html(text)
8
- Rack::Utils.escape_html(text)
9
- end
10
- alias h escape_html
11
- alias sanitize_html escape_html
12
-
13
- ##
14
- # Returns escaped text to protect against malicious content
15
- # Returns blank if the text is empty
16
- #
17
- def h!(text, blank_text = ' ')
18
- return blank_text if text.nil? || text.empty?
19
- h text
20
- end
21
-
22
- ##
23
- # Strips all HTML tags from the html
24
- #
25
- def strip_tags(html)
26
- html.gsub(/<\/?[^>]*>/, "") if html
27
- end
28
-
29
- ##
30
- # Returns text transformed into HTML using simple formatting rules. Two or more consecutive newlines(\n\n) are considered
31
- # as a paragraph and wrapped in <p> or your own tags. One newline (\n) is considered as a linebreak and a <br /> tag is appended.
32
- # This method does not remove the newlines from the text.
33
- #
34
- # ==== Examples
35
- #
36
- # simple_format("hello\nworld") # => "<p>hello<br/>world</p>"
37
- # simple_format("hello\nworld", :tag => :div, :class => :foo) # => "<div class="foo">hello<br/>world</div>"
38
- #
39
- def simple_format(text, options={})
40
- t = options.delete(:tag) || :p
41
- start_tag = tag(t, options.merge(:open => true))
42
- text = text.to_s.dup
43
- text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
44
- text.gsub!(/\n\n+/, "</#{t}>\n\n#{start_tag}") # 2+ newline -> paragraph
45
- text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
46
- text.insert 0, start_tag
47
- text << "</#{t}>"
48
- end
49
-
50
- ##
51
- # Attempts to pluralize the singular word unless count is 1. If plural is supplied, it will use that when count is > 1,
52
- # otherwise it will use the Inflector to determine the plural form
53
- #
54
- # ==== Examples
55
- #
56
- # pluralize(2, 'person') => '2 people'
57
- #
58
- def pluralize(count, singular, plural = nil)
59
- "#{count || 0} " + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))
60
- end
61
-
62
- ##
63
- # Truncates a given text after a given :length if text is longer than :length (defaults to 30).
64
- # The last characters will be replaced with the :omission (defaults to "…") for a total length not exceeding :length.
65
- #
66
- # ==== Examples
67
- #
68
- # truncate("Once upon a time in a world far far away", :length => 8) => "Once upon..."
69
- #
70
- def truncate(text, options={})
71
- options.reverse_merge!(:length => 30, :omission => "...")
72
- if text
73
- len = options[:length] - options[:omission].length
74
- chars = text
75
- (chars.length > options[:length] ? chars[0...len] + options[:omission] : text).to_s
76
- end
77
- end
78
-
79
- ##
80
- # Truncates words of a given text after a given :length if number of words in text is more than :length (defaults to 30).
81
- # The last words will be replaced with the :omission (defaults to "…") for a total number of words not exceeding :length.
82
- #
83
- # ==== Examples
84
- #
85
- # truncate_words("Once upon a time in a world far far away", :length => 8) => "Once upon a time in a world far..."
86
- #
87
- def truncate_words(text, options={})
88
- options.reverse_merge!(:length => 30, :omission => "...")
89
- if text
90
- words = text.split()
91
- words[0..(options[:length]-1)].join(' ') + (words.length > options[:length] ? options[:omission] : '')
92
- end
93
- end
94
-
95
- ##
96
- # Wraps the text into lines no longer than line_width width.
97
- # This method breaks on the first whitespace character that does not exceed line_width (which is 80 by default).
98
- #
99
- # ==== Examples
100
- #
101
- # word_wrap('Once upon a time', :line_width => 8) => "Once upon\na time"
102
- #
103
- def word_wrap(text, *args)
104
- options = args.extract_options!
105
- unless args.blank?
106
- options[:line_width] = args[0] || 80
107
- end
108
- options.reverse_merge!(:line_width => 80)
109
-
110
- text.split("\n").map do |line|
111
- line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\s+|$)/, "\\1\n").strip : line
112
- end * "\n"
113
- end
114
-
115
- ##
116
- # Highlights one or more words everywhere in text by inserting it into a :highlighter string.
117
- #
118
- # The highlighter can be customized by passing :+highlighter+ as a single-quoted string
119
- # with \1 where the phrase is to be inserted (defaults to ’<strong class="highlight">\1</strong>’)
120
- #
121
- # ==== Examples
122
- #
123
- # # => Lorem ipsum <strong class="highlight">dolor</strong> sit amet
124
- # highlight('Lorem ipsum dolor sit amet', 'dolor')
125
- #
126
- # # => Lorem ipsum <span class="custom">dolor</span> sit amet
127
- # highlight('Lorem ipsum dolor sit amet', 'dolor', :highlighter => '<span class="custom">\1</span>')
128
- #
129
- def highlight(text, words, *args)
130
- options = args.extract_options!
131
- options.reverse_merge!(:highlighter => '<strong class="highlight">\1</strong>')
132
-
133
- if text.blank? || words.blank?
134
- text
135
- else
136
- match = Array(words).map { |p| Regexp.escape(p) }.join('|')
137
- text.gsub(/(#{match})(?!(?:[^<]*?)(?:["'])[^<>]*>)/i, options[:highlighter])
138
- end
139
- end
140
-
141
- ##
142
- # Reports the approximate distance in time between two Time or Date objects or integers as seconds.
143
- # Set <tt>include_seconds</tt> to true if you want more detailed approximations when distance < 1 min, 29 secs
144
- # Distances are reported based on the following table:
145
- #
146
- # 0 <-> 29 secs # => less than a minute
147
- # 30 secs <-> 1 min, 29 secs # => 1 minute
148
- # 1 min, 30 secs <-> 44 mins, 29 secs # => [2..44] minutes
149
- # 44 mins, 30 secs <-> 89 mins, 29 secs # => about 1 hour
150
- # 89 mins, 29 secs <-> 23 hrs, 59 mins, 29 secs # => about [2..24] hours
151
- # 23 hrs, 59 mins, 29 secs <-> 47 hrs, 59 mins, 29 secs # => 1 day
152
- # 47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days
153
- # 29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month
154
- # 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] months
155
- # 1 yr <-> 1 yr, 3 months # => about 1 year
156
- # 1 yr, 3 months <-> 1 yr, 9 months # => over 1 year
157
- # 1 yr, 9 months <-> 2 yr minus 1 sec # => almost 2 years
158
- # 2 yrs <-> max time or date # => (same rules as 1 yr)
159
- #
160
- # With <tt>include_seconds</tt> = true and the difference < 1 minute 29 seconds:
161
- # 0-4 secs # => less than 5 seconds
162
- # 5-9 secs # => less than 10 seconds
163
- # 10-19 secs # => less than 20 seconds
164
- # 20-39 secs # => half a minute
165
- # 40-59 secs # => less than a minute
166
- # 60-89 secs # => 1 minute
167
- #
168
- # ==== Examples
169
- #
170
- # from_time = Time.now
171
- # distance_of_time_in_words(from_time, from_time + 50.minutes) # => about 1 hour
172
- # distance_of_time_in_words(from_time, 50.minutes.from_now) # => about 1 hour
173
- # distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute
174
- # distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 seconds
175
- # distance_of_time_in_words(from_time, 3.years.from_now) # => about 3 years
176
- # distance_of_time_in_words(from_time, from_time + 60.hours) # => about 3 days
177
- # distance_of_time_in_words(from_time, from_time + 45.seconds, true) # => less than a minute
178
- # distance_of_time_in_words(from_time, from_time - 45.seconds, true) # => less than a minute
179
- # distance_of_time_in_words(from_time, 76.seconds.from_now) # => 1 minute
180
- # distance_of_time_in_words(from_time, from_time + 1.year + 3.days) # => about 1 year
181
- # distance_of_time_in_words(from_time, from_time + 3.years + 6.months) # => over 3 years
182
- # distance_of_time_in_words(from_time, from_time + 4.years + 9.days + 30.minutes + 5.seconds) # => about 4 years
183
- #
184
- # to_time = Time.now + 6.years + 19.days
185
- # distance_of_time_in_words(from_time, to_time, true) # => about 6 years
186
- # distance_of_time_in_words(to_time, from_time, true) # => about 6 years
187
- # distance_of_time_in_words(Time.now, Time.now) # => less than a minute
188
- #
189
- def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
190
- from_time = from_time.to_time if from_time.respond_to?(:to_time)
191
- to_time = to_time.to_time if to_time.respond_to?(:to_time)
192
- distance_in_minutes = (((to_time.to_i - from_time.to_i).abs)/60).round
193
- distance_in_seconds = ((to_time.to_i - from_time.to_i).abs).round
194
-
195
- I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
196
- case distance_in_minutes
197
- when 0..1
198
- return distance_in_minutes == 0 ?
199
- locale.t(:less_than_x_minutes, :count => 1) :
200
- locale.t(:x_minutes, :count => distance_in_minutes) unless include_seconds
201
-
202
- case distance_in_seconds
203
- when 0..4 then locale.t :less_than_x_seconds, :count => 5
204
- when 5..9 then locale.t :less_than_x_seconds, :count => 10
205
- when 10..19 then locale.t :less_than_x_seconds, :count => 20
206
- when 20..39 then locale.t :half_a_minute
207
- when 40..59 then locale.t :less_than_x_minutes, :count => 1
208
- else locale.t :x_minutes, :count => 1
209
- end
210
-
211
- when 2..44 then locale.t :x_minutes, :count => distance_in_minutes
212
- when 45..89 then locale.t :about_x_hours, :count => 1
213
- when 90..1439 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round
214
- when 1440..2529 then locale.t :x_days, :count => 1
215
- when 2530..43199 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round
216
- when 43200..86399 then locale.t :about_x_months, :count => 1
217
- when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round
218
- else
219
- distance_in_years = distance_in_minutes / 525600
220
- minute_offset_for_leap_year = (distance_in_years / 4) * 1440
221
- remainder = ((distance_in_minutes - minute_offset_for_leap_year) % 525600)
222
- if remainder < 131400
223
- locale.t(:about_x_years, :count => distance_in_years)
224
- elsif remainder < 394200
225
- locale.t(:over_x_years, :count => distance_in_years)
226
- else
227
- locale.t(:almost_x_years, :count => distance_in_years + 1)
228
- end
229
- end
230
- end
231
- end
232
-
233
- ##
234
- # Like distance_of_time_in_words, but where <tt>to_time</tt> is fixed to <tt>Time.now</tt>.
235
- #
236
- # ==== Examples
237
- #
238
- # time_ago_in_words(3.minutes.from_now) # => 3 minutes
239
- # time_ago_in_words(Time.now - 15.hours) # => 15 hours
240
- # time_ago_in_words(Time.now) # => less than a minute
241
- #
242
- # from_time = Time.now - 3.days - 14.minutes - 25.seconds # => 3 days
243
- #
244
- def time_ago_in_words(from_time, include_seconds = false)
245
- distance_of_time_in_words(from_time, Time.now, include_seconds)
246
- end
247
-
248
- ##
249
- # Used in xxxx.js.erb files to escape html so that it can be passed to javascript from Padrino
250
- #
251
- # js_escape_html("<h1>Hey</h1>")
252
- #
253
- def js_escape_html(html_content)
254
- return '' unless html_content
255
- javascript_mapping = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" }
256
- html_content.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { javascript_mapping[$1] }
257
- end
258
- end # FormatHelpers
259
- end # Helpers
260
- end # Padrino
@@ -1,103 +0,0 @@
1
- cz:
2
- number:
3
- # Used in number_with_delimiter()
4
- # These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
5
- format:
6
- # Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
7
- separator: ","
8
- # Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
9
- delimiter: " "
10
- # Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
11
- precision: 3
12
-
13
- # Used in number_to_currency()
14
- currency:
15
- format:
16
- # Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
17
- format: "%n %u"
18
- unit: "Kč"
19
- # These three are to override number.format and are optional
20
- # separator: ","
21
- # delimiter: " "
22
- precision: 2
23
-
24
- # Used in number_to_percentage()
25
- percentage:
26
- format:
27
- # These three are to override number.format and are optional
28
- # separator:
29
- delimiter: ""
30
- # precision:
31
-
32
- # Used in number_to_precision()
33
- precision:
34
- format:
35
- # These three are to override number.format and are optional
36
- # separator:
37
- delimiter: ""
38
- # precision:
39
-
40
- # Used in number_to_human_size()
41
- human:
42
- format:
43
- # These three are to override number.format and are optional
44
- # separator:
45
- delimiter: ""
46
- precision: 1
47
- storage_units:
48
- # Storage units output formatting.
49
- # %u is the storage unit, %n is the number (default: 2 MB)
50
- format: "%n %u"
51
- units:
52
- byte:
53
- one: "Byte"
54
- other: "Bytes"
55
- kb: "KB"
56
- mb: "MB"
57
- gb: "GB"
58
- tb: "TB"
59
-
60
- # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
61
- datetime:
62
- distance_in_words:
63
- half_a_minute: "půl minutou"
64
- less_than_x_seconds:
65
- one: "asi před sekundou"
66
- other: "asi před %{count} sekundami"
67
- x_seconds:
68
- one: "sekundou"
69
- other: "%{count} sekundami"
70
- less_than_x_minutes:
71
- one: "před necelou minutou"
72
- other: "před ani ne %{count} minutami"
73
- x_minutes:
74
- one: "minutou"
75
- other: "%{count} minutami"
76
- about_x_hours:
77
- one: "asi hodinou"
78
- other: "asi %{count} hodinami"
79
- x_days:
80
- one: "24 hodinami"
81
- other: "%{count} dny"
82
- about_x_months:
83
- one: "asi měsícem"
84
- other: "asi %{count} měsíci"
85
- x_months:
86
- one: "měsícem"
87
- other: "%{count} měsíci"
88
- about_x_years:
89
- one: "asi rokem"
90
- other: "asi %{count} roky"
91
- over_x_years:
92
- one: "více než před rokem"
93
- other: "více než %{count} roky"
94
- almost_x_years:
95
- one: "skoro rokem"
96
- other: "almost %{count} roků"
97
- models:
98
- errors:
99
- template:
100
- header:
101
- one: "Při ukládání %{model} došlo k chybě a nebylo jej možné uložit"
102
- other: "Při ukládání %{model} došlo ke %{count} chybám a nebylo možné jej uložit"
103
- body: "Následující pole obsahují chybně vyplněné údaje:"
@@ -1,91 +0,0 @@
1
- da:
2
- number:
3
- format:
4
- separator: ","
5
- delimiter: "."
6
- precision: 3
7
- currency:
8
- format:
9
- format: "%u %n"
10
- unit: "DKK"
11
- separator: ","
12
- delimiter: "."
13
- precision: 2
14
- precision:
15
- format:
16
- # separator:
17
- delimiter: ""
18
- # precision:
19
- human:
20
- format:
21
- # separator:
22
- delimiter: ""
23
- precision: 1
24
- storage_units:
25
- # Storage units output formatting.
26
- # %u is the storage unit, %n is the number (default: 2 MB)
27
- format: "%n %u"
28
- units:
29
- byte:
30
- one: "Byte"
31
- other: "Bytes"
32
- kb: "KB"
33
- mb: "MB"
34
- gb: "GB"
35
- tb: "TB"
36
- percentage:
37
- format:
38
- # separator:
39
- delimiter: ""
40
- # precision:
41
-
42
- datetime:
43
- distance_in_words:
44
- half_a_minute: "et halvt minut"
45
- less_than_x_seconds:
46
- one: "mindre end et sekund"
47
- other: "mindre end %{count} sekunder"
48
- x_seconds:
49
- one: "et sekund"
50
- other: "%{count} sekunder"
51
- less_than_x_minutes:
52
- one: "mindre end et minut"
53
- other: "mindre end %{count} minutter"
54
- x_minutes:
55
- one: "et minut"
56
- other: "%{count} minutter"
57
- about_x_hours:
58
- one: "cirka en time"
59
- other: "cirka %{count} timer"
60
- x_days:
61
- one: "en dag"
62
- other: "%{count} dage"
63
- about_x_months:
64
- one: "cirka en måned"
65
- other: "cirka %{count} måneder"
66
- x_months:
67
- one: "en måned"
68
- other: "%{count} måneder"
69
- about_x_years:
70
- one: "cirka et år"
71
- other: "cirka %{count} år"
72
- over_x_years:
73
- one: "mere end et år"
74
- other: "mere end %{count} år"
75
- almost_x_years:
76
- one: "næsten et år"
77
- other: "næsten %{count} years"
78
- prompts:
79
- second: "Sekund"
80
- minute: "Minut"
81
- hour: "Time"
82
- day: "Dag"
83
- month: "Måned"
84
- year: "År"
85
- models:
86
- errors:
87
- template:
88
- header:
89
- one: "En fejl forhindrede %{model} i at blive gemt"
90
- other: "%{count} fejl forhindrede denne %{model} i at blive gemt"
91
- body: "Der var problemer med følgende felter:"