jekyll-theme-assets 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4237088ea7df170fa625470f79ec0fd4483dfff
4
- data.tar.gz: d81bdbe0fac7f5cf924a906d15ab308200a6649d
3
+ metadata.gz: 352fb7bbdf7b726c51e245e93fab2da3c0ce48bd
4
+ data.tar.gz: 437cdad5a0dd57ad721b85322d84f4aa411a34d9
5
5
  SHA512:
6
- metadata.gz: 7648b806e2a8cc1f17f596ac236e3c6e15631c232a7a0ccc8fd131e1bf6abb3d392176461bcba917cfef59346b966d9a8fda9a1d05653b11388086d215b920e1
7
- data.tar.gz: 5d46e922da4701b50f11a3b2a73d7facd85daaa23d416e4cdce0098d4f6213e5c36652305a95693a4b9039599820cb6fc76efaed1d849bedd2e86bf763c8ac82
6
+ metadata.gz: 0aee35aabcac549adcfb741f682e3855b967267d1e490a745175521b28d71e3afd7a84b03a98ddf9d47b04de74e8dc54f3c747e334eeeadef1eb17ac7d3f618a
7
+ data.tar.gz: 3479c1331328b82acf81b34a2ec2ea8a28a723102f0cccf551eb509609d1a809ecbf89d8c01d32352940f5c1433fe64a4e85bbea009f0ec00a9d7a5f87902206
@@ -1,17 +1,27 @@
1
1
  require 'jekyll-assets'
2
+ require 'theme'
2
3
 
3
4
  # Jekyll Assets hook to discover and register assets of a gem-based Jekyll theme.
4
5
  Jekyll::Assets::Hook.register :env, :init do
5
6
  # Nothing to do if there is no theme
6
7
  return unless jekyll.theme
7
- # Initialize
8
- assets_base = jekyll.theme.assets_path
8
+ # fetch from theme's "assets" folder
9
+ fetch_theme_assets(jekyll.theme.public_assets_path)
10
+ # fetch from theme's "_assets" folder
11
+ fetch_theme_assets(jekyll.theme.private_assets_path)
12
+ end
13
+
14
+ private
9
15
 
16
+ # Simple helper to fetch assets from theme
17
+ def fetch_theme_assets(base_path)
18
+ # Base path is resolved to nil unless it does exists
19
+ return unless base_path
10
20
  # Similar snippets could be found in Jekyll's code base (namely reader.rb)
11
- dot_sources = Dir.chdir(assets_base) { filter_entries(Dir.entries("."), assets_base) }
21
+ dot_sources = Dir.chdir(base_path) { filter_entries(Dir.entries("."), base_path) }
12
22
  dot_sources.each do |source|
13
23
  # TODO: Replace with the link to the original thread on Github on the subject...
14
- jekyll.sprockets.append_path(File.join(assets_base, source))
24
+ jekyll.sprockets.append_path(File.join(base_path, source))
15
25
  end
16
26
  end
17
27
 
@@ -0,0 +1,11 @@
1
+ # Lets extend base class with a few things to make our code
2
+ # less confusing (I hope that is the case LOL).
3
+ class Jekyll::Theme
4
+ # Our theme's public assets.
5
+ alias_method :public_assets_path, :assets_path
6
+
7
+ # Our theme's private assets.
8
+ def private_assets_path
9
+ path_for "_assets".freeze
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Tsurbeleu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-14 00:00:00.000000000 Z
11
+ date: 2017-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll-assets
@@ -86,8 +86,8 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '5.0'
89
- description: A Jekyll plugin, that allows you to use assets defined in a gem-based
90
- Jekyll theme.
89
+ description: A Jekyll plugin, that allows you to use private and public assets defined
90
+ in a gem-based Jekyll theme.
91
91
  email:
92
92
  - pavel.tsurbeleu@me.com
93
93
  executables: []
@@ -99,6 +99,7 @@ files:
99
99
  - README.md
100
100
  - Rakefile
101
101
  - lib/jekyll-theme-assets.rb
102
+ - lib/theme.rb
102
103
  homepage: https://github.com/ptsurbeleu/jekyll-theme-assets/
103
104
  licenses:
104
105
  - MIT