jekyll-collection-multiplier 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f847bfe8d67603f53ea1468806164abff716ff39
4
+ data.tar.gz: ba152ac79c48ab05a90b36fbad0749c6d8f1eef9
5
+ SHA512:
6
+ metadata.gz: 7e61ddae78389a7c8fd6b725961c8aa68ee44121935d34ef86ffb7aa0abd78cc02450636a8f0a820e24bfc9a0a2e55dc0d4bc8a89480c791f7180459f22dcb89
7
+ data.tar.gz: e04408d8c779ed3532bd2b9e4f76afc8d0bde7ab7cbe09bd74baf91a082f646b68e134f01ef8e08980619e02f7fd5096d6d135be2467d6f2181aea004bcade83
@@ -0,0 +1,46 @@
1
+ module Jekyll
2
+
3
+ class Collection
4
+ def docs=(docs)
5
+ @docs = docs
6
+ end
7
+ end
8
+
9
+ class Document
10
+ alias :old_cleaned_relative_path :cleaned_relative_path
11
+
12
+ def cleaned_relative_path
13
+ og_rp = old_cleaned_relative_path
14
+ og_rp.sub(%r{\A_[^/]+/}, '')
15
+ end
16
+ end
17
+
18
+
19
+ class CollectionMultiplier < Generator
20
+ def generate(site)
21
+ return if site.config['collection_multiplier'].nil?
22
+
23
+ pairs = []
24
+
25
+ site.config['collection_multiplier'].each do |multiplier|
26
+ site.collections.each_pair do |collection_name, collection|
27
+ next unless multiplier['type'] == collection_name
28
+ renamed = multiplier['dupe']
29
+ duped_collection = Jekyll::Collection.new(site, renamed)
30
+ duped_collection.docs = collection.docs.dup.map do |doc|
31
+ duped_doc = Jekyll::Document.new(doc.path, { :site => site, :collection => duped_collection })
32
+ duped_doc.content = doc.content
33
+ actual_path = doc.path.sub(collection_name, renamed)
34
+ duped_doc.read(:actual_path => actual_path)
35
+ duped_doc
36
+ end
37
+
38
+ pairs << { renamed => duped_collection }
39
+ end
40
+ end
41
+ pairs.each do |pair|
42
+ site.collections[pair.keys.first] = pair.values.first
43
+ end
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-collection-multiplier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Garen J. Torikian
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/jekyll-collection-multiplier.rb
48
+ homepage: https://github.com/gjtorikian/jekyll-collection-multiplier
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.2.2
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Allows you to rerender a single Jekyll collection into multiple places
72
+ test_files: []