nanoc 3.3.4 → 3.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -19,6 +19,7 @@ gem 'mustache'
19
19
  gem 'nokogiri'
20
20
  gem 'pygments.rb'
21
21
  gem 'rack'
22
+ gem 'rake'
22
23
  gem 'rainpress'
23
24
  gem 'rdiscount'
24
25
  gem 'rdoc'
data/NEWS.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # nanoc news
2
2
 
3
+ ## 3.3.5 (2012-04-23)
4
+
5
+ * Fixed issue with relative_link_to not working properly
6
+
3
7
  ## 3.3.4 (2012-04-23)
4
8
 
5
9
  * Fixed bug which caused the compilation stack to be empty
@@ -67,7 +67,7 @@ module Nanoc::Filters
67
67
  end
68
68
  end
69
69
 
70
- private
70
+ protected
71
71
 
72
72
  def nokogiri_process(content, selectors, namespaces, klass, type)
73
73
  # Ensure that all prefixes are strings
@@ -76,18 +76,27 @@ module Nanoc::Filters
76
76
  doc = klass.fragment(content)
77
77
  selectors.map { |sel| "descendant-or-self::#{sel}" }.each do |selector|
78
78
  doc.xpath(selector, namespaces).each do |node|
79
- node.content = relative_path_to(node.content)
79
+ if self.path_is_relativizable?(node.content)
80
+ node.content = relative_path_to(node.content)
81
+ end
80
82
  end
81
83
  end
82
84
  result = doc.send("to_#{type}")
83
85
 
84
86
  # FIXME cleanup because it is ugly
85
- # Because using the `Nokogiri::XML::DocumentFragment` class DOCTYPE
87
+ # # Because using the `Nokogiri::XML::DocumentFragment` class DOCTYPE
86
88
  # pseudonodes becomes even more creepy than usual.
87
89
  result.sub!(/(!DOCTYPE.+?)(&gt;)/, '<\1>')
88
90
 
89
91
  result
90
92
  end
91
93
 
94
+ def path_is_relativizable?(s)
95
+ require 'uri'
96
+ return false if s =~ URI.regexp
97
+ return false if s[0,1] == '#'
98
+ return true
99
+ end
100
+
92
101
  end
93
102
  end
@@ -121,7 +121,9 @@ module Nanoc::Helpers
121
121
  path = target
122
122
  else
123
123
  path = target.path
124
- raise RuntimeError, "Cannot get the relative path to #{target.inspect} because this target is not outputted (its routing rule returns nil)" if path.nil?
124
+ if path.nil?
125
+ raise "Cannot get the relative path to #{target.inspect} because this target is not outputted (its routing rule returns nil)"
126
+ end
125
127
  end
126
128
 
127
129
  # Handle Windows network (UNC) paths
@@ -131,7 +133,9 @@ module Nanoc::Helpers
131
133
 
132
134
  # Get source and destination paths
133
135
  dst_path = Pathname.new(path)
134
- raise RuntimeError, "Cannot get the relative path to #{path} because the current item representation, #{@item_rep.inspect}, is not outputted (its routing rule returns nil)" if @item_rep.path.nil?
136
+ if @item_rep.path.nil?
137
+ raise "Cannot get the relative path to #{path} because the current item representation, #{@item_rep.inspect}, is not outputted (its routing rule returns nil)"
138
+ end
135
139
  src_path = Pathname.new(@item_rep.path)
136
140
 
137
141
  # Calculate the relative path (method depends on whether destination is
data/lib/nanoc.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Nanoc
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.3.4'
6
+ VERSION = '3.3.5'
7
7
 
8
8
  # @return [String] A string containing information about this nanoc version
9
9
  # and its environment (Ruby engine and version, Rubygems version if any).
@@ -197,6 +197,54 @@ class Nanoc::Filters::RelativizePathsTest < MiniTest::Unit::TestCase
197
197
  assert_equal(expected_content, actual_content)
198
198
  end
199
199
 
200
+ def test_filter_html_with_anchor
201
+ # Create filter with mock item
202
+ filter = Nanoc::Filters::RelativizePaths.new
203
+
204
+ # Mock item
205
+ filter.instance_eval do
206
+ @item_rep = Nanoc::ItemRep.new(
207
+ Nanoc::Item.new(
208
+ 'content',
209
+ {},
210
+ '/foo/bar/baz/'),
211
+ :blah)
212
+ @item_rep.path = '/woof/meow/'
213
+ end
214
+
215
+ # Set content
216
+ raw_content = %[<a href="#max-payne">Max Payne</a>]
217
+ expected_content = %[<a href="#max-payne">Max Payne</a>]
218
+
219
+ # Test
220
+ actual_content = filter.run(raw_content, :type => :html)
221
+ assert_equal(expected_content, actual_content)
222
+ end
223
+
224
+ def test_filter_html_with_url
225
+ # Create filter with mock item
226
+ filter = Nanoc::Filters::RelativizePaths.new
227
+
228
+ # Mock item
229
+ filter.instance_eval do
230
+ @item_rep = Nanoc::ItemRep.new(
231
+ Nanoc::Item.new(
232
+ 'content',
233
+ {},
234
+ '/foo/bar/baz/'),
235
+ :blah)
236
+ @item_rep.path = '/woof/meow/'
237
+ end
238
+
239
+ # Set content
240
+ raw_content = %[<a href="http://example.com/">Example</a>]
241
+ expected_content = %[<a href="http://example.com/">Example</a>]
242
+
243
+ # Test
244
+ actual_content = filter.run(raw_content, :type => :html)
245
+ assert_equal(expected_content, actual_content)
246
+ end
247
+
200
248
  def test_filter_implicit
