middleman-more 3.0.0.rc.2 → 3.0.0.rc.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,22 @@ Feature: Built-in macro view helpers
6
6
  When I go to "/former_padrino_test.html"
7
7
  And I should see 'href="test2.com"'
8
8
  And I should see 'src="/images/test2.png"'
9
+ And I should see 'src="/images/100px.png"'
9
10
  And I should see 'src="/javascripts/test1.js"'
10
11
  And I should see 'href="/stylesheets/test1.css"'
11
12
  And I should see '1 KB'
13
+
14
+ Scenario: Setting http_prefix
15
+ Given a fixture app "padrino-helpers-app"
16
+ And a file named "config.rb" with:
17
+ """
18
+ set :http_prefix, "/foo"
19
+ """
20
+ And the Server is running at "padrino-helpers-app"
21
+ When I go to "/former_padrino_test.html"
22
+ And I should see 'src="/foo/images/test2.png"'
23
+ And I should see 'src="/foo/images/100px.png"'
24
+ And I should see 'src="/foo/javascripts/test1.js"'
25
+ And I should see 'href="/foo/stylesheets/test1.css"'
26
+
12
27
 
@@ -61,11 +61,11 @@ Feature: link_to helper
61
61
  """
62
62
  And the Server is running at "indexable-app"
63
63
  When I go to "/link_to/"
64
- Then I should see 'absolute: <a href="needs_index/">Needs Index</a>'
65
- Then I should see 'relative: <a href="needs_index/">Relative</a>'
66
- When I go to "/link_to/sub/"
67
64
  Then I should see 'absolute: <a href="../needs_index/">Needs Index</a>'
68
65
  Then I should see 'relative: <a href="../needs_index/">Relative</a>'
66
+ When I go to "/link_to/sub/"
67
+ Then I should see 'absolute: <a href="../../needs_index/">Needs Index</a>'
68
+ Then I should see 'relative: <a href="../../needs_index/">Relative</a>'
69
69
 
70
70
  Scenario: link_to can take a Resource
71
71
  Given a fixture app "indexable-app"
@@ -76,3 +76,18 @@ Feature: link_to helper
76
76
  And the Server is running at "indexable-app"
77
77
  When I go to "/link_to/"
78
78
  Then I should see '<a href="/needs_index/">Needs Index</a>'
79
+
80
+ Scenario: Setting http_prefix
81
+ Given a fixture app "indexable-app"
82
+ And a file named "config.rb" with:
83
+ """
84
+ set :http_prefix, "/foo"
85
+ """
86
+ And a file named "source/link_to.html.erb" with:
87
+ """
88
+ <%= link_to "Needs Index", "/needs_index.html" %>
89
+ """
90
+ And the Server is running at "indexable-app"
91
+ When I go to "/link_to.html"
92
+ Then I should see '<a href="/foo/needs_index.html">Needs Index</a>'
93
+
@@ -88,4 +88,15 @@ Feature: Relative Assets
88
88
  Given "relative_assets" feature is "enabled"
89
89
  And the Server is running at "fonts-app"
90
90
  When I go to "/stylesheets/fonts.css"
91
- Then I should see "url('../fonts/StMarie-Thin.otf"
91
+ Then I should see "url('../fonts/StMarie-Thin.otf"
92
+
93
+ Scenario: Relative assets via image_tag
94
+ Given a fixture app "relative-assets-app"
95
+ Given "relative_assets" feature is "enabled"
96
+ And a file named "source/sub/image_tag.html.erb" with:
97
+ """
98
+ <%= image_tag '/img/blank.gif' %>
99
+ """
100
+ And the Server is running at "relative-assets-app"
101
+ When I go to "/sub/image_tag.html"
102
+ Then I should see '<img src="../img/blank.gif" />'
@@ -1,5 +1,6 @@
1
1
  <%= stylesheet_link_tag "test1" %>
2
2
  <%= javascript_include_tag "test1" %>
3
3
  <%= image_tag "test2.png", :alt => "alt" %>
4
+ <%= image_tag "100px.png", :alt => "alt" %>
4
5
  <%= link_to "Has param", "test2.com", :class => "test" %>
5
6
  <%= number_to_human_size(1024) %>
@@ -31,13 +31,13 @@ module Middleman
31
31
  else # rewrite paths to use their destination path
32
32
  path = File.join(prefix, path)
33
33
  if resource = sitemap.find_resource_by_path(path)
34
- path = resource.destination_path
34
+ resource.url
35
+ else
36
+ File.join(http_prefix, path)
35
37
  end
36
-
37
- File.join(http_prefix, path)
38
38
  end
39
39
  end
40
40
  end
41
41
  end
42
42
  end
43
- end
43
+ end
@@ -102,9 +102,10 @@ module Middleman
102
102
  source = source.to_s.gsub(/\s/, '')
103
103
  ignore_extension = (kind == :images) # don't append extension
104
104
  source << ".#{kind}" unless ignore_extension or source =~ /\.#{kind}/
105
- result_path = source if source =~ %r{^/} # absolute path
106
- result_path ||= asset_url(source, asset_folder)
107
- "#{result_path}"
105
+ if source =~ %r{^/} # absolute path
106
+ asset_folder = ""
107
+ end
108
+ asset_url(source, asset_folder)
108
109
  end
109
110
 
110
111
  # Overload the regular link_to to be sitemap-aware - if you
@@ -131,10 +132,11 @@ module Middleman
131
132
  raise "Can't use the relative option with an external URL" if relative
132
133
  else
133
134
  # Handle relative urls
134
- current_dir = Pathname('/' + current_resource.path).dirname
135
+ current_source_dir = Pathname('/' + current_resource.path).dirname
136
+
135
137
  path = Pathname(url)
136
138
 
137
- url = current_dir.join(path).to_s if path.relative?
139
+ url = current_source_dir.join(path).to_s if path.relative?
138
140
 
139
141
  resource = sitemap.find_resource_by_path(url)
140
142
 
@@ -148,6 +150,9 @@ module Middleman
148
150
  if resource
149
151
  if effective_relative
150
152
  resource_url = resource.url
153
+
154
+ # Output urls relative to the destination path, not the source path
155
+ current_dir = Pathname('/' + current_resource.destination_path).dirname
151
156
  new_url = Pathname(resource_url).relative_path_from(current_dir).to_s
152
157
 
153
158
  # Put back the trailing slash to avoid unnecessary Apache redirects
@@ -30,31 +30,13 @@ module Middleman
30
30
  # @param [String] prefix
31
31
  # @return [String]
32
32
  def asset_url(path, prefix="")
33
- begin
34
- prefix = images_dir if prefix == http_images_path
35
- rescue
36
- end
33
+ path = super(path, prefix)
37
34
 
38
- if path.include?("://")
39
- super(path, prefix)
40
- elsif path[0,1] == "/"
35
+ if path.include?("//")
41
36
  path
42
37
  else
43
- path = File.join(prefix, path) if prefix.length > 0
44
-
45
- request_path = current_path.dup
46
- request_path << index_file if path.match(%r{/$})
47
-
48
- parts = request_path.gsub(%r{^/}, '').split('/')
49
-
50
- if parts.length > 1
51
- arry = []
52
- (parts.length - 1).times { arry << ".." }
53
- arry << path
54
- File.join(*arry)
55
- else
56
- path
57
- end
38
+ current_dir = Pathname('/' + current_resource.destination_path).dirname
39
+ Pathname(path).relative_path_from(current_dir)
58
40
  end
59
41
  end
60
42
  end
@@ -18,14 +18,14 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_dependency("middleman-core", Middleman::VERSION)
21
- s.add_dependency("uglifier", ["~> 1.2.0"])
22
- s.add_dependency("haml", [">= 3.1.0"])
23
- s.add_dependency("sass", [">= 3.1.7"])
24
- s.add_dependency("compass", [">= 0.12.1"])
21
+ s.add_dependency("uglifier", ["~> 1.2.6"])
22
+ s.add_dependency("haml", [">= 3.1.6"])
23
+ s.add_dependency("sass", [">= 3.1.20"])
24
+ s.add_dependency("compass", [">= 0.12.2"])
25
25
  s.add_dependency("coffee-script", ["~> 2.2.0"])
26
26
  s.add_dependency("coffee-script-source", ["~> 1.3.3"])
27
27
  s.add_dependency("execjs", ["~> 1.3.2"])
28
28
  s.add_dependency("maruku", ["~> 0.6.0"])
29
29
  s.add_dependency("i18n", ["~> 0.6.0"])
30
- s.add_dependency("padrino-helpers", ["~> 0.10.6"])
30
+ s.add_dependency("padrino-helpers", ["0.10.7"])
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-more
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc.2
4
+ version: 3.0.0.rc.3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-17 00:00:00.000000000 Z
13
+ date: 2012-07-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: middleman-core
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 3.0.0.rc.2
22
+ version: 3.0.0.rc.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - '='
29
29
  - !ruby/object:Gem::Version
30
- version: 3.0.0.rc.2
30
+ version: 3.0.0.rc.3
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: uglifier
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: 1.2.0
38
+ version: 1.2.6
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  requirements:
44
44
  - - ~>
45
45
  - !ruby/object:Gem::Version
46
- version: 1.2.0
46
+ version: 1.2.6
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: haml
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -51,7 +51,7 @@ dependencies:
51
51
  requirements:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 3.1.0
54
+ version: 3.1.6
55
55
  type: :runtime
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  requirements:
60
60
  - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
- version: 3.1.0
62
+ version: 3.1.6
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: sass
65
65
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ dependencies:
67
67
  requirements:
68
68
  - - ! '>='
69
69
  - !ruby/object:Gem::Version
70
- version: 3.1.7
70
+ version: 3.1.20
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -75,7 +75,7 @@ dependencies:
75
75
  requirements:
76
76
  - - ! '>='
77
77
  - !ruby/object:Gem::Version
78
- version: 3.1.7
78
+ version: 3.1.20
79
79
  - !ruby/object:Gem::Dependency
80
80
  name: compass
81
81
  requirement: !ruby/object:Gem::Requirement
@@ -83,7 +83,7 @@ dependencies:
83
83
  requirements:
84
84
  - - ! '>='
85
85
  - !ruby/object:Gem::Version
86
- version: 0.12.1
86
+ version: 0.12.2
87
87
  type: :runtime
88
88
  prerelease: false
89
89
  version_requirements: !ruby/object:Gem::Requirement
@@ -91,7 +91,7 @@ dependencies:
91
91
  requirements:
92
92
  - - ! '>='
93
93
  - !ruby/object:Gem::Version
94
- version: 0.12.1
94
+ version: 0.12.2
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: coffee-script
97
97
  requirement: !ruby/object:Gem::Requirement
@@ -177,17 +177,17 @@ dependencies:
177
177
  requirement: !ruby/object:Gem::Requirement
178
178
  none: false
179
179
  requirements:
180
- - - ~>
180
+ - - '='
181
181
  - !ruby/object:Gem::Version
182
- version: 0.10.6
182
+ version: 0.10.7
183
183
  type: :runtime
184
184
  prerelease: false
185
185
  version_requirements: !ruby/object:Gem::Requirement
186
186
  none: false
187
187
  requirements:
188
- - - ~>
188
+ - - '='
189
189
  - !ruby/object:Gem::Version
190
- version: 0.10.6
190
+ version: 0.10.7
191
191
  description: A static site generator. Provides dozens of templating languages (Haml,
192
192
  Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache
193
193
  busting, Yaml data (and more) an easy part of your development cycle.
@@ -594,7 +594,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
594
594
  version: '0'
595
595
  segments:
596
596
  - 0
597
- hash: 1457809501983501963
597
+ hash: 2353221539578920153
598
598
  required_rubygems_version: !ruby/object:Gem::Requirement
599
599
  none: false
600
600
  requirements: