gumdrop 0.7.3.1 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +4 -0
- data/lib/gumdrop/content.rb +19 -1
- data/lib/gumdrop/context.rb +6 -2
- data/lib/gumdrop/site.rb +2 -1
- data/lib/gumdrop/version.rb +1 -1
- data/specs/content_spec.rb +45 -4
- data/specs/fixtures/expected/posts/post1.html +1 -0
- data/specs/fixtures/expected/posts/post1.js +14 -0
- data/specs/fixtures/expected/posts/post2.html +5 -0
- data/specs/fixtures/expected/sub/sub/sub/test.html +5 -0
- data/specs/fixtures/expected/sub/sub/sub/test2.html +5 -0
- data/specs/fixtures/{expected-test.js → expected/test.js} +0 -0
- data/specs/fixtures/source/Gumdrop +13 -0
- data/specs/fixtures/source/posts/post1.html.slim +6 -0
- data/specs/fixtures/source/posts/post1.js.coffee +3 -0
- data/specs/fixtures/source/posts/post2.html.erb +5 -0
- data/specs/fixtures/source/sub/sub/sub/test.html +5 -0
- data/specs/fixtures/source/sub/sub/sub/test2.html.erb +5 -0
- data/specs/fixtures/{test.js.coffee → source/test.js.coffee} +0 -0
- data/specs/fixtures/{test.js.erb.coffee → source/test.js.erb.coffee} +0 -0
- metadata +16 -7
- data/specs/fixtures/Gumdrop +0 -0
data/ChangeLog.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# v0.7.4
|
2
|
+
- All rendered content (including layouts) will relativize paths starting with / on href="" and src="" for html files. Can be set to array of file exts to process at `config.relative_paths_for= ['.html']` or sett to process all files `config.relative_paths_for= :all` or turned off entirely by `config.relative_paths= false`
|
3
|
+
- Proxy server is disabled by default. Enable it `configure.proxy = true`
|
4
|
+
|
1
5
|
# v0.7.3
|
2
6
|
- Bugfix: Correctly runs content through multiple processors (when multiple are specified in the filename. ie: test.js.erb.coffee gets sent through CoffeeScript then erb)
|
3
7
|
|
data/lib/gumdrop/content.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
module Gumdrop
|
3
3
|
|
4
4
|
class Content
|
5
|
+
|
6
|
+
MUNGABLE_RE= Regexp.new(%Q<(href|data|src)([\s]*)=([\s]*)('|"|"|"|')?\\/([\\/]?)>, 'i')
|
5
7
|
|
6
8
|
attr_accessor :path,
|
7
9
|
:level,
|
@@ -53,7 +55,7 @@ module Gumdrop
|
|
53
55
|
content = layout.template.render(context, content:content) { content }
|
54
56
|
layout= context.get_template()
|
55
57
|
end
|
56
|
-
content
|
58
|
+
relativize content, context
|
57
59
|
end
|
58
60
|
|
59
61
|
def renderTo(context, output_path, filters=[], opts={})
|
@@ -149,6 +151,22 @@ module Gumdrop
|
|
149
151
|
uri
|
150
152
|
end
|
151
153
|
end
|
154
|
+
|
155
|
+
def relativize(content, ctx)
|
156
|
+
if site.config.relative_paths
|
157
|
+
if site.config.relative_paths_for == :all or site.config.relative_paths_for.include?(@ext)
|
158
|
+
path_to_root= ctx.path_to_root
|
159
|
+
content = content.gsub MUNGABLE_RE do |match|
|
160
|
+
if $5 == '/'
|
161
|
+
"#{ $1 }#{ $2 }=#{ $3 }#{ $4 }/"
|
162
|
+
else
|
163
|
+
"#{ $1 }#{ $2 }=#{ $3 }#{ $4 }#{ path_to_root }"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
content
|
169
|
+
end
|
152
170
|
|
153
171
|
end
|
154
172
|
|
data/lib/gumdrop/context.rb
CHANGED
@@ -14,9 +14,9 @@ module Gumdrop
|
|
14
14
|
def uri(path, opts={})
|
15
15
|
path= path[1..-1] if path.starts_with?('/') # and path != "/"
|
16
16
|
uri_string= if !@site.config.relative_paths or force_absolute
|
17
|
-
"/#{path}"
|
17
|
+
"/#{ path }"
|
18
18
|
else
|
19
|
-
"#{
|
19
|
+
"#{ path_to_root }#{ path }"
|
20
20
|
end
|
21
21
|
if opts[:fresh] and @site.node_tree.has_key?(path)
|
22
22
|
uri_string += "?v=#{ @site.node_tree[path].mtime.to_i }"
|
@@ -24,6 +24,10 @@ module Gumdrop
|
|
24
24
|
uri_string = "/" if uri_string == ""
|
25
25
|
uri_string
|
26
26
|
end
|
27
|
+
|
28
|
+
def path_to_root
|
29
|
+
'../' * @state['current_depth']
|
30
|
+
end
|
27
31
|
|
28
32
|
def url(path)
|
29
33
|
path= path[1..-1] if path.starts_with?('/')
|
data/lib/gumdrop/site.rb
CHANGED
data/lib/gumdrop/version.rb
CHANGED
data/specs/content_spec.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require 'minitest/spec'
|
2
2
|
require 'minitest/autorun'
|
3
3
|
require 'gumdrop'
|
4
|
+
#require File.join File.dirname(__FILE__), 'diff.rb'
|
5
|
+
|
6
|
+
fixture_src_path= File.join ".", "specs", "fixtures", "source"
|
7
|
+
fixture_exp_path= File.join ".", "specs", "fixtures", "expected"
|
8
|
+
|
9
|
+
def get_test_site
|
10
|
+
site= Gumdrop::Site.new File.join(".", "specs", "fixtures", "source", 'Gumdrop'), :quiet=>true
|
11
|
+
site.rescan
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_expected(filename)
|
15
|
+
path= File.join ".", "specs", "fixtures", "expected", filename
|
16
|
+
File.read path
|
17
|
+
end
|
4
18
|
|
5
19
|
describe Gumdrop::Content do
|
6
20
|
# before do
|
@@ -9,13 +23,15 @@ describe Gumdrop::Content do
|
|
9
23
|
|
10
24
|
it "should process the content through all the engines specified in the file ext" do
|
11
25
|
|
12
|
-
path= File.join
|
13
|
-
site= Gumdrop::Site.new path
|
26
|
+
# path= File.join fixture_src_path, 'Gumdrop'
|
27
|
+
# site= Gumdrop::Site.new path, :quiet=>true
|
28
|
+
# site.rescan
|
29
|
+
site= get_test_site
|
14
30
|
|
15
|
-
path= File.join
|
31
|
+
path= File.join fixture_src_path, 'test.js.erb.coffee'
|
16
32
|
content= Gumdrop::Content.new( path, site )
|
17
33
|
|
18
|
-
path= File.join
|
34
|
+
path= File.join fixture_exp_path, 'test.js'
|
19
35
|
expected= File.read path
|
20
36
|
|
21
37
|
content= content.render()
|
@@ -24,7 +40,32 @@ describe Gumdrop::Content do
|
|
24
40
|
# puts expected
|
25
41
|
|
26
42
|
content.must_equal expected
|
43
|
+
end
|
27
44
|
|
45
|
+
it "should relativize all absolute paths (when starts with /)" do
|
46
|
+
site= get_test_site
|
47
|
+
# puts site.node_tree.keys
|
48
|
+
|
49
|
+
page= site.contents('posts/post1.html').first
|
50
|
+
content= page.render
|
51
|
+
expected= get_expected('posts/post1.html')
|
52
|
+
# puts content
|
53
|
+
content.must_equal expected
|
54
|
+
|
55
|
+
page= site.contents('posts/post1.js').first
|
56
|
+
content= page.render
|
57
|
+
# puts content
|
58
|
+
content.must_equal get_expected('posts/post1.js')
|
59
|
+
|
60
|
+
page= site.contents('sub/sub/sub/test.html').first
|
61
|
+
content= page.render
|
62
|
+
# puts content
|
63
|
+
content.must_equal get_expected('sub/sub/sub/test.html')
|
64
|
+
|
65
|
+
page= site.contents('sub/sub/sub/test2.html').first
|
66
|
+
content= page.render
|
67
|
+
# puts content
|
68
|
+
content.must_equal get_expected('sub/sub/sub/test2.html')
|
28
69
|
end
|
29
70
|
|
30
71
|
# it "can be created with no arguments" do
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>My First Post</h1><img src="../media/crap.png" /><p>Go to <a href="../about/hell">Hell</a></p>
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.7.3.1
|
8
|
+
- 4
|
9
|
+
version: 0.7.4
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Matt McCray
|
@@ -130,10 +129,20 @@ files:
|
|
130
129
|
- lib/gumdrop/view_helpers.rb
|
131
130
|
- specs/content_spec.rb
|
132
131
|
- specs/deferred_loader_spec.rb
|
133
|
-
- specs/fixtures/
|
134
|
-
- specs/fixtures/expected
|
135
|
-
- specs/fixtures/
|
136
|
-
- specs/fixtures/test.
|
132
|
+
- specs/fixtures/expected/posts/post1.html
|
133
|
+
- specs/fixtures/expected/posts/post1.js
|
134
|
+
- specs/fixtures/expected/posts/post2.html
|
135
|
+
- specs/fixtures/expected/sub/sub/sub/test.html
|
136
|
+
- specs/fixtures/expected/sub/sub/sub/test2.html
|
137
|
+
- specs/fixtures/expected/test.js
|
138
|
+
- specs/fixtures/source/Gumdrop
|
139
|
+
- specs/fixtures/source/posts/post1.html.slim
|
140
|
+
- specs/fixtures/source/posts/post1.js.coffee
|
141
|
+
- specs/fixtures/source/posts/post2.html.erb
|
142
|
+
- specs/fixtures/source/sub/sub/sub/test.html
|
143
|
+
- specs/fixtures/source/sub/sub/sub/test2.html.erb
|
144
|
+
- specs/fixtures/source/test.js.coffee
|
145
|
+
- specs/fixtures/source/test.js.erb.coffee
|
137
146
|
- specs/hash_object_spec.rb
|
138
147
|
- templates/backbone/Gemfile
|
139
148
|
- templates/backbone/Gumdrop
|
data/specs/fixtures/Gumdrop
DELETED
File without changes
|