middleman-redirects 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/middleman/redirects/version.rb +1 -1
- data/lib/middleman/redirects.rb +20 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e6d8e9f845a8cc57f8f303557f82600e52f4ed8
|
4
|
+
data.tar.gz: aaa494ed37ee623e3fbe37e598453d0c67c95b4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be1178019d46ea3c9d65196686c9db76cd17c2cfdf7111bb509ec960a2ede0019259dee5ff3954ca155ad7ee29b42107e5296edb895b142ecc120d5e007c60ee
|
7
|
+
data.tar.gz: 375a9ef39314dbb9c7612467df2823a8f334a79a50a36eb74534fd5fdeaae5f6bfc5d774488a5e23c84f461831dcc6cd2db90216c480f78162cb61aae2916309
|
data/lib/middleman/redirects.rb
CHANGED
@@ -6,10 +6,13 @@ module Middleman
|
|
6
6
|
BLANK_RE = /\A[[:space:]]*\z/
|
7
7
|
|
8
8
|
class Extension < Middleman::Extension
|
9
|
+
option :match_trailing_slashes, true, 'match source URI even when requested with a trailing slash'
|
10
|
+
|
9
11
|
def initialize(app, options_hash={}, &block)
|
12
|
+
super
|
10
13
|
app.use ::Middleman::Redirects::Middleware
|
14
|
+
::Middleman::Redirects.match_trailing_slashes = options.match_trailing_slashes
|
11
15
|
::Middleman::Redirects.redirects_file_path = Pathname.new(app.root).join("REDIRECTS").freeze
|
12
|
-
super
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
@@ -28,6 +31,10 @@ module Middleman
|
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
34
|
+
class << self
|
35
|
+
attr_accessor :match_trailing_slashes
|
36
|
+
end
|
37
|
+
|
31
38
|
def self.redirects_file_path=(v)
|
32
39
|
@redirects_file_path = v
|
33
40
|
end
|
@@ -60,6 +67,18 @@ module Middleman
|
|
60
67
|
|
61
68
|
[source.to_s, destination.to_s]
|
62
69
|
end.compact]
|
70
|
+
|
71
|
+
autogenerated_redirects = {}
|
72
|
+
|
73
|
+
# duplicate redirect so it also matches URIs with a trailing slash
|
74
|
+
if self.match_trailing_slashes
|
75
|
+
@redirects.each do |source, destination|
|
76
|
+
next if source[-1] == '/'
|
77
|
+
autogenerated_redirects["#{source}/"] = destination
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
@redirects.merge!(autogenerated_redirects)
|
63
82
|
end
|
64
83
|
end
|
65
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-redirects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Schurrer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.
|
79
|
+
rubygems_version: 2.6.12
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Makes middleman support REDIRECT files in development
|