middleman-more 3.0.14 → 3.1.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/features/asset_hash.feature +29 -0
- data/features/clean_build.feature +3 -3
- data/features/helpers_link_to.feature +4 -4
- data/features/i18n_force_locale.feature +13 -0
- data/features/i18n_preview.feature +14 -1
- data/features/markdown.feature +3 -2
- data/features/markdown_redcarpet.feature +21 -0
- data/features/markdown_redcarpet_in_haml.feature +42 -0
- data/features/minify_javascript.feature +2 -2
- data/features/partials_dir.feature +30 -0
- data/features/sass-assets-paths.feature +1 -1
- data/fixtures/default-partials-dir-app/source/_partial.html.erb +1 -0
- data/fixtures/default-partials-dir-app/source/index.html.erb +2 -0
- data/fixtures/i18n-default-app/locales/en.yml +4 -0
- data/fixtures/i18n-default-app/locales/es.yml +8 -0
- data/fixtures/i18n-default-app/source/localizable/index.html.erb +5 -0
- data/fixtures/i18n-force-locale/config.rb +13 -0
- data/fixtures/i18n-force-locale/locales/en.yml +3 -0
- data/fixtures/i18n-force-locale/locales/es.yml +3 -0
- data/fixtures/i18n-force-locale/locales/fr.yml +3 -0
- data/fixtures/i18n-force-locale/source/index.haml +2 -0
- data/fixtures/markdown-app/config.rb +1 -0
- data/fixtures/markdown-frontmatter-options-app/config.rb +1 -0
- data/fixtures/markdown-frontmatter-options-app/source/smarty_pants-default.html.markdown +5 -0
- data/fixtures/markdown-frontmatter-options-app/source/smarty_pants-off.html.markdown +7 -0
- data/fixtures/markdown-frontmatter-options-app/source/smarty_pants-on.html.markdown +7 -0
- data/fixtures/markdown-frontmatter-options-app/source/tables-default.html.markdown +8 -0
- data/fixtures/markdown-frontmatter-options-app/source/tables-off.html.markdown +10 -0
- data/fixtures/markdown-frontmatter-options-app/source/tables-on.html.markdown +10 -0
- data/{lib/middleman-more/templates/smacss/source/stylesheets/_0.site-settings.scss → fixtures/markdown-in-haml-app/config.rb} +0 -0
- data/fixtures/markdown-in-haml-app/source/images/blank.gif +0 -0
- data/fixtures/markdown-in-haml-app/source/link_target.html.markdown +4 -0
- data/fixtures/partials-dir-app/source/index.html.erb +2 -0
- data/fixtures/partials-dir-app/source/nested/partials/_partial.html.erb +1 -0
- data/fixtures/partials-dir-app/source/partials/_partial.html.erb +1 -0
- data/fixtures/sass-assets-path-app/assets/stylesheets/{_shared-asset.sass → _shared-asset-sass.sass} +1 -1
- data/fixtures/sass-assets-path-app/source/stylesheets/plain.css.sass +1 -1
- data/lib/middleman-more/core_extensions/compass.rb +22 -22
- data/lib/middleman-more/core_extensions/default_helpers.rb +36 -13
- data/lib/middleman-more/core_extensions/i18n.rb +31 -6
- data/lib/middleman-more/extensions/asset_hash.rb +30 -17
- data/lib/middleman-more/extensions/asset_host.rb +11 -8
- data/lib/middleman-more/extensions/automatic_image_sizes.rb +4 -8
- data/lib/middleman-more/extensions/directory_indexes.rb +2 -5
- data/lib/middleman-more/extensions/gzip.rb +18 -19
- data/lib/middleman-more/extensions/minify_css.rb +11 -4
- data/lib/middleman-more/extensions/minify_javascript.rb +1 -1
- data/lib/middleman-more/templates/smacss/source/_footer.haml +1 -1
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/README.markdown +11 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/base.scss +1 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/normalize.scss +375 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/layout/README.markdown +9 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/modules/README.markdown +9 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/states/README.markdown +12 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/style.css.scss +12 -7
- data/lib/middleman-more.rb +1 -5
- data/middleman-more.gemspec +3 -4
- metadata +75 -50
- data/lib/middleman-more/core_extensions/assets.rb +0 -43
- data/lib/middleman-more/extensions/minify_css/rainpress.rb +0 -168
- data/lib/middleman-more/templates/smacss/source/stylesheets/_1.base.scss +0 -2
- data/lib/middleman-more/templates/smacss/source/stylesheets/_2.layout.scss +0 -2
- data/lib/middleman-more/templates/smacss/source/stylesheets/_3.states.scss +0 -2
- data/lib/middleman-more/templates/smacss/source/stylesheets/_4.themes.scss +0 -2
- data/lib/middleman-more/templates/smacss/source/stylesheets/modules/_btn.scss +0 -2
data/features/asset_hash.feature
CHANGED
@@ -104,3 +104,32 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
|
104
104
|
Then I should see 'Added by Rack filter'
|
105
105
|
When I go to "stylesheets/site-50eaa978.css"
|
106
106
|
Then I should see 'Not Found'
|
107
|
+
|
108
|
+
Scenario: Hashed-asset files are not produced for ignored paths
|
109
|
+
Given a fixture app "asset-hash-app"
|
110
|
+
And a file named "config.rb" with:
|
111
|
+
"""
|
112
|
+
activate :asset_hash, :ignore => [%r(javascripts/*), 'images/*']
|
113
|
+
activate :relative_assets
|
114
|
+
activate :directory_indexes
|
115
|
+
"""
|
116
|
+
And a successfully built app at "asset-hash-app"
|
117
|
+
When I cd to "build"
|
118
|
+
Then the following files should exist:
|
119
|
+
| index.html |
|
120
|
+
| apple-touch-icon.png |
|
121
|
+
| favicon.ico |
|
122
|
+
| images/100px.png |
|
123
|
+
| images/100px.jpg |
|
124
|
+
| images/100px.gif |
|
125
|
+
| javascripts/application.js |
|
126
|
+
| stylesheets/site-50eaa978.css |
|
127
|
+
| index.html |
|
128
|
+
| subdir/index.html |
|
129
|
+
| other/index.html |
|
130
|
+
And the following files should not exist:
|
131
|
+
| images/100px-1242c368.png |
|
132
|
+
| images/100px-5fd6fb90.jpg |
|
133
|
+
| images/100px-5fd6fb90.gif |
|
134
|
+
| javascripts/application-1d8d5276.js |
|
135
|
+
| stylesheets/site.css |
|
@@ -1,14 +1,14 @@
|
|
1
1
|
Feature: Build Clean
|
2
2
|
|
3
3
|
Scenario: Clean an app with directory indexes
|
4
|
-
Given a successfully built app at "clean-dir-app"
|
4
|
+
Given a successfully built app at "clean-dir-app" with flags "--no-clean"
|
5
5
|
Then the following files should exist:
|
6
6
|
| build/about/index.html |
|
7
|
-
Given a successfully built app at "clean-dir-app"
|
7
|
+
Given a successfully built app at "clean-dir-app"
|
8
8
|
Then the following files should exist:
|
9
9
|
| build/about/index.html |
|
10
10
|
|
11
11
|
Scenario: Clean build an app that's never been built
|
12
|
-
Given a successfully built app at "clean-dir-app"
|
12
|
+
Given a successfully built app at "clean-dir-app"
|
13
13
|
Then the following files should exist:
|
14
14
|
| build/about/index.html |
|
@@ -36,15 +36,15 @@ Feature: link_to helper
|
|
36
36
|
And a file named "source/link_to.html.erb" with:
|
37
37
|
"""
|
38
38
|
<% menu_items.each do |item| %>
|
39
|
-
<%= link_to(item.
|
40
|
-
<%= link_to(item.
|
39
|
+
<%= link_to(item.data['title'], item.url) %>
|
40
|
+
<%= link_to(item.data['title'], item) %>
|
41
41
|
<% end %>
|
42
42
|
"""
|
43
43
|
And a file named "source/link_to/sub.html.erb" with:
|
44
44
|
"""
|
45
45
|
<% menu_items.each do |item| %>
|
46
|
-
<%= link_to(item.
|
47
|
-
<%= link_to(item.
|
46
|
+
<%= link_to(item.data['title'], item.url) %>
|
47
|
+
<%= link_to(item.data['title'], item) %>
|
48
48
|
<% end %>
|
49
49
|
"""
|
50
50
|
And the Server is running at "indexable-app"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: i18n manually setting locale
|
2
|
+
|
3
|
+
Scenario: Setting I18n.locale in a block (see issue #809) or with the :lang option
|
4
|
+
Given the Server is running at "i18n-force-locale"
|
5
|
+
When I go to "/en/index.html"
|
6
|
+
Then I should see "Hello"
|
7
|
+
Then I should see "I18n.locale: en"
|
8
|
+
When I go to "/es/index.html"
|
9
|
+
Then I should see "Hola"
|
10
|
+
Then I should see "I18n.locale: es"
|
11
|
+
When I go to "/fr/index.html"
|
12
|
+
Then I should see "Bonjour"
|
13
|
+
Then I should see "I18n.locale: fr"
|
@@ -202,4 +202,17 @@ Feature: i18n Preview
|
|
202
202
|
When I go to "/es/index.html"
|
203
203
|
Then I should see '"../stylesheets/site.css"'
|
204
204
|
When I go to "/es/hola.html"
|
205
|
-
Then I should see '"../stylesheets/site.css"'
|
205
|
+
Then I should see '"../stylesheets/site.css"'
|
206
|
+
|
207
|
+
Scenario: Missing translations fall back to the default locale
|
208
|
+
Given a fixture app "i18n-default-app"
|
209
|
+
And a file named "config.rb" with:
|
210
|
+
"""
|
211
|
+
activate :i18n, :mount_at_root => :es
|
212
|
+
"""
|
213
|
+
Given the Server is running at "i18n-default-app"
|
214
|
+
When I go to "/en/"
|
215
|
+
Then I should see "Default locale: es"
|
216
|
+
Then I should see "Current locale: en"
|
217
|
+
Then I should see "Buenos días"
|
218
|
+
Then I should see "Howdy"
|
data/features/markdown.feature
CHANGED
@@ -5,8 +5,9 @@ Feature: Markdown support
|
|
5
5
|
Given the Server is running at "markdown-app"
|
6
6
|
When I go to "/index.html"
|
7
7
|
Then I should see "<p>Hello World</p>"
|
8
|
-
|
8
|
+
|
9
|
+
@encoding
|
9
10
|
Scenario: Markdown extensions (Maruku)
|
10
11
|
Given the Server is running at "markdown-app"
|
11
12
|
When I go to "/smarty_pants.html"
|
12
|
-
Then I should see "
|
13
|
+
Then I should see "“Hello”"
|
@@ -42,6 +42,27 @@ Feature: Markdown support
|
|
42
42
|
When I go to "/hard_wrap.html"
|
43
43
|
Then I should see "br"
|
44
44
|
|
45
|
+
Scenario: Redcarpet per-page frontmatter options
|
46
|
+
Given a fixture app "markdown-frontmatter-options-app"
|
47
|
+
And a file named "config.rb" with:
|
48
|
+
"""
|
49
|
+
set :markdown_engine, :redcarpet
|
50
|
+
set :markdown, :smartypants => true
|
51
|
+
"""
|
52
|
+
Given the Server is running at "markdown-frontmatter-options-app"
|
53
|
+
When I go to "/smarty_pants-default.html"
|
54
|
+
Then I should see "“"
|
55
|
+
When I go to "/smarty_pants-on.html"
|
56
|
+
Then I should see "“"
|
57
|
+
When I go to "/smarty_pants-off.html"
|
58
|
+
Then I should not see "“"
|
59
|
+
When I go to "/tables-default.html"
|
60
|
+
Then I should not see "<table>"
|
61
|
+
When I go to "/tables-on.html"
|
62
|
+
Then I should see "<table>"
|
63
|
+
When I go to "/tables-off.html"
|
64
|
+
Then I should not see "<table>"
|
65
|
+
|
45
66
|
Scenario: Redcarpet uses our link_to and image_tag helpers
|
46
67
|
Given a fixture app "markdown-app"
|
47
68
|
And a file named "config.rb" with:
|
@@ -0,0 +1,42 @@
|
|
1
|
+
@nojava
|
2
|
+
Feature: Markdown support in Haml
|
3
|
+
In order to test support of the Haml markdown filter
|
4
|
+
|
5
|
+
Scenario: Markdown filter in Haml works
|
6
|
+
Given a fixture app "markdown-in-haml-app"
|
7
|
+
And a file named "config.rb" with:
|
8
|
+
"""
|
9
|
+
set :markdown_engine, :redcarpet
|
10
|
+
activate :directory_indexes
|
11
|
+
"""
|
12
|
+
And a file named "source/markdown_filter.html.haml" with:
|
13
|
+
"""
|
14
|
+
:markdown
|
15
|
+
# H1
|
16
|
+
|
17
|
+
paragraph
|
18
|
+
"""
|
19
|
+
Given the Server is running at "markdown-in-haml-app"
|
20
|
+
When I go to "/markdown_filter/"
|
21
|
+
Then I should see "<h1>H1</h1>"
|
22
|
+
Then I should see "<p>paragraph</p>"
|
23
|
+
|
24
|
+
|
25
|
+
Scenario: Markdown filter in Haml uses our link_to and image_tag helpers
|
26
|
+
Given a fixture app "markdown-in-haml-app"
|
27
|
+
And a file named "config.rb" with:
|
28
|
+
"""
|
29
|
+
set :markdown_engine, :redcarpet
|
30
|
+
activate :directory_indexes
|
31
|
+
"""
|
32
|
+
And a file named "source/link_and_image.html.haml" with:
|
33
|
+
"""
|
34
|
+
:markdown
|
35
|
+
[A link](/link_target.html)
|
36
|
+
|
37
|
+

|
38
|
+
"""
|
39
|
+
Given the Server is running at "markdown-in-haml-app"
|
40
|
+
When I go to "/link_and_image/"
|
41
|
+
Then I should see "/link_target/"
|
42
|
+
Then I should see 'src="/images/blank.gif"'
|
@@ -203,7 +203,7 @@ Feature: Minify Javascript
|
|
203
203
|
"""
|
204
204
|
And the Server is running at "passthrough-app"
|
205
205
|
When I go to "/inline-coffeescript.html"
|
206
|
-
Then I should see "
|
206
|
+
Then I should see "14" lines
|
207
207
|
|
208
208
|
Scenario: Rendering external js (coffeescript) with a passthrough minifier
|
209
209
|
Given a fixture app "passthrough-app"
|
@@ -221,5 +221,5 @@ Feature: Minify Javascript
|
|
221
221
|
"""
|
222
222
|
And the Server is running at "passthrough-app"
|
223
223
|
When I go to "/javascripts/coffee_test.js"
|
224
|
-
Then I should see "
|
224
|
+
Then I should see "12" lines
|
225
225
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: Partials dir
|
2
|
+
Scenario: Find partials in a custom partials dir
|
3
|
+
Given a fixture app "partials-dir-app"
|
4
|
+
And a file named "config.rb" with:
|
5
|
+
"""
|
6
|
+
set :partials_dir, 'partials'
|
7
|
+
"""
|
8
|
+
And the Server is running
|
9
|
+
When I go to "/index.html"
|
10
|
+
Then I should see "contents of the partial"
|
11
|
+
|
12
|
+
Scenario: Find partials in a nested custom partials dir
|
13
|
+
Given a fixture app "partials-dir-app"
|
14
|
+
And a file named "config.rb" with:
|
15
|
+
"""
|
16
|
+
set :partials_dir, 'nested/partials'
|
17
|
+
"""
|
18
|
+
And the Server is running
|
19
|
+
When I go to "/index.html"
|
20
|
+
Then I should see "contents of the nested partial"
|
21
|
+
|
22
|
+
Scenario: Find partials in the default partials dir
|
23
|
+
Given a fixture app "default-partials-dir-app"
|
24
|
+
And a file named "config.rb" with:
|
25
|
+
"""
|
26
|
+
"""
|
27
|
+
And the Server is running
|
28
|
+
When I go to "/index.html"
|
29
|
+
Then I should see "contents of the partial"
|
30
|
+
|
@@ -6,6 +6,6 @@ Feature: Support SASS assets paths
|
|
6
6
|
When I go to "/stylesheets/plain.css"
|
7
7
|
Then I should see "color: green;"
|
8
8
|
Then I should see "/* Works with shared SCSS assets from APPROOT/assets/stylesheets/_shared-asset.scss */"
|
9
|
-
Then I should see "/* Works with shared SASS assets from APPROOT/assets/stylesheets/_shared-asset.sass */"
|
9
|
+
Then I should see "/* Works with shared SASS assets from APPROOT/assets/stylesheets/_shared-asset-sass.sass */"
|
10
10
|
Then I should see "font-size: 18px"
|
11
11
|
Then I should see "/* Works with shared SASS assets from external source directory */"
|
@@ -0,0 +1 @@
|
|
1
|
+
contents of the partial
|
@@ -0,0 +1,13 @@
|
|
1
|
+
[:en, :es].each do |locale|
|
2
|
+
proxy "/#{locale}/index.html", "index.html", :ignore => true do
|
3
|
+
::I18n.locale = locale
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
proxy "/fr/index.html", "index.html", :lang => :fr
|
8
|
+
|
9
|
+
activate :i18n
|
10
|
+
|
11
|
+
# This is what breaks i18n, just because it adds a resource list manipulator that
|
12
|
+
# forces a rebuild of the resource list.
|
13
|
+
activate :asset_hash
|
@@ -0,0 +1 @@
|
|
1
|
+
set :markdown, :smartypants => true
|
@@ -0,0 +1 @@
|
|
1
|
+
set :markdown, :smartypants => true
|
File without changes
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
contents of the nested partial
|
@@ -0,0 +1 @@
|
|
1
|
+
contents of the partial
|
data/fixtures/sass-assets-path-app/assets/stylesheets/{_shared-asset.sass → _shared-asset-sass.sass}
RENAMED
@@ -1 +1 @@
|
|
1
|
-
/* Works with shared SASS assets from APPROOT/assets/stylesheets/_shared-asset.sass */
|
1
|
+
/* Works with shared SASS assets from APPROOT/assets/stylesheets/_shared-asset-sass.sass */
|
@@ -19,41 +19,41 @@ module Middleman
|
|
19
19
|
|
20
20
|
# Location of SASS/SCSS files external to source directory.
|
21
21
|
# @return [Array]
|
22
|
-
#
|
23
|
-
app.
|
22
|
+
# config[:sass_assets_paths] = ["#{root}/assets/sass/", "/path/2/external/sass/repository/"]
|
23
|
+
app.config.define_setting :sass_assets_paths, [], 'Paths to extra SASS/SCSS files'
|
24
24
|
|
25
25
|
app.after_configuration do
|
26
|
-
::Compass.configuration do |
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
sass_assets_paths.each do |path|
|
38
|
-
|
26
|
+
::Compass.configuration do |compass_config|
|
27
|
+
compass_config.project_path = source_dir
|
28
|
+
compass_config.environment = :development
|
29
|
+
compass_config.cache_path = config[:sass_cache_path]
|
30
|
+
compass_config.sass_dir = config[:css_dir]
|
31
|
+
compass_config.css_dir = config[:css_dir]
|
32
|
+
compass_config.javascripts_dir = config[:js_dir]
|
33
|
+
compass_config.fonts_dir = config[:fonts_dir]
|
34
|
+
compass_config.images_dir = config[:images_dir]
|
35
|
+
compass_config.http_path = config[:http_prefix]
|
36
|
+
|
37
|
+
config[:sass_assets_paths].each do |path|
|
38
|
+
compass_config.add_import_path path
|
39
39
|
end
|
40
40
|
|
41
41
|
# Disable this initially, the cache_buster extension will
|
42
42
|
# re-enable it if requested.
|
43
|
-
|
43
|
+
compass_config.asset_cache_buster :none
|
44
44
|
|
45
45
|
# Disable this initially, the relative_assets extension will
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
compass_config.relative_assets = false
|
48
48
|
|
49
49
|
# Default output style
|
50
|
-
|
50
|
+
compass_config.output_style = :nested
|
51
51
|
|
52
52
|
# No line-comments in test mode (changing paths mess with sha1)
|
53
|
-
|
53
|
+
compass_config.line_comments = false if ENV["TEST"]
|
54
54
|
|
55
|
-
if
|
56
|
-
|
55
|
+
if config.defines_setting?(:asset_host) && config[:asset_host].is_a?(Proc)
|
56
|
+
compass_config.asset_host(&config[:asset_host])
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -18,17 +18,21 @@ module Middleman
|
|
18
18
|
app.helpers ::Padrino::Helpers::FormatHelpers
|
19
19
|
app.helpers ::Padrino::Helpers::RenderHelpers
|
20
20
|
app.helpers ::Padrino::Helpers::NumberHelpers
|
21
|
-
# app.helpers ::Padrino::Helpers::TranslationHelpers
|
22
21
|
|
23
22
|
app.helpers Helpers
|
24
23
|
|
25
|
-
app.
|
24
|
+
app.config.define_setting :relative_links, false, 'Whether to generate relative links instead of absolute ones'
|
26
25
|
end
|
27
26
|
alias :included :registered
|
28
27
|
end
|
29
28
|
|
30
29
|
# The helpers
|
31
30
|
module Helpers
|
31
|
+
# Disable Padrino cache buster
|
32
|
+
def asset_stamp
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
32
36
|
# Output a stylesheet link tag based on the current path
|
33
37
|
#
|
34
38
|
# @return [String]
|
@@ -50,7 +54,6 @@ module Middleman
|
|
50
54
|
# Output a stylesheet link tag based on the current path
|
51
55
|
#
|
52
56
|
# @param [Symbol] asset_ext The type of asset
|
53
|
-
# @param [String] separator How to break up path in parts
|
54
57
|
# @param [String] asset_dir Where to look for assets
|
55
58
|
# @return [void]
|
56
59
|
def auto_tag(asset_ext, asset_dir=nil)
|
@@ -95,16 +98,36 @@ module Middleman
|
|
95
98
|
when :css then css_dir
|
96
99
|
when :js then js_dir
|
97
100
|
when :images then images_dir
|
101
|
+
when :fonts then fonts_dir
|
98
102
|
else kind.to_s
|
99
103
|
end
|
100
104
|
source = source.to_s.tr(' ', '')
|
101
|
-
ignore_extension = (kind == :images) # don't append extension
|
105
|
+
ignore_extension = (kind == :images || kind == :fonts) # don't append extension
|
102
106
|
source << ".#{kind}" unless ignore_extension || source.end_with?(".#{kind}")
|
103
107
|
asset_folder = "" if source.start_with?('/') # absolute path
|
104
108
|
|
105
109
|
asset_url(source, asset_folder)
|
106
110
|
end
|
107
111
|
|
112
|
+
# Get the URL of an asset given a type/prefix
|
113
|
+
#
|
114
|
+
# @param [String] path The path (such as "photo.jpg")
|
115
|
+
# @param [String] prefix The type prefix (such as "images")
|
116
|
+
# @return [String] The fully qualified asset url
|
117
|
+
def asset_url(path, prefix="")
|
118
|
+
# Don't touch assets which already have a full path
|
119
|
+
if path.include?("//")
|
120
|
+
path
|
121
|
+
else # rewrite paths to use their destination path
|
122
|
+
path = File.join(prefix, path)
|
123
|
+
if resource = sitemap.find_resource_by_path(path)
|
124
|
+
resource.url
|
125
|
+
else
|
126
|
+
File.join(config[:http_prefix], path)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
108
131
|
# Given a source path (referenced either absolutely or relatively)
|
109
132
|
# or a Resource, this will produce the nice URL configured for that
|
110
133
|
# path, respecting :relative_links, directory indexes, etc.
|
@@ -122,16 +145,16 @@ module Middleman
|
|
122
145
|
relative = options.delete(:relative)
|
123
146
|
raise "Can't use the relative option with an external URL" if relative && uri.host
|
124
147
|
|
125
|
-
# Allow people to turn on relative paths for all links with
|
148
|
+
# Allow people to turn on relative paths for all links with
|
126
149
|
# set :relative_links, true
|
127
150
|
# but still override on a case by case basis with the :relative parameter.
|
128
151
|
effective_relative = relative || false
|
129
|
-
effective_relative = true if relative.nil? && relative_links
|
152
|
+
effective_relative = true if relative.nil? && config[:relative_links]
|
130
153
|
|
131
154
|
# Try to find a sitemap resource corresponding to the desired path
|
132
155
|
this_resource = current_resource # store in a local var to save work
|
133
156
|
if path_or_resource.is_a?(Sitemap::Resource)
|
134
|
-
resource = path_or_resource
|
157
|
+
resource = path_or_resource
|
135
158
|
resource_url = url
|
136
159
|
elsif this_resource && uri.path
|
137
160
|
# Handle relative urls
|
@@ -163,7 +186,7 @@ module Middleman
|
|
163
186
|
# If they explicitly asked for relative links but we can't find a resource...
|
164
187
|
raise "No resource exists at #{url}" if relative
|
165
188
|
end
|
166
|
-
|
189
|
+
|
167
190
|
# Support a :query option that can be a string or hash
|
168
191
|
if query = options.delete(:query)
|
169
192
|
uri.query = query.respond_to?(:to_param) ? query.to_param : query.to_s
|
@@ -172,7 +195,7 @@ module Middleman
|
|
172
195
|
# Support a :fragment or :anchor option just like Padrino
|
173
196
|
fragment = options.delete(:anchor) || options.delete(:fragment)
|
174
197
|
uri.fragment = fragment.to_s if fragment
|
175
|
-
|
198
|
+
|
176
199
|
# Finally make the URL back into a string
|
177
200
|
uri.to_s
|
178
201
|
end
|
@@ -183,10 +206,10 @@ module Middleman
|
|
183
206
|
# :relative option which, if set to true, will produce
|
184
207
|
# relative URLs instead of absolute URLs. You can also add
|
185
208
|
#
|
186
|
-
#
|
209
|
+
# config[:relative_links] = true
|
187
210
|
#
|
188
211
|
# to config.rb to have all links default to relative.
|
189
|
-
#
|
212
|
+
#
|
190
213
|
# There is also a :query option that can be used to append a
|
191
214
|
# query string, which can be expressed as either a String,
|
192
215
|
# or a Hash which will be turned into URL parameters.
|
@@ -201,11 +224,11 @@ module Middleman
|
|
201
224
|
if url = args[url_arg_index]
|
202
225
|
options = args[options_index] || {}
|
203
226
|
raise ArgumentError.new("Options must be a hash") unless options.is_a?(Hash)
|
204
|
-
|
227
|
+
|
205
228
|
# Transform the url through our magic url_for method
|
206
229
|
args[url_arg_index] = url_for(url, options)
|
207
230
|
end
|
208
|
-
|
231
|
+
|
209
232
|
super(*args, &block)
|
210
233
|
end
|
211
234
|
|