201
249
  # Create filter with mock item
202
250
  filter = Nanoc::Filters::RelativizePaths.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.4
4
+ version: 3.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -123,7 +123,6 @@ extra_rdoc_files:
123
123
  files:
124
124
  - ChangeLog
125
125
  - Gemfile
126
- - Gemfile.lock
127
126
  - LICENSE
128
127
  - NEWS.md
129
128
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,135 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- nanoc (3.3.4)
5
- cri (~> 2.2)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- RedCloth (4.2.9)
11
- albino (1.3.3)
12
- posix-spawn (>= 0.3.6)
13
- blankslate (2.1.2.4)
14
- bluecloth (2.2.0)
15
- builder (3.0.0)
16
- coderay (1.0.6)
17
- coffee-script (2.2.0)
18
- coffee-script-source
19
- execjs
20
- coffee-script-source (1.2.0)
21
- commonjs (0.2.5)
22
- cri (2.2.1)
23
- erubis (2.7.0)
24
- excon (0.13.4)
25
- execjs (1.3.0)
26
- multi_json (~> 1.0)
27
- ffi (1.0.11)
28
- fog (1.3.1)
29
- builder
30
- excon (~> 0.13.0)
31
- formatador (~> 0.2.0)
32
- mime-types
33
- multi_json (~> 1.0)
34
- net-scp (~> 1.0.4)
35
- net-ssh (>= 2.1.3)
36
- nokogiri (~> 1.5.0)
37
- ruby-hmac
38
- formatador (0.2.1)
39
- haml (3.1.4)
40
- json (1.6.6)
41
- kramdown (0.13.5)
42
- less (2.1.0)
43
- commonjs (~> 0.2.0)
44
- therubyracer (~> 0.10.0)
45
- libv8 (3.3.10.4)
46
- markaby (0.7.2)
47
- builder (>= 2.0.0)
48
- maruku (0.6.0)
49
- syntax (>= 1.0.0)
50
- metaclass (0.0.1)
51
- mime-types (1.18)
52
- minitest (2.12.0)
53
- mocha (0.10.5)
54
- metaclass (~> 0.0.1)
55
- multi_json (1.2.0)
56
- mustache (0.99.4)
57
- net-scp (1.0.4)
58
- net-ssh (>= 1.99.1)
59
- net-ssh (2.3.0)
60
- nokogiri (1.5.2)
61
- posix-spawn (0.3.6)
62
- pygments.rb (0.2.12)
63
- rubypython (~> 0.5.3)
64
- rack (1.4.1)
65
- rainpress (1.0)
66
- rake (0.9.2.2)
67
- rdiscount (1.6.8)
68
- rdoc (3.12)
69
- json (~> 1.4)
70
- redcarpet (2.1.1)
71
- ruby-hmac (0.4.0)
72
- rubypants (0.2.0)
73
- rubypython (0.5.3)
74
- blankslate (>= 2.1.2.3)
75
- ffi (~> 1.0.7)
76
- sass (3.1.15)
77
- slim (1.2.0)
78
- temple (~> 0.4.0)
79
- tilt (~> 1.3.3)
80
- syntax (1.0.0)
81
- systemu (2.5.0)
82
- temple (0.4.0)
83
- therubyracer (0.10.1)
84
- libv8 (~> 3.3.10)
85
- tilt (1.3.3)
86
- typogruby (1.0.15)
87
- rubypants
88
- uglifier (1.2.4)
89
- execjs (>= 0.3.0)
90
- multi_json (>= 1.0.2)
91
- w3c_validators (1.2)
92
- json
93
- nokogiri
94
- yard (0.7.5)
95
- yuicompressor (1.2.0)
96
-
97
- PLATFORMS
98
- ruby
99
-
100
- DEPENDENCIES
101
- RedCloth
102
- albino
103
- bluecloth
104
- builder
105
- coderay
106
- coffee-script
107
- erubis
108
- fog
109
- haml
110
- kramdown
111
- less (~> 2.0)
112
- markaby
113
- maruku
114
- mime-types
115
- minitest
116
- mocha
117
- mustache
118
- nanoc!
119
- nokogiri
120
- pygments.rb
121
- rack
122
- rainpress
123
- rake
124
- rdiscount
125
- rdoc
126
- redcarpet
127
- rubypants
128
- sass (~> 3.1)
129
- slim
130
- systemu
131
- typogruby
132
- uglifier
133
- w3c_validators
134
- yard
135
- yuicompressor