nanoc 3.6.7 → 3.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CONTRIBUTING.md +9 -13
- data/Gemfile +5 -1
- data/Gemfile.lock +70 -45
- data/NEWS.md +15 -1
- data/README.md +12 -119
- data/doc/yardoc_handlers/identifier.rb +34 -0
- data/lib/nanoc/base/compilation/checksum_store.rb +2 -2
- data/lib/nanoc/base/compilation/compiler.rb +3 -3
- data/lib/nanoc/base/compilation/compiler_dsl.rb +20 -15
- data/lib/nanoc/base/compilation/dependency_tracker.rb +4 -4
- data/lib/nanoc/base/compilation/filter.rb +5 -5
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +2 -2
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +3 -3
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +49 -46
- data/lib/nanoc/base/compilation/rule.rb +6 -4
- data/lib/nanoc/base/compilation/rule_context.rb +10 -4
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +8 -7
- data/lib/nanoc/base/compilation/rule_memory_store.rb +2 -2
- data/lib/nanoc/base/compilation/rules_collection.rb +2 -2
- data/lib/nanoc/base/core_ext/array.rb +2 -2
- data/lib/nanoc/base/core_ext/date.rb +4 -2
- data/lib/nanoc/base/core_ext/hash.rb +3 -3
- data/lib/nanoc/base/core_ext/pathname.rb +1 -1
- data/lib/nanoc/base/directed_graph.rb +6 -6
- data/lib/nanoc/base/errors.rb +1 -1
- data/lib/nanoc/base/memoization.rb +4 -4
- data/lib/nanoc/base/notification_center.rb +1 -1
- data/lib/nanoc/base/ordered_hash.rb +207 -179
- data/lib/nanoc/base/plugin_registry.rb +7 -7
- data/lib/nanoc/base/result_data/item_rep.rb +25 -26
- data/lib/nanoc/base/source_data/code_snippet.rb +2 -2
- data/lib/nanoc/base/source_data/configuration.rb +1 -1
- data/lib/nanoc/base/source_data/data_source.rb +2 -2
- data/lib/nanoc/base/source_data/item.rb +16 -15
- data/lib/nanoc/base/source_data/item_array.rb +4 -4
- data/lib/nanoc/base/source_data/layout.rb +5 -5
- data/lib/nanoc/base/source_data/site.rb +6 -6
- data/lib/nanoc/base/store.rb +8 -8
- data/lib/nanoc/cli/cleaning_stream.rb +11 -12
- data/lib/nanoc/cli/command_runner.rb +8 -8
- data/lib/nanoc/cli/commands/autocompile.rb +5 -4
- data/lib/nanoc/cli/commands/check.rb +12 -11
- data/lib/nanoc/cli/commands/compile.rb +50 -52
- data/lib/nanoc/cli/commands/create-item.rb +6 -6
- data/lib/nanoc/cli/commands/create-layout.rb +6 -6
- data/lib/nanoc/cli/commands/create-site.rb +10 -13
- data/lib/nanoc/cli/commands/deploy.rb +11 -11
- data/lib/nanoc/cli/commands/prune.rb +10 -10
- data/lib/nanoc/cli/commands/shell.rb +7 -7
- data/lib/nanoc/cli/commands/show-data.rb +22 -23
- data/lib/nanoc/cli/commands/show-plugins.rb +3 -3
- data/lib/nanoc/cli/commands/show-rules.rb +8 -8
- data/lib/nanoc/cli/commands/sync.rb +4 -2
- data/lib/nanoc/cli/commands/update.rb +4 -4
- data/lib/nanoc/cli/commands/validate-css.rb +3 -3
- data/lib/nanoc/cli/commands/validate-html.rb +3 -3
- data/lib/nanoc/cli/commands/validate-links.rb +3 -3
- data/lib/nanoc/cli/commands/view.rb +5 -3
- data/lib/nanoc/cli/commands/watch.rb +12 -12
- data/lib/nanoc/cli/error_handler.rb +58 -58
- data/lib/nanoc/cli/logger.rb +6 -6
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -1
- data/lib/nanoc/cli/stream_cleaners.rb +0 -1
- data/lib/nanoc/cli.rb +24 -22
- data/lib/nanoc/data_sources/deprecated/delicious.rb +1 -1
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +16 -14
- data/lib/nanoc/data_sources/deprecated/twitter.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +22 -20
- data/lib/nanoc/data_sources/filesystem_unified.rb +4 -5
- data/lib/nanoc/data_sources/filesystem_verbose.rb +2 -3
- data/lib/nanoc/data_sources/static.rb +2 -2
- data/lib/nanoc/extra/auto_compiler.rb +3 -3
- data/lib/nanoc/extra/checking/check.rb +3 -3
- data/lib/nanoc/extra/checking/checks/css.rb +2 -2
- data/lib/nanoc/extra/checking/checks/external_links.rb +9 -9
- data/lib/nanoc/extra/checking/checks/html.rb +2 -3
- data/lib/nanoc/extra/checking/checks/internal_links.rb +6 -7
- data/lib/nanoc/extra/checking/checks/stale.rb +6 -6
- data/lib/nanoc/extra/checking/dsl.rb +1 -1
- data/lib/nanoc/extra/checking/runner.rb +19 -19
- data/lib/nanoc/extra/chick.rb +11 -9
- data/lib/nanoc/extra/core_ext/pathname.rb +1 -2
- data/lib/nanoc/extra/core_ext/time.rb +2 -2
- data/lib/nanoc/extra/core_ext.rb +0 -1
- data/lib/nanoc/extra/deployer.rb +2 -2
- data/lib/nanoc/extra/deployers/fog.rb +12 -12
- data/lib/nanoc/extra/deployers/rsync.rb +6 -6
- data/lib/nanoc/extra/file_proxy.rb +1 -1
- data/lib/nanoc/extra/filesystem_tools.rb +5 -5
- data/lib/nanoc/extra/link_collector.rb +4 -3
- data/lib/nanoc/extra/pruner.rb +5 -5
- data/lib/nanoc/extra/validators/links.rb +3 -3
- data/lib/nanoc/extra/vcs.rb +1 -1
- data/lib/nanoc/filters/asciidoc.rb +3 -3
- data/lib/nanoc/filters/bluecloth.rb +1 -1
- data/lib/nanoc/filters/coderay.rb +2 -2
- data/lib/nanoc/filters/coffeescript.rb +2 -0
- data/lib/nanoc/filters/colorize_syntax.rb +16 -16
- data/lib/nanoc/filters/erb.rb +5 -5
- data/lib/nanoc/filters/erubis.rb +1 -1
- data/lib/nanoc/filters/haml.rb +1 -1
- data/lib/nanoc/filters/handlebars.rb +2 -2
- data/lib/nanoc/filters/kramdown.rb +1 -1
- data/lib/nanoc/filters/less.rb +1 -1
- data/lib/nanoc/filters/markaby.rb +1 -1
- data/lib/nanoc/filters/maruku.rb +1 -1
- data/lib/nanoc/filters/mustache.rb +1 -1
- data/lib/nanoc/filters/pandoc.rb +1 -1
- data/lib/nanoc/filters/rainpress.rb +1 -1
- data/lib/nanoc/filters/rdiscount.rb +1 -1
- data/lib/nanoc/filters/rdoc.rb +1 -1
- data/lib/nanoc/filters/redcarpet.rb +2 -2
- data/lib/nanoc/filters/redcloth.rb +9 -9
- data/lib/nanoc/filters/relativize_paths.rb +7 -8
- data/lib/nanoc/filters/rubypants.rb +1 -1
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
- data/lib/nanoc/filters/sass.rb +1 -1
- data/lib/nanoc/filters/slim.rb +1 -1
- data/lib/nanoc/filters/typogruby.rb +1 -1
- data/lib/nanoc/filters/uglify_js.rb +1 -1
- data/lib/nanoc/filters/xsl.rb +9 -7
- data/lib/nanoc/filters/yui_compressor.rb +2 -0
- data/lib/nanoc/helpers/blogging.rb +6 -6
- data/lib/nanoc/helpers/breadcrumbs.rb +1 -1
- data/lib/nanoc/helpers/capturing.rb +2 -2
- data/lib/nanoc/helpers/filtering.rb +1 -1
- data/lib/nanoc/helpers/html_escape.rb +3 -3
- data/lib/nanoc/helpers/link_to.rb +6 -6
- data/lib/nanoc/helpers/rendering.rb +2 -2
- data/lib/nanoc/helpers/tagging.rb +2 -2
- data/lib/nanoc/helpers/text.rb +1 -1
- data/lib/nanoc/helpers/xml_sitemap.rb +2 -2
- data/lib/nanoc/version.rb +1 -1
- data/lib/nanoc.rb +3 -2
- data/nanoc.gemspec +2 -6
- data/tasks/rubocop.rake +5 -0
- data/test/base/test_compiler_dsl.rb +20 -1
- data/test/cli/commands/test_compile.rb +4 -3
- data/test/cli/test_error_handler.rb +32 -0
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_less.rb +1 -1
- data/test/filters/test_xsl.rb +95 -8
- metadata +30 -84
data/lib/nanoc/filters/erb.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
3
|
module Nanoc::Filters
|
4
4
|
class ERB < Nanoc::Filter
|
@@ -15,7 +15,7 @@ module Nanoc::Filters
|
|
15
15
|
# @option params [String] trim_mode (nil) The trim mode to use
|
16
16
|
#
|
17
17
|
# @return [String] The filtered content
|
18
|
-
def run(content, params={})
|
18
|
+
def run(content, params = {})
|
19
19
|
# Add locals
|
20
20
|
assigns.merge!(params[:locals] || {})
|
21
21
|
|
@@ -23,7 +23,7 @@ module Nanoc::Filters
|
|
23
23
|
context = ::Nanoc::Context.new(assigns)
|
24
24
|
|
25
25
|
# Get binding
|
26
|
-
proc = assigns[:content] ? lambda { assigns[:content] } : nil
|
26
|
+
proc = assigns[:content] ? lambda { assigns[:content] } : nil
|
27
27
|
assigns_binding = context.get_binding(&proc)
|
28
28
|
|
29
29
|
# Get result
|
@@ -32,7 +32,7 @@ module Nanoc::Filters
|
|
32
32
|
erb = ::ERB.new(content, safe_level, trim_mode)
|
33
33
|
erb.filename = filename
|
34
34
|
erb.result(assigns_binding)
|
35
|
-
end
|
35
|
+
end
|
36
36
|
|
37
|
-
end
|
37
|
+
end
|
38
38
|
end
|
data/lib/nanoc/filters/erubis.rb
CHANGED
data/lib/nanoc/filters/haml.rb
CHANGED
@@ -15,12 +15,12 @@ module Nanoc::Filters
|
|
15
15
|
# @param [String] content The content to filter
|
16
16
|
#
|
17
17
|
# @return [String] The filtered content
|
18
|
-
def run(content, params={})
|
18
|
+
def run(content, params = {})
|
19
19
|
context = item.attributes.dup
|
20
20
|
context[:item] = assigns[:item].attributes
|
21
21
|
context[:config] = assigns[:config]
|
22
22
|
context[:yield] = assigns[:content]
|
23
|
-
if assigns.
|
23
|
+
if assigns.key?(:layout)
|
24
24
|
context[:layout] = assigns[:layout].attributes
|
25
25
|
end
|
26
26
|
|
@@ -11,7 +11,7 @@ module Nanoc::Filters
|
|
11
11
|
# @param [String] content The content to filter
|
12
12
|
#
|
13
13
|
# @return [String] The filtered content
|
14
|
-
def run(content, params={})
|
14
|
+
def run(content, params = {})
|
15
15
|
# Get result
|
16
16
|
::Kramdown::Document.new(content, params).to_html
|
17
17
|
end
|
data/lib/nanoc/filters/less.rb
CHANGED
@@ -11,7 +11,7 @@ module Nanoc::Filters
|
|
11
11
|
# @param [String] content The content to filter
|
12
12
|
#
|
13
13
|
# @return [String] The filtered content
|
14
|
-
def run(content, params={})
|
14
|
+
def run(content, params = {})
|
15
15
|
# Find imports (hacky)
|
16
16
|
imports = []
|
17
17
|
imports.concat(content.scan(/^@import\s+(["'])([^\1]+?)\1;/))
|
@@ -11,7 +11,7 @@ module Nanoc::Filters
|
|
11
11
|
# @param [String] content The content to filter
|
12
12
|
#
|
13
13
|
# @return [String] The filtered content
|
14
|
-
def run(content, params={})
|
14
|
+
def run(content, params = {})
|
15
15
|
# Get result
|
16
16
|
::Markaby::Builder.new(assigns).instance_eval(content).to_s
|
17
17
|
end
|
data/lib/nanoc/filters/maruku.rb
CHANGED
@@ -14,7 +14,7 @@ module Nanoc::Filters
|
|
14
14
|
# @param [String] content The content to filter
|
15
15
|
#
|
16
16
|
# @return [String] The filtered content
|
17
|
-
def run(content, params={})
|
17
|
+
def run(content, params = {})
|
18
18
|
context = item.attributes.merge({ :yield => assigns[:content] })
|
19
19
|
::Mustache.render(content, context)
|
20
20
|
end
|
data/lib/nanoc/filters/pandoc.rb
CHANGED
@@ -12,7 +12,7 @@ module Nanoc::Filters
|
|
12
12
|
# @param [String] content The content to filter
|
13
13
|
#
|
14
14
|
# @return [String] The filtered content
|
15
|
-
def run(content, params={})
|
15
|
+
def run(content, params = {})
|
16
16
|
extensions = params[:extensions] || []
|
17
17
|
|
18
18
|
::RDiscount.new(content, *extensions).to_html
|
data/lib/nanoc/filters/rdoc.rb
CHANGED
@@ -16,7 +16,7 @@ module Nanoc::Filters
|
|
16
16
|
# @param [String] content The content to filter
|
17
17
|
#
|
18
18
|
# @return [String] The filtered content
|
19
|
-
def run(content, params={})
|
19
|
+
def run(content, params = {})
|
20
20
|
options = ::RDoc::Options.new
|
21
21
|
to_html = ::RDoc::Markup::ToHtml.new(options)
|
22
22
|
::RDoc::Markup.new.convert(content, to_html)
|
@@ -20,7 +20,7 @@ module Nanoc::Filters
|
|
20
20
|
# Redcarpet
|
21
21
|
#
|
22
22
|
# @return [String] The filtered content
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# @overload run(content, params={})
|
25
25
|
#
|
26
26
|
# For Redcarpet 2.x
|
@@ -39,7 +39,7 @@ module Nanoc::Filters
|
|
39
39
|
# on to the Redcarpet renderer
|
40
40
|
#
|
41
41
|
# @return [String] The filtered content
|
42
|
-
def run(content, params={})
|
42
|
+
def run(content, params = {})
|
43
43
|
if ::Redcarpet::VERSION > '2'
|
44
44
|
options = params[:options] || {}
|
45
45
|
renderer_class = params[:renderer] || ::Redcarpet::Render::HTML
|
@@ -25,19 +25,19 @@ module Nanoc::Filters
|
|
25
25
|
# @param [String] content The content to filter
|
26
26
|
#
|
27
27
|
# @return [String] The filtered content
|
28
|
-
def run(content, params={})
|
28
|
+
def run(content, params = {})
|
29
29
|
# Create formatter
|
30
30
|
r = ::RedCloth.new(content)
|
31
31
|
|
32
32
|
# Set options
|
33
|
-
r.filter_classes = params[:filter_classes] if params.
|
34
|
-
r.filter_html = params[:filter_html] if params.
|
35
|
-
r.filter_ids = params[:filter_ids] if params.
|
36
|
-
r.filter_styles = params[:filter_styles] if params.
|
37
|
-
r.hard_breaks = params[:hard_breaks] if params.
|
38
|
-
r.lite_mode = params[:lite_mode] if params.
|
39
|
-
r.no_span_caps = params[:no_span_caps] if params.
|
40
|
-
r.sanitize_html = params[:sanitize_html] if params.
|
33
|
+
r.filter_classes = params[:filter_classes] if params.key?(:filter_classes)
|
34
|
+
r.filter_html = params[:filter_html] if params.key?(:filter_html)
|
35
|
+
r.filter_ids = params[:filter_ids] if params.key?(:filter_ids)
|
36
|
+
r.filter_styles = params[:filter_styles] if params.key?(:filter_styles)
|
37
|
+
r.hard_breaks = params[:hard_breaks] if params.key?(:hard_breaks)
|
38
|
+
r.lite_mode = params[:lite_mode] if params.key?(:lite_mode)
|
39
|
+
r.no_span_caps = params[:no_span_caps] if params.key?(:no_span_caps)
|
40
|
+
r.sanitize_html = params[:sanitize_html] if params.key?(:sanitize_html)
|
41
41
|
|
42
42
|
# Get result
|
43
43
|
r.to_html
|
@@ -24,11 +24,11 @@ module Nanoc::Filters
|
|
24
24
|
# `:xhtml` types.
|
25
25
|
#
|
26
26
|
# @option params [Hash] :namespaces The pairs `prefix => uri` to define
|
27
|
-
# any namespace you want to use in the XPath expressions. This param
|
27
|
+
# any namespace you want to use in the XPath expressions. This param
|
28
28
|
# is useful only for the `:xml` and `:xhtml` types.
|
29
29
|
#
|
30
30
|
# @return [String] The filtered content
|
31
|
-
def run(content, params={})
|
31
|
+
def run(content, params = {})
|
32
32
|
# Set assigns so helper function can be used
|
33
33
|
@item_rep = assigns[:item_rep] if @item_rep.nil?
|
34
34
|
|
@@ -61,9 +61,9 @@ module Nanoc::Filters
|
|
61
61
|
nokogiri_process(content, selectors, namespaces, klass, params[:type])
|
62
62
|
else
|
63
63
|
raise RuntimeError.new(
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
'The relativize_paths needs to know the type of content to ' +
|
65
|
+
'process. Pass a :type to the filter call (:html for HTML, ' +
|
66
|
+
':xhtml for XHTML, :xml for XML, or :css for CSS).')
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -71,7 +71,7 @@ module Nanoc::Filters
|
|
71
71
|
|
72
72
|
def nokogiri_process(content, selectors, namespaces, klass, type)
|
73
73
|
# Ensure that all prefixes are strings
|
74
|
-
namespaces = namespaces.
|
74
|
+
namespaces = namespaces.reduce({}) { |new, (prefix, uri)| new.merge(prefix.to_s => uri) }
|
75
75
|
|
76
76
|
doc = content =~ /<html[\s>]/ ? klass.parse(content) : klass.fragment(content)
|
77
77
|
selectors.map { |sel| "descendant-or-self::#{sel}" }.each do |selector|
|
@@ -94,9 +94,8 @@ module Nanoc::Filters
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def path_is_relativizable?(s)
|
97
|
-
s[0,1] == '/'
|
97
|
+
s[0, 1] == '/'
|
98
98
|
end
|
99
99
|
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
@@ -6,7 +6,7 @@ class ::Sass::Importers::Filesystem
|
|
6
6
|
|
7
7
|
def _find(dir, name, options)
|
8
8
|
# Find filename
|
9
|
-
full_filename,
|
9
|
+
full_filename, _syntax = ::Sass::Util.destructure(find_real_file(dir, name, options))
|
10
10
|
return nil if full_filename.nil?
|
11
11
|
|
12
12
|
# Create dependency
|
data/lib/nanoc/filters/sass.rb
CHANGED
@@ -11,7 +11,7 @@ module Nanoc::Filters
|
|
11
11
|
# @param [String] content The content to filter
|
12
12
|
#
|
13
13
|
# @return [String] The filtered content
|
14
|
-
def run(content, params={})
|
14
|
+
def run(content, params = {})
|
15
15
|
options = params.merge({
|
16
16
|
:nanoc_current_filter => self,
|
17
17
|
:filename => @item && @item.raw_filename,
|
data/lib/nanoc/filters/slim.rb
CHANGED
@@ -13,7 +13,7 @@ module Nanoc::Filters
|
|
13
13
|
# @param [String] content The content to filter
|
14
14
|
#
|
15
15
|
# @return [String] The filtered content
|
16
|
-
def run(content, params={})
|
16
|
+
def run(content, params = {})
|
17
17
|
params = {
|
18
18
|
:disable_capture => true, # Capture managed by nanoc
|
19
19
|
:buffer => '_erbout', # Force slim to output to the buffer used by nanoc
|
@@ -13,7 +13,7 @@ module Nanoc::Filters
|
|
13
13
|
# @option params [Array] :options ([]) A list of options to pass on to Uglifier
|
14
14
|
#
|
15
15
|
# @return [String] The filtered content
|
16
|
-
def run(content, params={})
|
16
|
+
def run(content, params = {})
|
17
17
|
# Add filename to load path
|
18
18
|
Uglifier.new(params).compile(content)
|
19
19
|
end
|
data/lib/nanoc/filters/xsl.rb
CHANGED
@@ -7,7 +7,7 @@ module Nanoc::Filters
|
|
7
7
|
|
8
8
|
requires 'nokogiri'
|
9
9
|
|
10
|
-
# Runs the item content through an [XSLT](http://www.w3.org/TR/xslt)
|
10
|
+
# Runs the item content through an [XSLT](http://www.w3.org/TR/xslt)
|
11
11
|
# stylesheet using [Nokogiri](http://nokogiri.org/).
|
12
12
|
#
|
13
13
|
# This filter can only be run for layouts, because it will need both the
|
@@ -22,24 +22,26 @@ module Nanoc::Filters
|
|
22
22
|
# compile '/reports/*/' do
|
23
23
|
# layout 'xsl-report'
|
24
24
|
# end
|
25
|
-
#
|
25
|
+
#
|
26
26
|
# layout 'xsl-report', :xsl, :awesome => 'definitely'
|
27
27
|
#
|
28
|
-
# @param [String] content
|
28
|
+
# @param [String] content Ignored. As the filter can be run only as a
|
29
|
+
# layout, the value of the `:content` parameter passed to the class at
|
30
|
+
# initialization is used as the content to transform.
|
29
31
|
#
|
30
32
|
# @param [Hash] params The parameters that will be stored in corresponding
|
31
33
|
# `xsl:param` elements.
|
32
34
|
#
|
33
35
|
# @return [String] The transformed content
|
34
|
-
def run(content, params={})
|
36
|
+
def run(content, params = {})
|
35
37
|
if assigns[:layout].nil?
|
36
|
-
raise
|
38
|
+
raise 'The XSL filter can only be run as a layout'
|
37
39
|
end
|
38
40
|
|
39
|
-
xml = ::Nokogiri::XML(content)
|
41
|
+
xml = ::Nokogiri::XML(assigns[:content])
|
40
42
|
xsl = ::Nokogiri::XSLT(assigns[:layout].raw_content)
|
41
43
|
|
42
|
-
xsl.
|
44
|
+
xsl.apply_to(xml, ::Nokogiri::XSLT.quote_params(params))
|
43
45
|
end
|
44
46
|
|
45
47
|
end
|
@@ -64,15 +64,15 @@ module Nanoc::Helpers
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def validate
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
validate_config
|
68
|
+
validate_feed_item
|
69
|
+
validate_articles
|
70
70
|
end
|
71
71
|
|
72
72
|
def build
|
73
73
|
buffer = ''
|
74
74
|
xml = Builder::XmlMarkup.new(:target => buffer, :indent => 2)
|
75
|
-
|
75
|
+
build_for_feed(xml)
|
76
76
|
buffer
|
77
77
|
end
|
78
78
|
|
@@ -143,7 +143,7 @@ module Nanoc::Helpers
|
|
143
143
|
|
144
144
|
# Add articles
|
145
145
|
sorted_relevant_articles.each do |a|
|
146
|
-
|
146
|
+
build_for_article(a, xml)
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
@@ -289,7 +289,7 @@ module Nanoc::Helpers
|
|
289
289
|
# @option params [String] :logo The URI of the feed's logo.
|
290
290
|
#
|
291
291
|
# @return [String] The generated feed content
|
292
|
-
def atom_feed(params={})
|
292
|
+
def atom_feed(params = {})
|
293
293
|
require 'builder'
|
294
294
|
|
295
295
|
# Create builder
|
@@ -101,7 +101,7 @@ module Nanoc::Helpers
|
|
101
101
|
if block_given? # Set content
|
102
102
|
# Get args
|
103
103
|
if args.size != 1
|
104
|
-
raise ArgumentError,
|
104
|
+
raise ArgumentError, 'expected 1 argument (the name ' +
|
105
105
|
"of the capture) but got #{args.size} instead"
|
106
106
|
end
|
107
107
|
name = args[0]
|
@@ -112,7 +112,7 @@ module Nanoc::Helpers
|
|
112
112
|
else # Get content
|
113
113
|
# Get args
|
114
114
|
if args.size != 2
|
115
|
-
raise ArgumentError,
|
115
|
+
raise ArgumentError, 'expected 2 arguments (the item ' +
|
116
116
|
"and the name of the capture) but got #{args.size} instead"
|
117
117
|
end
|
118
118
|
item = args[0]
|
@@ -28,7 +28,7 @@ module Nanoc::Helpers
|
|
28
28
|
# @param [String] string The string to escape
|
29
29
|
#
|
30
30
|
# @return [String] The escaped string
|
31
|
-
def html_escape(string=nil, &block)
|
31
|
+
def html_escape(string = nil, &block)
|
32
32
|
if block_given?
|
33
33
|
# Capture and escape block
|
34
34
|
data = capture(&block)
|
@@ -43,12 +43,12 @@ module Nanoc::Helpers
|
|
43
43
|
gsub('>', '>').
|
44
44
|
gsub('"', '"')
|
45
45
|
else
|
46
|
-
raise
|
46
|
+
raise "The #html_escape or #h function needs either a " \
|
47
47
|
"string or a block to HTML-escape, but neither a string nor a block was given"
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
alias_method :h, :html_escape
|
52
52
|
|
53
53
|
end
|
54
54
|
|
@@ -45,17 +45,17 @@ module Nanoc::Helpers
|
|
45
45
|
#
|
46
46
|
# link_to('Blog', '/blog/', :title => 'My super cool blog')
|
47
47
|
# # => '<a title="My super cool blog" href="/blog/">Blog</a>'
|
48
|
-
def link_to(text, target, attributes={})
|
48
|
+
def link_to(text, target, attributes = {})
|
49
49
|
# Find path
|
50
50
|
if target.is_a?(String)
|
51
51
|
path = target
|
52
52
|
else
|
53
53
|
path = target.path
|
54
|
-
raise
|
54
|
+
raise "Cannot create a link to #{target.inspect} because this target is not outputted (its routing rule returns nil)" if path.nil?
|
55
55
|
end
|
56
56
|
|
57
57
|
# Join attributes
|
58
|
-
attributes = attributes.
|
58
|
+
attributes = attributes.reduce('') do |memo, (key, value)|
|
59
59
|
memo + key.to_s + '="' + h(value) + '" '
|
60
60
|
end
|
61
61
|
|
@@ -87,7 +87,7 @@ module Nanoc::Helpers
|
|
87
87
|
#
|
88
88
|
# link_to_unless_current('This Item', @item)
|
89
89
|
# # => '<span class="active" title="You\'re here.">This Item</span>'
|
90
|
-
def link_to_unless_current(text, target, attributes={})
|
90
|
+
def link_to_unless_current(text, target, attributes = {})
|
91
91
|
# Find path
|
92
92
|
path = target.is_a?(String) ? target : target.path
|
93
93
|
|
@@ -140,14 +140,14 @@ module Nanoc::Helpers
|
|
140
140
|
|
141
141
|
# Calculate the relative path (method depends on whether destination is
|
142
142
|
# a directory or not).
|
143
|
-
if src_path.to_s[-1,1] != '/'
|
143
|
+
if src_path.to_s[-1, 1] != '/'
|
144
144
|
relative_path = dst_path.relative_path_from(src_path.dirname).to_s
|
145
145
|
else
|
146
146
|
relative_path = dst_path.relative_path_from(src_path).to_s
|
147
147
|
end
|
148
148
|
|
149
149
|
# Add trailing slash if necessary
|
150
|
-
if dst_path.to_s[-1,1] == '/'
|
150
|
+
if dst_path.to_s[-1, 1] == '/'
|
151
151
|
relative_path << '/'
|
152
152
|
end
|
153
153
|
|
@@ -38,7 +38,7 @@ module Nanoc::Helpers
|
|
38
38
|
# @example Rendering a head and a foot partial around some text
|
39
39
|
#
|
40
40
|
# <%= render 'head' %> - MIDDLE - <%= render 'foot' %>
|
41
|
-
# # => "HEAD - MIDDLE - FOOT"
|
41
|
+
# # => "HEAD - MIDDLE - FOOT"
|
42
42
|
#
|
43
43
|
# @example Rendering a head partial with a custom title
|
44
44
|
#
|
@@ -77,7 +77,7 @@ module Nanoc::Helpers
|
|
77
77
|
#
|
78
78
|
# @return [String, nil] The rendered partial, or nil if this method was
|
79
79
|
# invoked with a block
|
80
|
-
def render(identifier, other_assigns={}, &block)
|
80
|
+
def render(identifier, other_assigns = {}, &block)
|
81
81
|
# Find layout
|
82
82
|
layout = @site.layouts.find { |l| l.identifier == identifier.cleaned_identifier }
|
83
83
|
raise Nanoc::Errors::UnknownLayout.new(identifier.cleaned_identifier) if layout.nil?
|
@@ -30,12 +30,12 @@ module Nanoc::Helpers
|
|
30
30
|
# tags
|
31
31
|
#
|
32
32
|
# @return [String] A hyperlinked list of tags for the given item
|
33
|
-
def tags_for(item, params={})
|
33
|
+
def tags_for(item, params = {})
|
34
34
|
base_url = params[:base_url] || 'http://technorati.com/tag/'
|
35
35
|
none_text = params[:none_text] || '(none)'
|
36
36
|
separator = params[:separator] || ', '
|
37
37
|
|
38
|
-
if item[:tags].nil?
|
38
|
+
if item[:tags].nil? || item[:tags].empty?
|
39
39
|
none_text
|
40
40
|
else
|
41
41
|
item[:tags].map { |tag| link_for_tag(tag, base_url) }.join(separator)
|
data/lib/nanoc/helpers/text.rb
CHANGED
@@ -18,7 +18,7 @@ module Nanoc::Helpers
|
|
18
18
|
# excerpt when the excerpt is shorter than the original string
|
19
19
|
#
|
20
20
|
# @return [String] The excerpt of the given string
|
21
|
-
def excerptize(string, params={})
|
21
|
+
def excerptize(string, params = {})
|
22
22
|
# Initialize params
|
23
23
|
params[:length] ||= 25
|
24
24
|
params[:omission] ||= '...'
|
@@ -39,7 +39,7 @@ module Nanoc::Helpers
|
|
39
39
|
# proc returns true, the rep will be included; otherwise, it will not.
|
40
40
|
#
|
41
41
|
# @return [String] The XML sitemap
|
42
|
-
def xml_sitemap(params={})
|
42
|
+
def xml_sitemap(params = {})
|
43
43
|
require 'builder'
|
44
44
|
|
45
45
|
# Extract parameters
|
@@ -52,7 +52,7 @@ module Nanoc::Helpers
|
|
52
52
|
|
53
53
|
# Check for required attributes
|
54
54
|
if @site.config[:base_url].nil?
|
55
|
-
raise RuntimeError.new(
|
55
|
+
raise RuntimeError.new('The Nanoc::Helpers::XMLSitemap helper requires the site configuration to specify the base URL for the site.')
|
56
56
|
end
|
57
57
|
|
58
58
|
# Build sitemap
|
data/lib/nanoc/version.rb
CHANGED
data/lib/nanoc.rb
CHANGED
@@ -5,8 +5,8 @@ module Nanoc
|
|
5
5
|
# @return [String] A string containing information about this nanoc version
|
6
6
|
# and its environment (Ruby engine and version, Rubygems version if any).
|
7
7
|
def self.version_information
|
8
|
-
gem_info = defined?(Gem) ? "with RubyGems #{Gem::VERSION}" :
|
9
|
-
engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE :
|
8
|
+
gem_info = defined?(Gem) ? "with RubyGems #{Gem::VERSION}" : 'without RubyGems'
|
9
|
+
engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
10
10
|
res = ''
|
11
11
|
res << "nanoc #{Nanoc::VERSION} © 2007-2013 Denis Defreyne.\n"
|
12
12
|
res << "Running #{engine} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} #{gem_info}.\n"
|
@@ -34,6 +34,7 @@ require 'tempfile'
|
|
34
34
|
require 'thread'
|
35
35
|
require 'time'
|
36
36
|
require 'yaml'
|
37
|
+
require 'English'
|
37
38
|
|
38
39
|
# Load nanoc
|
39
40
|
require 'nanoc/version'
|
data/nanoc.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.license = 'MIT'
|
16
16
|
|
17
17
|
s.files = Dir['[A-Z]*'] +
|
18
|
-
Dir['doc/
|
18
|
+
Dir['doc/yardoc_{templates,handlers}/**/*'] +
|
19
19
|
Dir['{bin,lib,tasks,test}/**/*'] +
|
20
20
|
[ 'nanoc.gemspec' ]
|
21
21
|
s.executables = [ 'nanoc' ]
|
@@ -26,9 +26,5 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_runtime_dependency('cri', '~> 2.3')
|
28
28
|
|
29
|
-
s.add_development_dependency('
|
30
|
-
s.add_development_dependency('mocha')
|
31
|
-
s.add_development_dependency('rake')
|
32
|
-
s.add_development_dependency('rdiscount')
|
33
|
-
s.add_development_dependency('yard')
|
29
|
+
s.add_development_dependency('bundler', '~> 1.5')
|
34
30
|
end
|