jekyll-root-directory 0.0.4 → 0.0.5
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 +4 -4
- data/lib/jekyll-root-directory.rb +22 -9
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9091cb0087d96149f6089ce3b92d9f0428591cb1dc3a591f9825080d5611f95b
|
4
|
+
data.tar.gz: 44ca9c37e48516a8d9d3ebd8fc37d389ae47d2a4c51c683bb0aa485ab5044123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c7dbc95458709e8902dd05f8f0f846ace500d503922f62103924886150411f015b6edfe1263b0456f5363c398ddaddf0ae0745641fb63bcfdf9e1e715e5c8eb
|
7
|
+
data.tar.gz: 948f16ec4545ad8c0a07a6db5ac79a052a2e4a1f66d5ec2181d0ea46b8ea6967ff0b25b59a7a23bf364fdcc017d7287e45add350166a17ad1ae376c0733acf90
|
@@ -1,27 +1,31 @@
|
|
1
|
+
require "fileutils"
|
1
2
|
require "find"
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
class RootDirectoryPlugin
|
5
|
+
def initialize(site)
|
6
|
+
@site = site
|
7
|
+
@root_dir = "#{site.source}/_root"
|
8
|
+
end
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
def move_files()
|
11
|
+
Find.find("#{@root_dir}").select do |filename|
|
12
|
+
filename = filename.gsub("#{@root_dir}/", "")
|
13
|
+
path = "#{@root_dir}/#{filename}"
|
10
14
|
|
11
15
|
if File.file?("#{path}")
|
12
16
|
# There doesn't seem to be a native Jekyll method to copy + flatten a subfolder :|
|
13
17
|
# This means we need to do it manually.
|
14
18
|
|
15
19
|
# We can't use StaticFile as it keeps the subfolder used, but we need it for modify times
|
16
|
-
sFile = Jekyll::StaticFile.new(site, site.source, "_root", filename)
|
20
|
+
sFile = Jekyll::StaticFile.new(@site, @site.source, "_root", filename)
|
17
21
|
|
18
|
-
dest_path = "#{site.config['destination']}/#{filename}"
|
22
|
+
dest_path = "#{@site.config['destination']}/#{filename}"
|
19
23
|
|
20
24
|
FileUtils.mkdir_p(File.dirname(dest_path))
|
21
25
|
FileUtils.rm(dest_path) if File.exist?(dest_path)
|
22
26
|
|
23
27
|
# https://github.com/jekyll/jekyll/blob/22a974200d21a5476e92ee9e33312c583f001271/lib/jekyll/static_file.rb#L192
|
24
|
-
if @site.safe || Jekyll.env == "production"
|
28
|
+
if @site.safe? || Jekyll.env == "production"
|
25
29
|
FileUtils.cp(path, dest_path)
|
26
30
|
else
|
27
31
|
FileUtils.copy_entry(path, dest_path)
|
@@ -34,3 +38,12 @@ module Jekyll
|
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
41
|
+
|
42
|
+
|
43
|
+
module Jekyll
|
44
|
+
Hooks.register :site, :post_write do |site|
|
45
|
+
plugin = RootDirectoryPlugin.new(site)
|
46
|
+
|
47
|
+
plugin.move_files()
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-root-directory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angus Johnston
|
@@ -9,7 +9,27 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-10-30 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
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.7'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.7'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
13
33
|
description: Adds a _root directory to Jekyll, allowing you to move static root site
|
14
34
|
files away from the root jekyll directory.
|
15
35
|
email:
|