nanoc-redirector 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9b40db8122ff87d40c0f911ba8f2db8bdb3c5fecadc2ddfa6675e1c76418c2f
4
- data.tar.gz: bb2e3726da80ba18a9cf0e4c3efae06a00af669900249b93305effce616895f0
3
+ metadata.gz: a7abeee55bb8736eaa1e726e905368b2ebbf409d435a2e54a3d3a3f8e344f0dd
4
+ data.tar.gz: b334d24cce12bf8a67e259167b59b4ec4bc9333b3de69a6975ffacf4e5600cf4
5
5
  SHA512:
6
- metadata.gz: '068ba60f4397e18e9f2a25b5c1393d6dbb628aee6c9449ba387732d804a9f9af6071936d2d0c79828fffe762b2faf5819c92694896db81c306859e9092e9917d'
7
- data.tar.gz: f78eca52b3aed4cc7bb149638cc5a6196b78040f9ee8555c7df05928d939772188bf2e689c187f31140a0331a663cf12ee274e2726d8d823ba47c7c0b756e1c4
6
+ metadata.gz: 2d6aa2684637c4bf7cdf9179d0e93995697d20f3eb0c923b7ab183dad35257a34749b1a9e15f93d966d3b5328937e02490a8da755e97252be6fa541edd8a316b
7
+ data.tar.gz: d14ea79599dd76c15bdb7af2898edde5f7e594e5cfe7d5ede6a8c99bbdd559133062a64117e6c8be08286ea3ce499642a3b8c4bd30f105121917c16f60f3ad8a
data/.gitignore CHANGED
@@ -27,4 +27,6 @@ doc/
27
27
  .DS_Store
28
28
 
29
29
  test/fixtures/output
30
+ test/fixtures/somewhere
30
31
  test/fixtures/tmp
32
+ test/fixtures/nanoc.yaml
data/README.md CHANGED
@@ -61,11 +61,18 @@ require 'nanoc-redirector'
61
61
 
62
62
  postprocess do
63
63
  @items.each do |item|
64
- NanocRedirector::RedirectFrom.process(item, item.path)
64
+ NanocRedirector::RedirectFrom.process(item, item.identifier.without_ext)
65
65
  end
66
66
  end
67
67
  ```
68
68
 
69
+ #### Configuration
70
+
71
+ `RedirectFrom.process` takes an additional argument, `config`, which accepts two keys:
72
+
73
+ * [`:output_dir`](https://nanoc.ws/doc/reference/config/#output_dir): the directory where files are written to
74
+ * [`:index_filenames`](https://nanoc.ws/doc/reference/config/#index_filenames): a list of index filenames, i.e. names of files that will be served by a web server when a directory is requested.
75
+
69
76
  ### Redirect To filter
70
77
 
71
78
  Sometimes, you may want to redirect a site page to a totally different website. This plugin also supports that with the `redirect_to` key:
@@ -3,11 +3,13 @@ require 'version'
3
3
 
4
4
  module NanocRedirector
5
5
  module RedirectFrom
6
- def self.process(item, dest)
6
+ def self.process(item, dest, config = {})
7
7
  return if item[:redirect_from].nil?
8
8
  return if dest.nil?
9
9
  redirect_hash = {}
10
10
 
11
+ output_dir = config[:output_dir] || 'output'
12
+ index_filenames = config[:index_filenames] || ['index.html']
11
13
  key = item.identifier.without_ext
12
14
  value = item[:redirect_from].is_a?(String) ? [item[:redirect_from]] : item[:redirect_from]
13
15
 
@@ -16,10 +18,12 @@ module NanocRedirector
16
18
  redirect_hash.values.each do |redirects|
17
19
  redirects.each do |redirect|
18
20
  content = NanocRedirector.redirect_template(dest)
19
- dir = File.join("output", redirect)
20
- redirect_path = File.join(dir, "index.html")
21
- FileUtils.mkdir_p(dir) unless File.directory?(dir)
22
- File.write(redirect_path, content) unless File.exist? redirect_path
21
+ dir = File.join(output_dir, redirect)
22
+ index_filenames.each do |index_filename|
23
+ redirect_path = File.join(dir, index_filename)
24
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
25
+ File.write(redirect_path, content) unless File.exist? redirect_path
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -1,3 +1,3 @@
1
1
  module NanocRedirector
2
- VERSION = '0.3.2'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-redirector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-08 00:00:00.000000000 Z
11
+ date: 2019-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nanoc
@@ -103,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.7.6
106
+ rubygems_version: 3.0.6
108
107
  signing_key:
109
108
  specification_version: 4
110
109
  summary: '["Allows", "you", "to", "generate", "redirects", "to", "and", "from", "an",