jekyll-postfiles 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/lib/jekyll-postfiles.rb +35 -9
- data/lib/jekyll-postfiles/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 854c58ed5e01319e8160695c04e36f810ca219e7
|
4
|
+
data.tar.gz: 4ff8a95dc4238957e04ecb37d90316308df239bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d240983785824174ff9e5231a12bd1e192b256bb61a65ba72de4608ba268611775aaf05b05ff2e770798bd7ba08c249e3164b633b493c39397f97b13232e6245
|
7
|
+
data.tar.gz: a71ba2e871ad238394bf8c4bb3762bd26145dd22c9ce54eae4bd1ac3ee41d26b788781aaa37bc5c59164008a3c9c991b1b37d1d0d9e8daa557106aa2f91533e0
|
data/README.md
CHANGED
@@ -3,6 +3,24 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/jekyll-postfiles.svg)](https://badge.fury.io/rb/jekyll-postfiles)
|
4
4
|
[![Gem Downloads](https://img.shields.io/gem/dt/jekyll-postfiles.svg?style=flat)](http://rubygems.org/gems/jekyll-postfiles)
|
5
5
|
|
6
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
7
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
8
|
+
|
9
|
+
## Table of contents
|
10
|
+
|
11
|
+
- [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
|
+
- [The pain of Jekyll's recommended posts assets management](#the-pain-of-jekylls-recommended-posts-assets-management)
|
13
|
+
- [There must be another way](#there-must-be-another-way)
|
14
|
+
- [Not every assets need this](#not-every-assets-need-this)
|
15
|
+
- [How does it work?](#how-does-it-work)
|
16
|
+
- [Installation](#installation)
|
17
|
+
- [Usage](#usage)
|
18
|
+
- [Contributing](#contributing)
|
19
|
+
- [License](#license)
|
20
|
+
- [Thanks](#thanks)
|
21
|
+
|
22
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
23
|
+
|
6
24
|
## Easing the management of images (and other files) attached to Markdown posts
|
7
25
|
|
8
26
|
### The pain of Jekyll's recommended posts assets management
|
@@ -166,7 +184,7 @@ gem 'jekyll-postfiles'
|
|
166
184
|
Execute this:
|
167
185
|
|
168
186
|
```shell
|
169
|
-
|
187
|
+
bundle
|
170
188
|
```
|
171
189
|
|
172
190
|
And add this line to your `_config.yml`:
|
data/lib/jekyll-postfiles.rb
CHANGED
@@ -34,17 +34,43 @@ module Jekyll
|
|
34
34
|
# post - A Post which may have associated content.
|
35
35
|
def copy_post_files(post)
|
36
36
|
|
37
|
-
|
38
|
-
postdir = File.dirname(postpath)
|
39
|
-
destdir = File.dirname(post.destination(""))
|
40
|
-
|
37
|
+
post_path = post.path
|
41
38
|
site = post.site
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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])
|
46
72
|
site.static_files <<
|
47
|
-
PostFile.new(site,
|
73
|
+
PostFile.new(site, site_src_dir, filedir, filename, dest_dir)
|
48
74
|
end
|
49
75
|
end
|
50
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-postfiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.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: 2017-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|