jekyll-postfiles 2.0.0 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83ecad5523c6564d8bf0f84674f54ba82295ca03
4
- data.tar.gz: 96a2acb28eb23d7771dcf2d845b4eed0f7f8a686
3
+ metadata.gz: 854c58ed5e01319e8160695c04e36f810ca219e7
4
+ data.tar.gz: 4ff8a95dc4238957e04ecb37d90316308df239bc
5
5
  SHA512:
6
- metadata.gz: c844451a153fa9dcd1451555b6839496f8ec43f30ae57e9cbf6435bd08eb1106860d77cc463e3b0fdd0573d1f00c9ce948dc4c666f9ec5fe6a06dbbaf4ed6114
7
- data.tar.gz: b645575e93dbff13c94582fbcc635f3423a7d39773ca161f650276aca43f62b9bb9ff57a16a8c10862e12f664ad224cf3c8a210e3776e880327e1ec5295bfdd4
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
- $ bundle
187
+ bundle
170
188
  ```
171
189
 
172
190
  And add this line to your `_config.yml`:
@@ -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
- postpath = post.path
38
- postdir = File.dirname(postpath)
39
- destdir = File.dirname(post.destination(""))
40
-
37
+ post_path = post.path
41
38
  site = post.site
42
- sitesrcdir = site.source
43
- contents = Dir.glob(File.join(postdir, '**', '*')) do |filepath|
44
- if filepath != postpath
45
- filedir, filename = File.split(filepath[sitesrcdir.length..-1])
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, sitesrcdir, filedir, filename, destdir)
73
+ PostFile.new(site, site_src_dir, filedir, filename, dest_dir)
48
74
  end
49
75
  end
50
76
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllPostFiles
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  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.0.0
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: 2016-08-04 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler