nanoc3 3.2.4 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. metadata +14 -313
  2. data/.gemtest +0 -0
  3. data/ChangeLog +0 -3
  4. data/Gemfile +0 -29
  5. data/LICENSE +0 -19
  6. data/NEWS.md +0 -449
  7. data/README.md +0 -108
  8. data/Rakefile +0 -14
  9. data/bin/nanoc3 +0 -12
  10. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  11. data/lib/nanoc3.rb +0 -28
  12. data/lib/nanoc3/base.rb +0 -49
  13. data/lib/nanoc3/base/compilation/checksum_store.rb +0 -57
  14. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +0 -62
  15. data/lib/nanoc3/base/compilation/compiler.rb +0 -455
  16. data/lib/nanoc3/base/compilation/compiler_dsl.rb +0 -214
  17. data/lib/nanoc3/base/compilation/dependency_tracker.rb +0 -196
  18. data/lib/nanoc3/base/compilation/filter.rb +0 -165
  19. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +0 -102
  20. data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +0 -88
  21. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +0 -223
  22. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +0 -46
  23. data/lib/nanoc3/base/compilation/rule.rb +0 -73
  24. data/lib/nanoc3/base/compilation/rule_context.rb +0 -84
  25. data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -40
  26. data/lib/nanoc3/base/compilation/rule_memory_store.rb +0 -53
  27. data/lib/nanoc3/base/compilation/rules_collection.rb +0 -231
  28. data/lib/nanoc3/base/context.rb +0 -47
  29. data/lib/nanoc3/base/core_ext.rb +0 -6
  30. data/lib/nanoc3/base/core_ext/array.rb +0 -62
  31. data/lib/nanoc3/base/core_ext/hash.rb +0 -63
  32. data/lib/nanoc3/base/core_ext/pathname.rb +0 -26
  33. data/lib/nanoc3/base/core_ext/string.rb +0 -46
  34. data/lib/nanoc3/base/directed_graph.rb +0 -275
  35. data/lib/nanoc3/base/errors.rb +0 -174
  36. data/lib/nanoc3/base/memoization.rb +0 -67
  37. data/lib/nanoc3/base/notification_center.rb +0 -84
  38. data/lib/nanoc3/base/ordered_hash.rb +0 -200
  39. data/lib/nanoc3/base/plugin_registry.rb +0 -165
  40. data/lib/nanoc3/base/result_data/item_rep.rb +0 -488
  41. data/lib/nanoc3/base/source_data/code_snippet.rb +0 -58
  42. data/lib/nanoc3/base/source_data/configuration.rb +0 -24
  43. data/lib/nanoc3/base/source_data/data_source.rb +0 -234
  44. data/lib/nanoc3/base/source_data/item.rb +0 -301
  45. data/lib/nanoc3/base/source_data/layout.rb +0 -130
  46. data/lib/nanoc3/base/source_data/site.rb +0 -361
  47. data/lib/nanoc3/base/store.rb +0 -135
  48. data/lib/nanoc3/cli.rb +0 -133
  49. data/lib/nanoc3/cli/command.rb +0 -139
  50. data/lib/nanoc3/cli/commands/autocompile.rb +0 -60
  51. data/lib/nanoc3/cli/commands/compile.rb +0 -280
  52. data/lib/nanoc3/cli/commands/create_item.rb +0 -62
  53. data/lib/nanoc3/cli/commands/create_layout.rb +0 -75
  54. data/lib/nanoc3/cli/commands/create_site.rb +0 -410
  55. data/lib/nanoc3/cli/commands/debug.rb +0 -119
  56. data/lib/nanoc3/cli/commands/info.rb +0 -98
  57. data/lib/nanoc3/cli/commands/nanoc.rb +0 -37
  58. data/lib/nanoc3/cli/commands/update.rb +0 -72
  59. data/lib/nanoc3/cli/commands/view.rb +0 -84
  60. data/lib/nanoc3/cli/commands/watch.rb +0 -125
  61. data/lib/nanoc3/cli/error_handler.rb +0 -193
  62. data/lib/nanoc3/cli/logger.rb +0 -91
  63. data/lib/nanoc3/data_sources.rb +0 -29
  64. data/lib/nanoc3/data_sources/deprecated/delicious.rb +0 -42
  65. data/lib/nanoc3/data_sources/deprecated/last_fm.rb +0 -87
  66. data/lib/nanoc3/data_sources/deprecated/twitter.rb +0 -38
  67. data/lib/nanoc3/data_sources/filesystem.rb +0 -299
  68. data/lib/nanoc3/data_sources/filesystem_unified.rb +0 -116
  69. data/lib/nanoc3/data_sources/filesystem_verbose.rb +0 -86
  70. data/lib/nanoc3/extra.rb +0 -22
  71. data/lib/nanoc3/extra/auto_compiler.rb +0 -103
  72. data/lib/nanoc3/extra/chick.rb +0 -125
  73. data/lib/nanoc3/extra/core_ext.rb +0 -4
  74. data/lib/nanoc3/extra/core_ext/enumerable.rb +0 -33
  75. data/lib/nanoc3/extra/core_ext/time.rb +0 -19
  76. data/lib/nanoc3/extra/deployers.rb +0 -11
  77. data/lib/nanoc3/extra/deployers/rsync.rb +0 -114
  78. data/lib/nanoc3/extra/file_proxy.rb +0 -40
  79. data/lib/nanoc3/extra/validators.rb +0 -12
  80. data/lib/nanoc3/extra/validators/links.rb +0 -264
  81. data/lib/nanoc3/extra/validators/w3c.rb +0 -95
  82. data/lib/nanoc3/extra/vcs.rb +0 -66
  83. data/lib/nanoc3/extra/vcses.rb +0 -17
  84. data/lib/nanoc3/extra/vcses/bazaar.rb +0 -25
  85. data/lib/nanoc3/extra/vcses/dummy.rb +0 -24
  86. data/lib/nanoc3/extra/vcses/git.rb +0 -25
  87. data/lib/nanoc3/extra/vcses/mercurial.rb +0 -25
  88. data/lib/nanoc3/extra/vcses/subversion.rb +0 -25
  89. data/lib/nanoc3/filters.rb +0 -53
  90. data/lib/nanoc3/filters/asciidoc.rb +0 -38
  91. data/lib/nanoc3/filters/bluecloth.rb +0 -19
  92. data/lib/nanoc3/filters/coderay.rb +0 -21
  93. data/lib/nanoc3/filters/colorize_syntax.rb +0 -261
  94. data/lib/nanoc3/filters/erb.rb +0 -35
  95. data/lib/nanoc3/filters/erubis.rb +0 -27
  96. data/lib/nanoc3/filters/haml.rb +0 -27
  97. data/lib/nanoc3/filters/kramdown.rb +0 -20
  98. data/lib/nanoc3/filters/less.rb +0 -53
  99. data/lib/nanoc3/filters/markaby.rb +0 -20
  100. data/lib/nanoc3/filters/maruku.rb +0 -20
  101. data/lib/nanoc3/filters/mustache.rb +0 -24
  102. data/lib/nanoc3/filters/rainpress.rb +0 -19
  103. data/lib/nanoc3/filters/rdiscount.rb +0 -22
  104. data/lib/nanoc3/filters/rdoc.rb +0 -33
  105. data/lib/nanoc3/filters/redcarpet.rb +0 -27
  106. data/lib/nanoc3/filters/redcloth.rb +0 -47
  107. data/lib/nanoc3/filters/relativize_paths.rb +0 -45
  108. data/lib/nanoc3/filters/rubypants.rb +0 -20
  109. data/lib/nanoc3/filters/sass.rb +0 -66
  110. data/lib/nanoc3/filters/slim.rb +0 -25
  111. data/lib/nanoc3/filters/typogruby.rb +0 -23
  112. data/lib/nanoc3/filters/uglify_js.rb +0 -42
  113. data/lib/nanoc3/helpers.rb +0 -16
  114. data/lib/nanoc3/helpers/blogging.rb +0 -319
  115. data/lib/nanoc3/helpers/breadcrumbs.rb +0 -40
  116. data/lib/nanoc3/helpers/capturing.rb +0 -138
  117. data/lib/nanoc3/helpers/filtering.rb +0 -50
  118. data/lib/nanoc3/helpers/html_escape.rb +0 -55
  119. data/lib/nanoc3/helpers/link_to.rb +0 -151
  120. data/lib/nanoc3/helpers/rendering.rb +0 -140
  121. data/lib/nanoc3/helpers/tagging.rb +0 -71
  122. data/lib/nanoc3/helpers/text.rb +0 -44
  123. data/lib/nanoc3/helpers/xml_sitemap.rb +0 -76
  124. data/lib/nanoc3/tasks.rb +0 -10
  125. data/lib/nanoc3/tasks/clean.rake +0 -16
  126. data/lib/nanoc3/tasks/clean.rb +0 -29
  127. data/lib/nanoc3/tasks/deploy/rsync.rake +0 -14
  128. data/lib/nanoc3/tasks/validate.rake +0 -92
  129. data/nanoc3.gemspec +0 -49
  130. data/tasks/doc.rake +0 -16
  131. data/tasks/test.rake +0 -44
  132. data/test/base/core_ext/array_spec.rb +0 -73
  133. data/test/base/core_ext/hash_spec.rb +0 -98
  134. data/test/base/core_ext/pathname_spec.rb +0 -27
  135. data/test/base/core_ext/string_spec.rb +0 -37
  136. data/test/base/test_checksum_store.rb +0 -35
  137. data/test/base/test_code_snippet.rb +0 -31
  138. data/test/base/test_compiler.rb +0 -316
  139. data/test/base/test_compiler_dsl.rb +0 -161
  140. data/test/base/test_context.rb +0 -31
  141. data/test/base/test_data_source.rb +0 -46
  142. data/test/base/test_dependency_tracker.rb +0 -262
  143. data/test/base/test_directed_graph.rb +0 -283
  144. data/test/base/test_filter.rb +0 -83
  145. data/test/base/test_item.rb +0 -179
  146. data/test/base/test_item_rep.rb +0 -553
  147. data/test/base/test_layout.rb +0 -59
  148. data/test/base/test_memoization.rb +0 -90
  149. data/test/base/test_notification_center.rb +0 -34
  150. data/test/base/test_outdatedness_checker.rb +0 -394
  151. data/test/base/test_plugin.rb +0 -30
  152. data/test/base/test_rule.rb +0 -19
  153. data/test/base/test_rule_context.rb +0 -65
  154. data/test/base/test_site.rb +0 -190
  155. data/test/cli/commands/test_compile.rb +0 -33
  156. data/test/cli/commands/test_create_item.rb +0 -14
  157. data/test/cli/commands/test_create_layout.rb +0 -28
  158. data/test/cli/commands/test_create_site.rb +0 -24
  159. data/test/cli/commands/test_help.rb +0 -12
  160. data/test/cli/commands/test_info.rb +0 -11
  161. data/test/cli/commands/test_update.rb +0 -10
  162. data/test/cli/test_cli.rb +0 -102
  163. data/test/cli/test_error_handler.rb +0 -29
  164. data/test/cli/test_logger.rb +0 -10
  165. data/test/data_sources/test_filesystem.rb +0 -433
  166. data/test/data_sources/test_filesystem_unified.rb +0 -536
  167. data/test/data_sources/test_filesystem_verbose.rb +0 -357
  168. data/test/extra/core_ext/test_enumerable.rb +0 -30
  169. data/test/extra/core_ext/test_time.rb +0 -15
  170. data/test/extra/deployers/test_rsync.rb +0 -232
  171. data/test/extra/test_auto_compiler.rb +0 -417
  172. data/test/extra/test_file_proxy.rb +0 -19
  173. data/test/extra/test_vcs.rb +0 -22
  174. data/test/extra/validators/test_links.rb +0 -51
  175. data/test/extra/validators/test_w3c.rb +0 -47
  176. data/test/filters/test_asciidoc.rb +0 -22
  177. data/test/filters/test_bluecloth.rb +0 -18
  178. data/test/filters/test_coderay.rb +0 -44
  179. data/test/filters/test_colorize_syntax.rb +0 -283
  180. data/test/filters/test_erb.rb +0 -99
  181. data/test/filters/test_erubis.rb +0 -70
  182. data/test/filters/test_haml.rb +0 -96
  183. data/test/filters/test_kramdown.rb +0 -18
  184. data/test/filters/test_less.rb +0 -113
  185. data/test/filters/test_markaby.rb +0 -24
  186. data/test/filters/test_maruku.rb +0 -18
  187. data/test/filters/test_mustache.rb +0 -25
  188. data/test/filters/test_rainpress.rb +0 -29
  189. data/test/filters/test_rdiscount.rb +0 -31
  190. data/test/filters/test_rdoc.rb +0 -18
  191. data/test/filters/test_redcarpet.rb +0 -63
  192. data/test/filters/test_redcloth.rb +0 -33
  193. data/test/filters/test_relativize_paths.rb +0 -332
  194. data/test/filters/test_rubypants.rb +0 -18
  195. data/test/filters/test_sass.rb +0 -229
  196. data/test/filters/test_slim.rb +0 -35
  197. data/test/filters/test_typogruby.rb +0 -21
  198. data/test/filters/test_uglify_js.rb +0 -30
  199. data/test/gem_loader.rb +0 -11
  200. data/test/helper.rb +0 -179
  201. data/test/helpers/test_blogging.rb +0 -754
  202. data/test/helpers/test_breadcrumbs.rb +0 -81
  203. data/test/helpers/test_capturing.rb +0 -41
  204. data/test/helpers/test_filtering.rb +0 -106
  205. data/test/helpers/test_html_escape.rb +0 -32
  206. data/test/helpers/test_link_to.rb +0 -249
  207. data/test/helpers/test_rendering.rb +0 -89
  208. data/test/helpers/test_tagging.rb +0 -87
  209. data/test/helpers/test_text.rb +0 -24
  210. data/test/helpers/test_xml_sitemap.rb +0 -103
  211. data/test/tasks/test_clean.rb +0 -67
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'erb'
4
-
5
- module Nanoc3::Filters
6
- class ERB < Nanoc3::Filter
7
-
8
- # Runs the content through [ERB](http://ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html).
9
- #
10
- # @param [String] content The content to filter
11
- #
12
- # @option params [Integer] safe_level (nil) The safe level (`$SAFE`) to
13
- # use while running this filter
14
- #
15
- # @option params [String] trim_mode (nil) The trim mode to use
16
- #
17
- # @return [String] The filtered content
18
- def run(content, params={})
19
- # Create context
20
- context = ::Nanoc3::Context.new(assigns)
21
-
22
- # Get binding
23
- proc = assigns[:content] ? lambda { assigns[:content] } : nil
24
- assigns_binding = context.get_binding(&proc)
25
-
26
- # Get result
27
- safe_level = params[:safe_level]
28
- trim_mode = params[:trim_mode]
29
- erb = ::ERB.new(content, safe_level, trim_mode)
30
- erb.filename = filename
31
- erb.result(assigns_binding)
32
- end
33
-
34
- end
35
- end
@@ -1,27 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'erubis'
4
-
5
- module Nanoc3::Filters
6
- class Erubis < Nanoc3::Filter
7
-
8
- # Runs the content through [Erubis](http://www.kuwata-lab.com/erubis/).
9
- # This method takes no options.
10
- #
11
- # @param [String] content The content to filter
12
- #
13
- # @return [String] The filtered content
14
- def run(content, params={})
15
- # Create context
16
- context = ::Nanoc3::Context.new(assigns)
17
-
18
- # Get binding
19
- proc = assigns[:content] ? lambda { assigns[:content] } : nil
20
- assigns_binding = context.get_binding(&proc)
21
-
22
- # Get result
23
- ::Erubis::Eruby.new(content, :filename => filename).result(assigns_binding)
24
- end
25
-
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'haml'
4
-
5
- module Nanoc3::Filters
6
- class Haml < Nanoc3::Filter
7
-
8
- # Runs the content through [Haml](http://haml-lang.com/).
9
- # Parameters passed to this filter will be passed on to Haml.
10
- #
11
- # @param [String] content The content to filter
12
- #
13
- # @return [String] The filtered content
14
- def run(content, params={})
15
- # Get options
16
- options = params.merge(:filename => filename)
17
-
18
- # Create context
19
- context = ::Nanoc3::Context.new(assigns)
20
-
21
- # Get result
22
- proc = assigns[:content] ? lambda { assigns[:content] } : nil
23
- ::Haml::Engine.new(content, options).render(context, assigns, &proc)
24
- end
25
-
26
- end
27
- end
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'kramdown'
4
-
5
- module Nanoc3::Filters
6
- class Kramdown < Nanoc3::Filter
7
-
8
- # Runs the content through [Kramdown](http://kramdown.rubyforge.org/).
9
- # Parameters passed to this filter will be passed on to Kramdown.
10
- #
11
- # @param [String] content The content to filter
12
- #
13
- # @return [String] The filtered content
14
- def run(content, params={})
15
- # Get result
16
- ::Kramdown::Document.new(content, params).to_html
17
- end
18
-
19
- end
20
- end
@@ -1,53 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'less'
4
-
5
- module Nanoc3::Filters
6
- class Less < Nanoc3::Filter
7
-
8
- # Runs the content through [LESS](http://lesscss.org/).
9
- # This method takes no options.
10
- #
11
- # @param [String] content The content to filter
12
- #
13
- # @return [String] The filtered content
14
- def run(content, params={})
15
- # Find imports (hacky)
16
- imports = []
17
- imports.concat(content.scan(/^@import\s+(["'])([^\1]+?)\1;/))
18
- imports.concat(content.scan(/^@import\s+url\((["']?)([^)]+?)\1\);/))
19
- imported_filenames = imports.map do |i|
20
- i[1].match(/\.(less|css)$/) ? i[1] : i[1] + '.less'
21
- end
22
-
23
- # Convert to items
24
- imported_items = imported_filenames.map do |filename|
25
- # Find directory for this item
26
- current_dir_pathname = Pathname.new(@item[:content_filename]).dirname.realpath
27
-
28
- # Find absolute pathname for imported item
29
- imported_pathname = Pathname.new(filename)
30
- if imported_pathname.relative?
31
- imported_pathname = current_dir_pathname + imported_pathname
32
- end
33
- next if !imported_pathname.exist?
34
- imported_filename = imported_pathname.realpath
35
-
36
- # Find matching item
37
- @items.find do |i|
38
- next if i[:content_filename].nil?
39
- Pathname.new(i[:content_filename]).realpath == imported_filename
40
- end
41
- end.compact
42
-
43
- # Create dependencies
44
- depend_on(imported_items)
45
-
46
- # Add filename to load path
47
- paths = [ File.dirname(@item[:content_filename]) ]
48
- parser = ::Less::Parser.new(:paths => paths)
49
- parser.parse(content).to_css
50
- end
51
-
52
- end
53
- end
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'markaby'
4
-
5
- module Nanoc3::Filters
6
- class Markaby < Nanoc3::Filter
7
-
8
- # Runs the content through [Markaby](http://markaby.rubyforge.org/).
9
- # This method takes no options.
10
- #
11
- # @param [String] content The content to filter
12
- #
13
- # @return [String] The filtered content
14
- def run(content, params={})
15
- # Get result
16
- ::Markaby::Builder.new(assigns).instance_eval(content).to_s
17
- end
18
-
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'maruku'
4
-
5
- module Nanoc3::Filters
6
- class Maruku < Nanoc3::Filter
7
-
8
- # Runs the content through [Maruku](http://maruku.rubyforge.org/).
9
- # Parameters passed to this filter will be passed on to Maruku.
10
- #
11
- # @param [String] content The content to filter
12
- #
13
- # @return [String] The filtered content
14
- def run(content, params={})
15
- # Get result
16
- ::Maruku.new(content, params).to_html
17
- end
18
-
19
- end
20
- end
@@ -1,24 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'mustache'
4
-
5
- module Nanoc3::Filters
6
-
7
- # @since 3.2.0
8
- class Mustache < Nanoc3::Filter
9
-
10
- # Runs the content through
11
- # [Mustache](http://github.com/defunkt/mustache). This method takes no
12
- # options.
13
- #
14
- # @param [String] content The content to filter
15
- #
16
- # @return [String] The filtered content
17
- def run(content, params={})
18
- # Get result
19
- ::Mustache.render(content, item.attributes)
20
- end
21
-
22
- end
23
-
24
- end
@@ -1,19 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rainpress'
4
-
5
- module Nanoc3::Filters
6
- class Rainpress < Nanoc3::Filter
7
-
8
- # Runs the content through [Rainpress](http://code.google.com/p/rainpress/).
9
- # Parameters passed to this filter will be passed on to Rainpress.
10
- #
11
- # @param [String] content The content to filter
12
- #
13
- # @return [String] The filtered content
14
- def run(content, params={})
15
- ::Rainpress.compress(content, params)
16
- end
17
-
18
- end
19
- end
@@ -1,22 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rdiscount'
4
-
5
- module Nanoc3::Filters
6
- class RDiscount < Nanoc3::Filter
7
-
8
- # Runs the content through [RDiscount](http://github.com/rtomayko/rdiscount).
9
- #
10
- # @option params [Array] symbol ([]) A list of RDiscount extensions
11
- #
12
- # @param [String] content The content to filter
13
- #
14
- # @return [String] The filtered content
15
- def run(content, params={})
16
- extensions = params[:extensions] || []
17
-
18
- ::RDiscount.new(content, *extensions).to_html
19
- end
20
-
21
- end
22
- end
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
-
3
- begin
4
- # new RDoc
5
- require 'rdoc/markup'
6
- require 'rdoc/markup/to_html'
7
- rescue LoadError
8
- # old RDoc
9
- require 'rdoc/markup/simple_markup'
10
- require 'rdoc/markup/simple_markup/to_html'
11
- end
12
-
13
- module Nanoc3::Filters
14
- class RDoc < Nanoc3::Filter
15
-
16
- # Runs the content through [RDoc::Markup](http://rdoc.rubyforge.org/RDoc/Markup.html).
17
- # This method takes no options.
18
- #
19
- # @param [String] content The content to filter
20
- #
21
- # @return [String] The filtered content
22
- def run(content, params={})
23
- begin
24
- # new RDoc
25
- ::RDoc::Markup.new.convert(content, ::RDoc::Markup::ToHtml.new)
26
- rescue LoadError
27
- # old RDoc
28
- ::SM::SimpleMarkup.new.convert(content, ::SM::ToHtml.new)
29
- end
30
- end
31
-
32
- end
33
- end
@@ -1,27 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'redcarpet'
4
-
5
- module Nanoc3::Filters
6
-
7
- # @since 3.2.0
8
- class Redcarpet < Nanoc3::Filter
9
-
10
- # Runs the content through [Redcarpet](https://github.com/tanoku/redcarpet/).
11
- # This method optionally takes processing options to pass on to Redcarpet.
12
- #
13
- # @param [String] content The content to filter
14
- #
15
- # @option params [Array] :options ([]) A list of options to pass on to
16
- # Redcarpet
17
- #
18
- # @return [String] The filtered content
19
- def run(content, params={})
20
- options = params[:options] || []
21
-
22
- ::Redcarpet.new(content, *options).to_html
23
- end
24
-
25
- end
26
-
27
- end
@@ -1,47 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'redcloth'
4
-
5
- module Nanoc3::Filters
6
- class RedCloth < Nanoc3::Filter
7
-
8
- # Runs the content through [RedCloth](http://redcloth.org/). This method
9
- # takes the following options:
10
- #
11
- # * `:filter_class`
12
- # * `:filter_html`
13
- # * `:filter_ids`
14
- # * `:filter_style`
15
- # * `:hard_breaks`
16
- # * `:lite_mode`
17
- # * `:no_span_caps`
18
- # * `:sanitize_htm`
19
- #
20
- # Each of these options sets the corresponding attribute on the `RedCloth`
21
- # instance. For example, when the `:hard_breaks => false` option is passed
22
- # to this filter, the filter will call `r.hard_breaks = false` (with `r`
23
- # being the `RedCloth` instance).
24
- #
25
- # @param [String] content The content to filter
26
- #
27
- # @return [String] The filtered content
28
- def run(content, params={})
29
- # Create formatter
30
- r = ::RedCloth.new(content)
31
-
32
- # Set options
33
- r.filter_classes = params[:filter_classes] if params.has_key?(:filter_classes)
34
- r.filter_html = params[:filter_html] if params.has_key?(:filter_html)
35
- r.filter_ids = params[:filter_ids] if params.has_key?(:filter_ids)
36
- r.filter_styles = params[:filter_styles] if params.has_key?(:filter_styles)
37
- r.hard_breaks = params[:hard_breaks] if params.has_key?(:hard_breaks)
38
- r.lite_mode = params[:lite_mode] if params.has_key?(:lite_mode)
39
- r.no_span_caps = params[:no_span_caps] if params.has_key?(:no_span_caps)
40
- r.sanitize_html = params[:sanitize_html] if params.has_key?(:sanitize_html)
41
-
42
- # Get result
43
- r.to_html
44
- end
45
-
46
- end
47
- end
@@ -1,45 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::Filters
4
- class RelativizePaths < Nanoc3::Filter
5
-
6
- require 'nanoc3/helpers/link_to'
7
- include Nanoc3::Helpers::LinkTo
8
-
9
- # Relativizes all paths in the given content, which can be either HTML or
10
- # CSS. This filter is quite useful if a site needs to be hosted in a
11
- # subdirectory instead of a subdomain. In HTML, all `href` and `src`
12
- # attributes will be relativized. In CSS, all `url()` references will be
13
- # relativized.
14
- #
15
- # @param [String] content The content to filter
16
- #
17
- # @option params [Symbol] :type The type of content to filter; can be
18
- # either `:html` or `:css`.
19
- #
20
- # @return [String] The filtered content
21
- def run(content, params={})
22
- # Set assigns so helper function can be used
23
- @item_rep = assigns[:item_rep] if @item_rep.nil?
24
-
25
- # Filter
26
- # FIXME use nokogiri or csspool instead of regular expressions
27
- case params[:type]
28
- when :html
29
- content.gsub(/(<[^>]+\s+(src|href))=(['"]?)(\/(?:[^\/].*?)?)\3([\s\/>])/) do
30
- $1 + '=' + $3 + relative_path_to($4) + $3 + $5
31
- end
32
- when :css
33
- content.gsub(/url\((['"]?)(\/(?:[^\/].*?)?)\1\)/) do
34
- 'url(' + $1 + relative_path_to($2) + $1 + ')'
35
- end
36
- else
37
- raise RuntimeError.new(
38
- "The relativize_paths needs to know the type of content to " +
39
- "process. Pass :type => :html for HTML or :type => :css for CSS."
40
- )
41
- end
42
- end
43
-
44
- end
45
- end
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rubypants'
4
-
5
- module Nanoc3::Filters
6
- class RubyPants < Nanoc3::Filter
7
-
8
- # Runs the content through [RubyPants](http://chneukirchen.org/blog/static/projects/rubypants.html).
9
- # This method takes no options.
10
- #
11
- # @param [String] content The content to filter
12
- #
13
- # @return [String] The filtered content
14
- def run(content, params={})
15
- # Get result
16
- ::RubyPants.new(content).to_html
17
- end
18
-
19
- end
20
- end