middleman-alias 0.0.11 → 0.0.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fde8e6cd5a5473ffd8da034531e6f4981fe11651
4
- data.tar.gz: 340b29a36d12fe60431bb205befc9c26705ae872
3
+ metadata.gz: 62ea3643f03debfc512085870207e7ad69751d5e
4
+ data.tar.gz: c427a81dda362fbf22c4cfa759bb089fe90277c9
5
5
  SHA512:
6
- metadata.gz: ce7daeabc363a7241e7553529b176b3ecef25c51252335048ccb76bb68d2d106a30c0532750bc8c26ca81ef78e0b2ebdbebc8ce5bbe2d763461dbca3cc8886c0
7
- data.tar.gz: 596742f0b81eafa150538a84d175fcc14698a160689f25b76ada697b344f2239e7d8909572cc0173c0fb7fd40acbb99e83ec6df7f13d8d71b47e797a1dbd78f4
6
+ metadata.gz: 2bfce411ed299c17e99383725261c531f4af61ee8a074c9cee946ccff28ce98e1c3d1ce9d137c00e26dd8b321451ec7d6d99852e0d9db56479667233e983e896
7
+ data.tar.gz: d1da69ba50ddfe937130cfaac6fece34bd23f6563ea7a55ac29768cea0153046621dd268ed38f3cef7d4885936534a39c3eeda85e7df06f4d0542de2decc2dac
@@ -16,3 +16,25 @@ Feature: Aliases
16
16
  Then I should see "You are being redirected"
17
17
  When I go to "/foo-b.html"
18
18
  Then I should see "You are being redirected"
19
+
20
+ Scenario: Aliases should use relative paths if relative_links are enabled
21
+ Given a fixture app "alias-app"
22
+ And a file named "config.rb" with:
23
+ """
24
+ set :relative_links, true
25
+ activate :alias
26
+ """
27
+ And the Server is running
28
+ When I go to "/foo.html"
29
+ Then I should see 'href="bar.html'
30
+
31
+ Scenario: Aliases should use absolute paths if relative_links are disabled
32
+ Given a fixture app "alias-app"
33
+ And a file named "config.rb" with:
34
+ """
35
+ set :relative_links, false
36
+ activate :alias
37
+ """
38
+ And the Server is running
39
+ When I go to "/foo.html"
40
+ Then I should see 'href="/bar.html'
@@ -4,8 +4,8 @@ module Middleman
4
4
 
5
5
  attr_accessor :output
6
6
 
7
- def initialize(store, path, alias_path)
8
- @alias_path = alias_path
7
+ def initialize(store, path, alias_resource)
8
+ @alias_resource = alias_resource
9
9
  super(store, path)
10
10
  end
11
11
 
@@ -18,20 +18,21 @@ module Middleman
18
18
  end
19
19
 
20
20
  def render(*args, &block)
21
+ app.current_path = destination_path
21
22
  %[
22
23
  <html>
23
24
  <head>
24
- <link rel="canonical" href="#{@alias_path}" />
25
+ <link rel="canonical" href="#{app.url_for(@alias_resource)}" />
25
26
  <meta name="robots" content="noindex,follow" />
26
27
  <meta http-equiv="cache-control" content="no-cache" />
27
28
  <script>
28
29
  // Attempt to keep search and hash
29
- window.location.replace("#{@alias_path}"+window.location.search+window.location.hash);
30
+ window.location.replace("#{app.url_for(@alias_resource)}"+window.location.search+window.location.hash);
30
31
  </script>
31
- <meta http-equiv=refresh content="0; url=#{@alias_path}" />
32
+ <meta http-equiv=refresh content="0; url=#{app.url_for(@alias_resource)}" />
32
33
  </head>
33
34
  <body>
34
- <a href="#{@alias_path}">You are being redirected.</a>
35
+ <a href="#{app.url_for(@alias_resource)}">You are being redirected.</a>
35
36
  </body>
36
37
  </html>
37
38
  ]
@@ -42,7 +43,7 @@ module Middleman
42
43
  end
43
44
 
44
45
  def raw_data
45
- {}
46
+ @alias_resource.raw_data
46
47
  end
47
48
 
48
49
  def ignored?
@@ -50,7 +51,7 @@ module Middleman
50
51
  end
51
52
 
52
53
  def metadata
53
- @local_metadata.dup
54
+ @alias_resource.metadata
54
55
  end
55
56
 
56
57
 
@@ -16,7 +16,7 @@ module Middleman
16
16
  existing_resource = resources.select{|r| r.destination_path == alias_url }.first
17
17
  next if existing_resource
18
18
 
19
- resources.push Middleman::Sitemap::AliasResource.new(@app.sitemap, alias_url, resource.url)
19
+ resources.push Middleman::Sitemap::AliasResource.new(@app.sitemap, alias_url, resource)
20
20
  #Sitemap::Resource.new(@app.sitemap, alias_url).tap do |p|
21
21
  #p.proxy_to("alias.html")
22
22
  #p.add_metadata locals: {
@@ -1,3 +1,3 @@
1
1
  module MiddlemanAlias
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-alias
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-08 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core