jekyll-multisite 0.2
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 +7 -0
- data/lib/jekyll-multisite.rb +178 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6083adb4b3f29499daf8ce22dc219b13a56d7c1f
|
4
|
+
data.tar.gz: 57ae23af96f23a8292c00da014b050efe73019fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e669ecc06ad6f134d911a28c903dcde72e12a859b9ed139f56a1f54d5b35e9252cae9b635fd209a3f19e2c4ca8644acc67bfc49bf7a2a5dc8d55972f4239612d
|
7
|
+
data.tar.gz: e31303d417121f29454e92440e189904ac645b78e85ccafdfbc26aa7c50fa4f2c8b46cf9a28edd508ca48c413db4f919b6e9db629cc19fb2b84974563fa77efb
|
@@ -0,0 +1,178 @@
|
|
1
|
+
"""
|
2
|
+
jekyll-multisite Sumit Khanna - http://penguindreams.org
|
3
|
+
|
4
|
+
---
|
5
|
+
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
"""
|
19
|
+
|
20
|
+
require 'jekyll'
|
21
|
+
require 'jekyll/reader'
|
22
|
+
require 'jekyll/cleaner'
|
23
|
+
require 'fileutils'
|
24
|
+
require 'pathname'
|
25
|
+
|
26
|
+
module Jekyll
|
27
|
+
|
28
|
+
# Originally part of jekyll-unsanatize gem
|
29
|
+
|
30
|
+
class << self
|
31
|
+
def sanitized_path(base_directory, questionable_path)
|
32
|
+
|
33
|
+
if base_directory.eql?(questionable_path)
|
34
|
+
base_directory
|
35
|
+
elsif questionable_path.start_with?(base_directory)
|
36
|
+
questionable_path
|
37
|
+
elsif File.exists?(questionable_path) and questionable_path != '/'
|
38
|
+
File.expand_path(questionable_path)
|
39
|
+
else
|
40
|
+
File.join(base_directory, questionable_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Cleaner
|
47
|
+
def parent_dirs(file)
|
48
|
+
parent_dir = File.dirname(file)
|
49
|
+
if parent_dir == '/'
|
50
|
+
[]
|
51
|
+
elsif parent_dir == site.dest
|
52
|
+
[]
|
53
|
+
else
|
54
|
+
[parent_dir] + parent_dirs(parent_dir)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Shared source reader
|
60
|
+
|
61
|
+
class Reader
|
62
|
+
|
63
|
+
def read
|
64
|
+
@site.layouts = LayoutReader.new(site).read
|
65
|
+
read_directories
|
66
|
+
|
67
|
+
if @site.config['shared_dir']
|
68
|
+
read_directories File.join('..', @site.config['shared_dir'])
|
69
|
+
end
|
70
|
+
|
71
|
+
sort_files!
|
72
|
+
@site.data = DataReader.new(site).read(site.config['data_dir'])
|
73
|
+
CollectionReader.new(site).read
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# Move the _shared directories to the correct location
|
80
|
+
# (very hacky - we move all the files to the correct
|
81
|
+
# location with a hook after the site is written/rendered)
|
82
|
+
|
83
|
+
def self.sync_dir(cur, base, dest)
|
84
|
+
Dir.glob( File.join(cur, '*'), File::FNM_DOTMATCH).each do |f|
|
85
|
+
|
86
|
+
rel = Pathname.new(f).relative_path_from(base)
|
87
|
+
dest_dir = File.join(dest, rel)
|
88
|
+
|
89
|
+
if File.basename(f) == '.' or File.basename(f) == '..'
|
90
|
+
next
|
91
|
+
elsif File.directory?(f)
|
92
|
+
if not File.exists?(dest_dir)
|
93
|
+
Dir.mkdir(dest_dir)
|
94
|
+
end
|
95
|
+
sync_dir(f, base, dest)
|
96
|
+
Dir.rmdir(f)
|
97
|
+
else
|
98
|
+
FileUtils.mv(f, dest_dir)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
Jekyll::Hooks.register :site, :post_write do |site|
|
104
|
+
base_shared = File.basename(site.config['shared_dir'])
|
105
|
+
shared_dir = File.join(site.dest, base_shared)
|
106
|
+
static_shared_dir = File.join(Configuration::DEFAULTS['destination'], base_shared)
|
107
|
+
|
108
|
+
sync_dir(shared_dir, Pathname.new(shared_dir), site.dest)
|
109
|
+
sync_dir(static_shared_dir, Pathname.new(static_shared_dir), site.dest)
|
110
|
+
|
111
|
+
Dir.rmdir(shared_dir)
|
112
|
+
Dir.rmdir(static_shared_dir)
|
113
|
+
end
|
114
|
+
|
115
|
+
# excluded files
|
116
|
+
|
117
|
+
class EntryFilter
|
118
|
+
|
119
|
+
def relative_to_source(entry)
|
120
|
+
|
121
|
+
shared_base = File.join('/..', @site.config['shared_dir'])
|
122
|
+
rel_path = File.join(base_directory, entry)
|
123
|
+
|
124
|
+
if base_directory.start_with?(shared_base)
|
125
|
+
rel_path.sub(/^#{shared_base}/,'')
|
126
|
+
else
|
127
|
+
rel_path
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
# jekyll-pagination fixes for multi-side
|
134
|
+
|
135
|
+
begin
|
136
|
+
require "jekyll-paginate"
|
137
|
+
|
138
|
+
module Paginate
|
139
|
+
|
140
|
+
class Pager
|
141
|
+
def self.pagination_candidate?(config, page)
|
142
|
+
page.name == 'index.html'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class Pagination < Generator
|
147
|
+
def paginate(site, page)
|
148
|
+
all_posts = site.site_payload['site']['posts']
|
149
|
+
all_posts = all_posts.reject { |p| p['hidden'] }
|
150
|
+
pages = Pager.calculate_pages(all_posts, site.config['paginate'].to_i)
|
151
|
+
(1..pages).each do |num_page|
|
152
|
+
pager = Pager.new(site, num_page, all_posts, pages)
|
153
|
+
if num_page > 1
|
154
|
+
|
155
|
+
# Here is our monkey patch
|
156
|
+
if site.config['shared_pagination'] == true
|
157
|
+
base = File.expand_path(File.join(site.source, '..'))
|
158
|
+
newpage = Page.new(site, base, page.dir, page.name)
|
159
|
+
else
|
160
|
+
newpage = Page.new(site, site.source, page.dir, page.name)
|
161
|
+
end
|
162
|
+
|
163
|
+
newpage.pager = pager
|
164
|
+
newpage.dir = Pager.paginate_path(site, num_page)
|
165
|
+
site.pages << newpage
|
166
|
+
else
|
167
|
+
page.pager = pager
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
rescue LoadError
|
175
|
+
# not installed
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-multisite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sumit Khanna
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-11 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: '3.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.1
|
33
|
+
description: Plugin for mult-site Jekyll configurations
|
34
|
+
email: sumit@penguindreams.org
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/jekyll-multisite.rb
|
40
|
+
homepage: http://penguindreams.org
|
41
|
+
licenses:
|
42
|
+
- GPL-3.0
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.2.5
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: jekyll-multisite
|
64
|
+
test_files: []
|