jekyll-postfiles 2.1.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +3 -2
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +1 -2
- data/RELEASES.md +6 -0
- data/Rakefile +2 -0
- data/lib/jekyll-postfiles.rb +2 -85
- data/lib/jekyll/postfiles.rb +111 -0
- data/lib/jekyll/postfiles/version.rb +7 -0
- metadata +29 -15
- data/_release.sh +0 -11
- data/jekyll-postfiles.gemspec +0 -23
- data/lib/jekyll-postfiles/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0fbc83e7c863e6c9c8de143eb478b3e264cc640d1c88b2a7170be1cacbabb0c6
|
4
|
+
data.tar.gz: 8c8cd59474d3de1cbd0702b733a2f3f89f1a0df3dd64deb72628354ceff4830b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49bdc09297feda1dc497e8c2c04b18234117231b9e08433539117805f122a7c6339e4cca229da2da7a267f4c79191b6370626ab90f45747d0e7f88fb0f46519e
|
7
|
+
data.tar.gz: fcb9eb8fe93bb3388a085610bf341f04602b50a48311ed40b4bb7e0ba3d0c708124683bffabbd98fc27241a02ca66a8d5590c2447a45e8eb8ac169bf7551b339
|
data/Gemfile
CHANGED
data/{LICENSE.txt → LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -6,7 +6,6 @@
|
|
6
6
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
7
7
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
8
8
|
|
9
|
-
## Table of contents
|
10
9
|
|
11
10
|
- [Easing the management of images (and other files) attached to Markdown posts](#easing-the-management-of-images-and-other-files-attached-to-markdown-posts)
|
12
11
|
- [The pain of Jekyll's recommended posts assets management](#the-pain-of-jekylls-recommended-posts-assets-management)
|
@@ -202,7 +201,7 @@ Just put the images (and PDFs, etc.) in the same folder as your Markdown files,
|
|
202
201
|
|
203
202
|
## Contributing
|
204
203
|
|
205
|
-
|
204
|
+
Thanks for your interest in contributing! There are many ways to contribute to this project. Get started here (https://github.com/nhoizey/jekyll-postfiles/blob/master/CONTRIBUTING.md).
|
206
205
|
|
207
206
|
## License
|
208
207
|
|
data/RELEASES.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# Releases
|
2
|
+
|
3
|
+
## [v3.0.0](https://github.com/nhoizey/jekyll-postfiles/releases/tag/v3.0.0)
|
4
|
+
|
5
|
+
- [Rewrite for Jekyll 3.8.0](https://github.com/nhoizey/jekyll-postfiles/pull/12) by [@Birch-san](https://github.com/Birch-san)
|
6
|
+
- Match jekyll's coding style thanks to [Rubocop](http://rubocop.readthedocs.io/)
|
data/Rakefile
CHANGED
data/lib/jekyll-postfiles.rb
CHANGED
@@ -1,86 +1,3 @@
|
|
1
|
-
|
2
|
-
require "jekyll"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
class PostFile < StaticFile
|
7
|
-
|
8
|
-
# Initialize a new PostFile.
|
9
|
-
#
|
10
|
-
# site - The Site.
|
11
|
-
# base - The String path to the <source>.
|
12
|
-
# dir - The String path of the source directory of the file (rel <source>).
|
13
|
-
# name - The String filename of the file.
|
14
|
-
def initialize(site, base, dir, name, dest)
|
15
|
-
super(site, base, dir, name)
|
16
|
-
@name = name
|
17
|
-
@dest = dest
|
18
|
-
end
|
19
|
-
|
20
|
-
# Obtain destination path.
|
21
|
-
#
|
22
|
-
# dest - The String path to the destination dir.
|
23
|
-
#
|
24
|
-
# Returns destination file path.
|
25
|
-
def destination(dest)
|
26
|
-
File.join(@dest, @name)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class PostFileGenerator < Generator
|
31
|
-
|
32
|
-
# Copy the files from post's folder.
|
33
|
-
#
|
34
|
-
# post - A Post which may have associated content.
|
35
|
-
def copy_post_files(post)
|
36
|
-
|
37
|
-
post_path = post.path
|
38
|
-
site = post.site
|
39
|
-
site_src_dir = site.source
|
40
|
-
|
41
|
-
# Jekyll.logger.warn(
|
42
|
-
# "[PostFiles]",
|
43
|
-
# "Current post: #{post_path[site_src_dir.length..-1]}"
|
44
|
-
# )
|
45
|
-
|
46
|
-
post_dir = File.dirname(post_path)
|
47
|
-
dest_dir = File.dirname(post.destination(""))
|
48
|
-
|
49
|
-
# Count other Markdown files in the same directory
|
50
|
-
other_md_count = 0
|
51
|
-
other_md = Dir.glob(File.join(post_dir, '*.{md,markdown}'), File::FNM_CASEFOLD) do |mdfilepath|
|
52
|
-
if mdfilepath != post_path
|
53
|
-
other_md_count += 1
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
contents = Dir.glob(File.join(post_dir, '*')) do |filepath|
|
58
|
-
if filepath != post_path \
|
59
|
-
&& !File.directory?(filepath) \
|
60
|
-
&& !File.fnmatch?('*.{md,markdown}', filepath, File::FNM_EXTGLOB | File::FNM_CASEFOLD)
|
61
|
-
# Jekyll.logger.warn(
|
62
|
-
# "[PostFiles]",
|
63
|
-
# "-> attachment: #{filepath[site_src_dir.length..-1]}"
|
64
|
-
# )
|
65
|
-
if other_md_count > 0
|
66
|
-
Jekyll.logger.abort_with(
|
67
|
-
"[PostFiles]",
|
68
|
-
"Sorry, there can be only one Markdown file in each directory containing other assets to be copied by jekyll-postfiles"
|
69
|
-
)
|
70
|
-
end
|
71
|
-
filedir, filename = File.split(filepath[site_src_dir.length..-1])
|
72
|
-
site.static_files <<
|
73
|
-
PostFile.new(site, site_src_dir, filedir, filename, dest_dir)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# Generate content by copying files associated with each post.
|
79
|
-
def generate(site)
|
80
|
-
site.posts.docs.each do |post|
|
81
|
-
copy_post_files(post)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
3
|
+
require "jekyll/postfiles"
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
require "pathname"
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
module PostFiles
|
8
|
+
|
9
|
+
# there's a bug in the regex Document::DATE_FILENAME_MATCHER:
|
10
|
+
# %r!^(?:.+/)*(\d{2,4}-\d{1,2}-\d{1,2})-(.*)(\.[^.]+)$!
|
11
|
+
# used by:
|
12
|
+
# jekyll/lib/jekyll/readers/post_reader.rb#read_posts
|
13
|
+
# which ultimately populates:
|
14
|
+
# site.posts.docs
|
15
|
+
#
|
16
|
+
# the original code's intention was to match:
|
17
|
+
# all files with a date in the name
|
18
|
+
# but it accidentally matches also:
|
19
|
+
# all files immediately within a directory whose name contains a date
|
20
|
+
#
|
21
|
+
# our plugin changes the regex, to:
|
22
|
+
# avoid false positive when directory name matches date regex
|
23
|
+
Hooks.register :site, :after_reset do |site|
|
24
|
+
# Suppress warning messages.
|
25
|
+
original_verbose = $VERBOSE
|
26
|
+
$VERBOSE = nil
|
27
|
+
Document.const_set("DATE_FILENAME_MATCHER", PostFileGenerator::FIXED_DATE_FILENAME_MATCHER)
|
28
|
+
# Activate warning messages again.
|
29
|
+
$VERBOSE = original_verbose
|
30
|
+
end
|
31
|
+
|
32
|
+
class PostFile < StaticFile
|
33
|
+
# Initialize a new PostFile.
|
34
|
+
#
|
35
|
+
# site - The Site.
|
36
|
+
# base - The String path to the <source> - /srv/jekyll
|
37
|
+
# dir - The String path between <source> and the file - _posts/somedir
|
38
|
+
# name - The String filename of the file - cool.svg
|
39
|
+
# dest - The String path to the containing folder of the document which is output - /dist/blog/[:tag/]*:year/:month/:day
|
40
|
+
def initialize(site, base, dir, name, dest)
|
41
|
+
super(site, base, dir, name)
|
42
|
+
@name = name
|
43
|
+
@dest = dest
|
44
|
+
end
|
45
|
+
|
46
|
+
# Obtain destination path.
|
47
|
+
#
|
48
|
+
# dest - The String path to the destination dir.
|
49
|
+
#
|
50
|
+
# Returns destination file path.
|
51
|
+
def destination(dest)
|
52
|
+
File.join(@dest, @name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class PostFileGenerator < Generator
|
57
|
+
FIXED_DATE_FILENAME_MATCHER = %r!^(?:.+/)*(\d{2,4}-\d{1,2}-\d{1,2})-([^/]*)(\.[^.]+)$!
|
58
|
+
|
59
|
+
# _posts/
|
60
|
+
# 2018-01-01-whatever.md # there's a date on this filename, so it will be treated as a post
|
61
|
+
# # it's a direct descendant of _posts, so we do not treat it as an asset root
|
62
|
+
# somedir/
|
63
|
+
# 2018-05-01-some-post.md # there's a date on this filename, so it will be treated as a post.
|
64
|
+
# # moreover, we will treat its dir as an asset root
|
65
|
+
# cool.svg # there's no date on this filename, so it will be treated as an asset
|
66
|
+
# undated.md # there's no date on this filename, so it will be treated as an asset
|
67
|
+
# img/
|
68
|
+
# cool.png # yes, even deeply-nested files are eligible to be copied.
|
69
|
+
def generate(site)
|
70
|
+
site_srcroot = Pathname.new site.source
|
71
|
+
posts_src_dir = site_srcroot + "_posts"
|
72
|
+
drafts_src_dir = site_srcroot + "_drafts"
|
73
|
+
|
74
|
+
# Jekyll.logger.warn("[PostFiles]", "_posts: #{posts_src_dir}")
|
75
|
+
# Jekyll.logger.warn("[PostFiles]", "docs: #{site.posts.docs.map(&:path)}")
|
76
|
+
|
77
|
+
docs_with_dirs = site.posts.docs
|
78
|
+
.reject { |doc|
|
79
|
+
Pathname.new(doc.path).dirname.instance_eval { |dirname|
|
80
|
+
[posts_src_dir, drafts_src_dir].reduce(false) { |acc, dir|
|
81
|
+
acc || dirname.eql?(dir)
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
# Jekyll.logger.warn("[PostFiles]", "postdirs: #{docs_with_dirs.map{|doc| Pathname.new(doc.path).dirname}}")
|
87
|
+
|
88
|
+
assets = docs_with_dirs.map { |doc|
|
89
|
+
dest_dir = Pathname.new(doc.destination("")).dirname
|
90
|
+
Pathname.new(doc.path).dirname.instance_eval { |postdir|
|
91
|
+
Dir[postdir + "**/*"]
|
92
|
+
.reject { |fname| fname =~ FIXED_DATE_FILENAME_MATCHER }
|
93
|
+
.reject { |fname| File.directory? fname }
|
94
|
+
.map { |fname|
|
95
|
+
asset_abspath = Pathname.new fname
|
96
|
+
srcroot_to_asset = asset_abspath.relative_path_from(site_srcroot)
|
97
|
+
srcroot_to_assetdir = srcroot_to_asset.dirname
|
98
|
+
asset_basename = srcroot_to_asset.basename
|
99
|
+
|
100
|
+
assetdir_abs = site_srcroot + srcroot_to_assetdir
|
101
|
+
postdir_to_assetdir = assetdir_abs.relative_path_from(postdir)
|
102
|
+
PostFile.new(site, site_srcroot, srcroot_to_assetdir.to_path, asset_basename, (dest_dir + postdir_to_assetdir).to_path)
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}.flatten
|
106
|
+
|
107
|
+
site.static_files.concat(assets)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
metadata
CHANGED
@@ -1,59 +1,73 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-postfiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Hoizey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
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.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.6'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
33
|
+
version: '1.16'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
40
|
+
version: '1.16'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '12.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '12.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rubocop
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 0.55.0
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
description: This plugin takes any file that is in posts folders, and copy them
|
56
|
-
the folder in which the post HTML page will be created
|
68
|
+
version: 0.55.0
|
69
|
+
description: " This plugin takes any file that is in posts folders, and copy them
|
70
|
+
to the folder in which the post HTML page will be created.\n"
|
57
71
|
email:
|
58
72
|
- nicolas@hoizey.com
|
59
73
|
executables: []
|
@@ -61,13 +75,13 @@ extensions: []
|
|
61
75
|
extra_rdoc_files: []
|
62
76
|
files:
|
63
77
|
- Gemfile
|
64
|
-
- LICENSE
|
78
|
+
- LICENSE
|
65
79
|
- README.md
|
80
|
+
- RELEASES.md
|
66
81
|
- Rakefile
|
67
|
-
- _release.sh
|
68
|
-
- jekyll-postfiles.gemspec
|
69
82
|
- lib/jekyll-postfiles.rb
|
70
|
-
- lib/jekyll
|
83
|
+
- lib/jekyll/postfiles.rb
|
84
|
+
- lib/jekyll/postfiles/version.rb
|
71
85
|
homepage: https://nhoizey.github.io/jekyll-postfiles/
|
72
86
|
licenses:
|
73
87
|
- MIT
|
@@ -88,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
102
|
version: '0'
|
89
103
|
requirements: []
|
90
104
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.7.4
|
92
106
|
signing_key:
|
93
107
|
specification_version: 4
|
94
108
|
summary: A Jekyll plugin to keep posts assets alongside their Markdown files
|
data/_release.sh
DELETED
data/jekyll-postfiles.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'jekyll-postfiles/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "jekyll-postfiles"
|
8
|
-
spec.version = JekyllPostFiles::VERSION
|
9
|
-
spec.authors = ["Nicolas Hoizey"]
|
10
|
-
spec.email = ["nicolas@hoizey.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{A Jekyll plugin to keep posts assets alongside their Markdown files}
|
13
|
-
spec.description = %q{This plugin takes any file that is in posts folders, and copy them to the folder in which the post HTML page will be created.}
|
14
|
-
spec.homepage = "https://nhoizey.github.io/jekyll-postfiles/"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_development_dependency "bundler", "~> 1.12"
|
21
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
-
spec.add_development_dependency "rubocop", "~> 0.42"
|
23
|
-
end
|