nanoc3 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/ChangeLog +3 -0
  2. data/LICENSE +19 -0
  3. data/NEWS.rdoc +262 -0
  4. data/README.rdoc +80 -0
  5. data/Rakefile +11 -0
  6. data/bin/nanoc3 +16 -0
  7. data/lib/nanoc3/base/code_snippet.rb +42 -0
  8. data/lib/nanoc3/base/compiler.rb +225 -0
  9. data/lib/nanoc3/base/compiler_dsl.rb +110 -0
  10. data/lib/nanoc3/base/core_ext/array.rb +21 -0
  11. data/lib/nanoc3/base/core_ext/hash.rb +23 -0
  12. data/lib/nanoc3/base/core_ext/string.rb +14 -0
  13. data/lib/nanoc3/base/core_ext.rb +5 -0
  14. data/lib/nanoc3/base/data_source.rb +197 -0
  15. data/lib/nanoc3/base/dependency_tracker.rb +291 -0
  16. data/lib/nanoc3/base/errors.rb +95 -0
  17. data/lib/nanoc3/base/filter.rb +60 -0
  18. data/lib/nanoc3/base/item.rb +87 -0
  19. data/lib/nanoc3/base/item_rep.rb +236 -0
  20. data/lib/nanoc3/base/layout.rb +53 -0
  21. data/lib/nanoc3/base/notification_center.rb +68 -0
  22. data/lib/nanoc3/base/plugin.rb +88 -0
  23. data/lib/nanoc3/base/preprocessor_context.rb +37 -0
  24. data/lib/nanoc3/base/rule.rb +37 -0
  25. data/lib/nanoc3/base/rule_context.rb +68 -0
  26. data/lib/nanoc3/base/site.rb +334 -0
  27. data/lib/nanoc3/base.rb +25 -0
  28. data/lib/nanoc3/cli/base.rb +151 -0
  29. data/lib/nanoc3/cli/commands/autocompile.rb +89 -0
  30. data/lib/nanoc3/cli/commands/compile.rb +279 -0
  31. data/lib/nanoc3/cli/commands/create_item.rb +79 -0
  32. data/lib/nanoc3/cli/commands/create_layout.rb +94 -0
  33. data/lib/nanoc3/cli/commands/create_site.rb +320 -0
  34. data/lib/nanoc3/cli/commands/help.rb +71 -0
  35. data/lib/nanoc3/cli/commands/info.rb +114 -0
  36. data/lib/nanoc3/cli/commands/update.rb +96 -0
  37. data/lib/nanoc3/cli/commands.rb +13 -0
  38. data/lib/nanoc3/cli/logger.rb +73 -0
  39. data/lib/nanoc3/cli.rb +16 -0
  40. data/lib/nanoc3/data_sources/delicious.rb +66 -0
  41. data/lib/nanoc3/data_sources/filesystem.rb +231 -0
  42. data/lib/nanoc3/data_sources/filesystem_combined.rb +202 -0
  43. data/lib/nanoc3/data_sources/filesystem_common.rb +22 -0
  44. data/lib/nanoc3/data_sources/filesystem_compact.rb +232 -0
  45. data/lib/nanoc3/data_sources/last_fm.rb +103 -0
  46. data/lib/nanoc3/data_sources/twitter.rb +53 -0
  47. data/lib/nanoc3/data_sources.rb +20 -0
  48. data/lib/nanoc3/extra/auto_compiler.rb +97 -0
  49. data/lib/nanoc3/extra/chick.rb +119 -0
  50. data/lib/nanoc3/extra/context.rb +24 -0
  51. data/lib/nanoc3/extra/core_ext/time.rb +19 -0
  52. data/lib/nanoc3/extra/core_ext.rb +3 -0
  53. data/lib/nanoc3/extra/deployers/rsync.rb +64 -0
  54. data/lib/nanoc3/extra/deployers.rb +12 -0
  55. data/lib/nanoc3/extra/file_proxy.rb +31 -0
  56. data/lib/nanoc3/extra/validators/links.rb +0 -0
  57. data/lib/nanoc3/extra/validators/w3c.rb +71 -0
  58. data/lib/nanoc3/extra/validators.rb +12 -0
  59. data/lib/nanoc3/extra/vcs.rb +65 -0
  60. data/lib/nanoc3/extra/vcses/bazaar.rb +21 -0
  61. data/lib/nanoc3/extra/vcses/dummy.rb +20 -0
  62. data/lib/nanoc3/extra/vcses/git.rb +21 -0
  63. data/lib/nanoc3/extra/vcses/mercurial.rb +21 -0
  64. data/lib/nanoc3/extra/vcses/subversion.rb +21 -0
  65. data/lib/nanoc3/extra/vcses.rb +17 -0
  66. data/lib/nanoc3/extra.rb +16 -0
  67. data/lib/nanoc3/filters/bluecloth.rb +13 -0
  68. data/lib/nanoc3/filters/coderay.rb +17 -0
  69. data/lib/nanoc3/filters/erb.rb +19 -0
  70. data/lib/nanoc3/filters/erubis.rb +17 -0
  71. data/lib/nanoc3/filters/haml.rb +20 -0
  72. data/lib/nanoc3/filters/less.rb +13 -0
  73. data/lib/nanoc3/filters/markaby.rb +14 -0
  74. data/lib/nanoc3/filters/maruku.rb +14 -0
  75. data/lib/nanoc3/filters/rainpress.rb +13 -0
  76. data/lib/nanoc3/filters/rdiscount.rb +13 -0
  77. data/lib/nanoc3/filters/rdoc.rb +23 -0
  78. data/lib/nanoc3/filters/redcloth.rb +14 -0
  79. data/lib/nanoc3/filters/relativize_paths.rb +32 -0
  80. data/lib/nanoc3/filters/rubypants.rb +14 -0
  81. data/lib/nanoc3/filters/sass.rb +17 -0
  82. data/lib/nanoc3/filters.rb +37 -0
  83. data/lib/nanoc3/helpers/blogging.rb +226 -0
  84. data/lib/nanoc3/helpers/breadcrumbs.rb +25 -0
  85. data/lib/nanoc3/helpers/capturing.rb +71 -0
  86. data/lib/nanoc3/helpers/filtering.rb +46 -0
  87. data/lib/nanoc3/helpers/html_escape.rb +22 -0
  88. data/lib/nanoc3/helpers/link_to.rb +120 -0
  89. data/lib/nanoc3/helpers/rendering.rb +76 -0
  90. data/lib/nanoc3/helpers/tagging.rb +58 -0
  91. data/lib/nanoc3/helpers/text.rb +40 -0
  92. data/lib/nanoc3/helpers/xml_sitemap.rb +69 -0
  93. data/lib/nanoc3/helpers.rb +16 -0
  94. data/lib/nanoc3/package.rb +106 -0
  95. data/lib/nanoc3/tasks/clean.rake +16 -0
  96. data/lib/nanoc3/tasks/clean.rb +33 -0
  97. data/lib/nanoc3/tasks/deploy/rsync.rake +11 -0
  98. data/lib/nanoc3/tasks/validate.rake +35 -0
  99. data/lib/nanoc3/tasks.rb +9 -0
  100. data/lib/nanoc3.rb +19 -0
  101. data/vendor/cri/ChangeLog +0 -0
  102. data/vendor/cri/LICENSE +19 -0
  103. data/vendor/cri/NEWS +0 -0
  104. data/vendor/cri/README +4 -0
  105. data/vendor/cri/Rakefile +25 -0
  106. data/vendor/cri/lib/cri/base.rb +153 -0
  107. data/vendor/cri/lib/cri/command.rb +105 -0
  108. data/vendor/cri/lib/cri/core_ext/string.rb +41 -0
  109. data/vendor/cri/lib/cri/core_ext.rb +8 -0
  110. data/vendor/cri/lib/cri/option_parser.rb +186 -0
  111. data/vendor/cri/lib/cri.rb +12 -0
  112. data/vendor/cri/test/test_base.rb +6 -0
  113. data/vendor/cri/test/test_command.rb +6 -0
  114. data/vendor/cri/test/test_core_ext.rb +21 -0
  115. data/vendor/cri/test/test_option_parser.rb +279 -0
  116. metadata +225 -0
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra::Deployers
4
+
5
+ # Nanoc3::Extra::Deployers::Rsync is a deployer that deploys a site using rsync.
6
+ class Rsync
7
+
8
+ # Creates a new deployment task that uses rsync. The deployment
9
+ # configuration will be taken from the site's configuration file.
10
+ def initialize
11
+ # Get site
12
+ error 'No site configuration found' unless File.file?('config.yaml')
13
+ @site = Nanoc3::Site.new('.')
14
+ end
15
+
16
+ # Runs the task. Possible params:
17
+ #
18
+ # +:dry_run+:: Set to true when the action itself should not be executed,
19
+ # but still printed. Useful for debugging.
20
+ #
21
+ # +:config_name+:: The name of the deployment configuration to use.
22
+ # Defaults to +:default+ (surprise!).
23
+ def run(params={})
24
+ # Extract params
25
+ config_name = params.has_key?(:config_name) ? params[:config_name].to_sym : :default
26
+ dry_run = params.has_key?(:dry_run) ? params[:dry_run] : false
27
+
28
+ # Validate config
29
+ error 'No deploy configuration found' if @site.config[:deploy].nil?
30
+ error "No deploy configuration found for #{config_name}" if @site.config[:deploy][config_name].nil?
31
+
32
+ # Set arguments
33
+ src = File.expand_path(@site.config[:output_dir]) + '/'
34
+ dst = @site.config[:deploy][config_name][:dst]
35
+ options = @site.config[:deploy][config_name][:options] || []
36
+
37
+ # Validate arguments
38
+ error 'No dst found in deployment configuration' if dst.nil?
39
+ error 'dst requires no trailing slash' if dst[-1,1] == '/'
40
+
41
+ # Run
42
+ if dry_run
43
+ warn 'Performing a dry-run; no actions will actually be performed'
44
+ run_shell_cmd([ 'echo', 'rsync', options, src, dst ].flatten)
45
+ else
46
+ run_shell_cmd([ 'rsync', options, src, dst ].flatten)
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ # Prints the given message on stderr and exits.
53
+ def error(msg)
54
+ raise RuntimeError.new(msg)
55
+ end
56
+
57
+ # Runs the given shell command. This is a simple wrapper around Kernel#system.
58
+ def run_shell_cmd(args)
59
+ system(*args)
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra
4
+
5
+ # Nanoc3::Extra::Deployers is the name for all deployers.
6
+ module Deployers
7
+
8
+ autoload 'Rsync', 'nanoc3/extra/deployers/rsync'
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra
4
+
5
+ # A FileProxy is a proxy for a File object. It is used to prevent a File
6
+ # object from being created until it is actually necessary.
7
+ #
8
+ # For example, a site with a few thousand items would fail to compile
9
+ # because the massive amount of file descriptors necessary, but the file
10
+ # proxy will make sure the File object is not created until it is used.
11
+ class FileProxy
12
+
13
+ instance_methods.each { |m| undef_method m unless m =~ /^__/ || m.to_s == 'object_id' }
14
+
15
+ # Creates a new file proxy for the given path. This is similar to
16
+ # creating a File object with the same path, except that the File object
17
+ # will not be created until it is accessed.
18
+ def initialize(path)
19
+ @path = path
20
+ end
21
+
22
+ # Makes sure all method calls are relayed to a File object, which will
23
+ # be created right before the method call takes place and destroyed
24
+ # right after.
25
+ def method_missing(sym, *args, &block)
26
+ File.new(@path).__send__(sym, *args, &block)
27
+ end
28
+
29
+ end
30
+
31
+ end
File without changes
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra::Validators
4
+
5
+ # Nanoc3::Extra::Validators::W3C is a validator that uses the W3C web
6
+ # service to validate HTML and CSS files.
7
+ class W3C
8
+
9
+ def initialize(site, type)
10
+ @site = site
11
+ @type = type
12
+ end
13
+
14
+ def run
15
+ # Load validator
16
+ require 'w3c_validators'
17
+
18
+ # Make sure config is loaded
19
+ @site.load_data
20
+
21
+ # Find all files
22
+ files = extensions.map { |extension| Dir["#{@site.config[:output_dir]}/**/*.#{extension}"] }.flatten
23
+
24
+ # Validate each file
25
+ files.each do |file|
26
+ validation_started(file)
27
+ results = validator.validate_file(file)
28
+ validation_ended(file, results.errors)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def extensions
35
+ case @type
36
+ when :html
37
+ [ 'html', 'htm' ]
38
+ when :css
39
+ [ 'css' ]
40
+ end
41
+ end
42
+
43
+ def validator_class
44
+ case @type
45
+ when :html
46
+ ::W3CValidators::MarkupValidator
47
+ when :css
48
+ ::W3CValidators::CSSValidator
49
+ end
50
+ end
51
+
52
+ def validator
53
+ @validator ||= validator_class.new
54
+ end
55
+
56
+ def validation_started(file)
57
+ $stdout.print "Validating #{file}... "
58
+ $stdout.flush
59
+ end
60
+
61
+ def validation_ended(file, errors)
62
+ $stdout.puts(errors.empty? ? "valid" : "INVALID")
63
+
64
+ errors.each do |err|
65
+ puts " #{err}"
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra
4
+
5
+ # Nanoc3::Extra::Validators is the name for all validators.
6
+ module Validators
7
+
8
+ autoload 'W3C', 'nanoc3/extra/validators/w3c'
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra
4
+
5
+ # Nanoc3::Extra::VCS is a very simple representation of a version control
6
+ # system that abstracts the add, remove and move operations. It does not
7
+ # commit. This class is primarily used by data sources that store data as
8
+ # flat files on the disk.
9
+ #
10
+ # This is the abstract superclass for all VCSes. Subclasses should implement
11
+ # the indicated methods.
12
+ class VCS < Nanoc3::Plugin
13
+
14
+ # Sets the identifiers for this VCS.
15
+ def self.identifiers(*identifiers)
16
+ Nanoc3::Extra::VCS.register(self, *identifiers)
17
+ end
18
+
19
+ # Sets the identifier for this VCS.
20
+ def self.identifier(identifier)
21
+ Nanoc3::Extra::VCS.register(self, identifier)
22
+ end
23
+
24
+ # Registers the given class as a VCS with the given identifier.
25
+ def self.register(class_or_name, *identifiers)
26
+ Nanoc3::Plugin.register(Nanoc3::Extra::VCS, class_or_name, *identifiers)
27
+ end
28
+
29
+ # Adds the file with the given filename to the working copy.
30
+ #
31
+ # Subclasses must implement this method.
32
+ def add(filename)
33
+ not_implemented('add')
34
+ end
35
+
36
+ # Removes the file with the given filename from the working copy. When
37
+ # this method is executed, the file should no longer be present on the
38
+ # disk.
39
+ #
40
+ # Subclasses must implement this method.
41
+ def remove(filename)
42
+ not_implemented('remove')
43
+ end
44
+
45
+ # Moves the file with the given filename to a new location. When this
46
+ # method is executed, the original file should no longer be present on the
47
+ # disk.
48
+ #
49
+ # Subclasses must implement this method.
50
+ def move(src, dst)
51
+ not_implemented('move')
52
+ end
53
+
54
+ private
55
+
56
+ def not_implemented(name)
57
+ raise NotImplementedError.new(
58
+ "#{self.class} does not override ##{name}, which is required for " +
59
+ "this data source to be used."
60
+ )
61
+ end
62
+
63
+ end
64
+
65
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra::VCSes
4
+
5
+ class Bazaar < Nanoc3::Extra::VCS
6
+
7
+ def add(filename)
8
+ system('bzr', 'add', filename)
9
+ end
10
+
11
+ def remove(filename)
12
+ system('bzr', 'rm', filename)
13
+ end
14
+
15
+ def move(src, dst)
16
+ system('bzr', 'mv', src, dst)
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra::VCSes
4
+
5
+ class Dummy < Nanoc3::Extra::VCS
6
+
7
+ def add(filename)
8
+ end
9
+
10
+ def remove(filename)
11
+ FileUtils.rm_rf(filename)
12
+ end
13
+
14
+ def move(src, dst)
15
+ FileUtils.move(src, dst)
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra::VCSes
4
+
5
+ class Git < Nanoc3::Extra::VCS
6
+
7
+ def add(filename)
8
+ system('git', 'add', filename)
9
+ end
10
+
11
+ def remove(filename)
12
+ system('git', 'rm', filename)
13
+ end
14
+
15
+ def move(src, dst)
16
+ system('git', 'mv', src, dst)
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra::VCSes
4
+
5
+ class Mercurial < Nanoc3::Extra::VCS
6
+
7
+ def add(filename)
8
+ system('hg', 'add', filename)
9
+ end
10
+
11
+ def remove(filename)
12
+ system('hg', 'rm', filename)
13
+ end
14
+
15
+ def move(src, dst)
16
+ system('hg', 'mv', src, dst)
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra::VCSes
4
+
5
+ class Subversion < Nanoc3::Extra::VCS
6
+
7
+ def add(filename)
8
+ system('svn', 'add', filename)
9
+ end
10
+
11
+ def remove(filename)
12
+ system('svn', 'rm', filename)
13
+ end
14
+
15
+ def move(src, dst)
16
+ system('svn', 'mv', src, dst)
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra::VCSes
4
+
5
+ autoload 'Bazaar', 'nanoc3/extra/vcses/bazaar'
6
+ autoload 'Dummy', 'nanoc3/extra/vcses/dummy'
7
+ autoload 'Git', 'nanoc3/extra/vcses/git'
8
+ autoload 'Mercurial', 'nanoc3/extra/vcses/mercurial'
9
+ autoload 'Subversion', 'nanoc3/extra/vcses/subversion'
10
+
11
+ Nanoc3::Extra::VCS.register '::Nanoc3::Extra::VCSes::Bazaar', :bazaar, :bzr
12
+ Nanoc3::Extra::VCS.register '::Nanoc3::Extra::VCSes::Dummy', :dummy
13
+ Nanoc3::Extra::VCS.register '::Nanoc3::Extra::VCSes::Git', :git
14
+ Nanoc3::Extra::VCS.register '::Nanoc3::Extra::VCSes::Mercurial', :mercurial, :hg
15
+ Nanoc3::Extra::VCS.register '::Nanoc3::Extra::VCSes::Subversion', :subversion, :svn
16
+
17
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Extra
4
+
5
+ autoload 'AutoCompiler', 'nanoc3/extra/auto_compiler'
6
+ autoload 'CHiCk', 'nanoc3/extra/chick'
7
+ autoload 'Context', 'nanoc3/extra/context'
8
+ autoload 'Deployers', 'nanoc3/extra/deployers'
9
+ autoload 'FileProxy', 'nanoc3/extra/file_proxy'
10
+ autoload 'Validators', 'nanoc3/extra/validators'
11
+
12
+ end
13
+
14
+ require 'nanoc3/extra/core_ext'
15
+ require 'nanoc3/extra/vcs'
16
+ require 'nanoc3/extra/vcses'
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class BlueCloth < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'bluecloth'
8
+
9
+ ::BlueCloth.new(content).to_html
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class CodeRay < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'coderay'
8
+
9
+ # Check params
10
+ raise ArgumentError, "CodeRay filter requires a :language argument which is missing" if params[:language].nil?
11
+
12
+ # Get result
13
+ ::CodeRay.scan(content, params[:language]).html
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class ERB < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'erb'
8
+
9
+ # Create context
10
+ context = ::Nanoc3::Extra::Context.new(assigns)
11
+
12
+ # Get result
13
+ erb = ::ERB.new(content)
14
+ erb.filename = filename
15
+ erb.result(context.get_binding { assigns[:content] })
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class Erubis < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'erubis'
8
+
9
+ # Create context
10
+ context = ::Nanoc3::Extra::Context.new(assigns)
11
+
12
+ # Get result
13
+ ::Erubis::Eruby.new(content, :filename => filename).result(context.get_binding { assigns[:content] })
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class Haml < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'haml'
8
+
9
+ # Get options
10
+ options = params.merge(:filename => filename)
11
+
12
+ # Create context
13
+ context = ::Nanoc3::Extra::Context.new(assigns)
14
+
15
+ # Get result
16
+ ::Haml::Engine.new(content, options).render(context, assigns) { assigns[:content] }
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class Less < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'less'
8
+
9
+ ::Less::Engine.new(content).to_css
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class Markaby < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'markaby'
8
+
9
+ # Get result
10
+ ::Markaby::Builder.new(assigns).instance_eval(content).to_s
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class Maruku < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'maruku'
8
+
9
+ # Get result
10
+ ::Maruku.new(content).to_html
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class Rainpress < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'rainpress'
8
+
9
+ ::Rainpress.compress(content)
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class RDiscount < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'rdiscount'
8
+
9
+ ::RDiscount.new(content).to_html
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class RDoc < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ begin
8
+ # new RDoc
9
+ require 'rdoc/markup'
10
+ require 'rdoc/markup/to_html'
11
+
12
+ ::RDoc::Markup.new.convert(content, ::RDoc::Markup::ToHtml.new)
13
+ rescue LoadError
14
+ # old RDoc
15
+ require 'rdoc/markup/simple_markup'
16
+ require 'rdoc/markup/simple_markup/to_html'
17
+
18
+ ::SM::SimpleMarkup.new.convert(content, ::SM::ToHtml.new)
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class RedCloth < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'redcloth'
8
+
9
+ # Get result
10
+ ::RedCloth.new(content).to_html
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,32 @@
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
+ def run(content, params={})
10
+ # Set assigns so helper function can be used
11
+ @item_rep = assigns[:item_rep] if @item_rep.nil?
12
+
13
+ # Filter
14
+ case params[:type]
15
+ when :html
16
+ content.gsub(/(src|href)=(['"]?)(\/.+?)\2([ >])/) do
17
+ $1 + '=' + $2 + relative_path_to($3) + $2 + $4
18
+ end
19
+ when :css
20
+ content.gsub(/url\((['"]?)(\/.+?)\1\)/) do
21
+ 'url(' + $1 + relative_path_to($2) + $1 + ')'
22
+ end
23
+ else
24
+ raise RuntimeError.new(
25
+ "The relativize_paths needs to know the type of content to " +
26
+ "process. Pass :type => :html for HTML or :type => :css for CSS."
27
+ )
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class RubyPants < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'rubypants'
8
+
9
+ # Get result
10
+ ::RubyPants.new(content).to_html
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3::Filters
4
+ class Sass < Nanoc3::Filter
5
+
6
+ def run(content, params={})
7
+ require 'sass'
8
+
9
+ # Get options
10
+ options = params.merge(:filename => filename)
11
+
12
+ # Get result
13
+ ::Sass::Engine.new(content, options).render
14
+ end
15
+
16
+ end
17
+ end