jekyll-bookshop 1.1.10 → 1.5.0

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
  SHA256:
3
- metadata.gz: 651a1f61d8d1f760073e0575aa607cf5ea14bfc2fb32adfc2a9644424dbcb704
4
- data.tar.gz: 4563c66b5438da4d9d02aba4d2fd84340b54616dd1f0279e381007aabf9491fc
3
+ metadata.gz: 3aa1795f0a5014047a0b8cfb8609c7823b7d2c7bbf77fe8407eb9bd1253fb2bb
4
+ data.tar.gz: 83960fdbd3ffa085318d97dc88585fe834e4a6ad2fb9d8df37cc9e857f14cd36
5
5
  SHA512:
6
- metadata.gz: a37fa18b049134dd25b41bd409890eafaa8593181bc42e942090fd8f539f8409466fabe64504b368502a4e90c94bd022396cdf2901b31dd3d92254832d6b438f
7
- data.tar.gz: 0ee2cc741ec67ade5198f7dde105d25cf585615bfef53034f83a48745c3cb8492eaccbfffde18869c2b689c866ab960d9f3b68e796c4baf03131d4b0ed97c18d
6
+ metadata.gz: 50bd3c38d1908c97a4383528b41cd50058734ba6122b45ee06009700f49b07d56bccdd4b15beb2f60a88f536d73335519d5ae294511ec05d572b3f5fab7df68c
7
+ data.tar.gz: ae5991b08a43512539b82306083253a869c8984be25a4b7e16cc700119ece2142b3f1b189047e4161c7108fbdbdbd039899d6fcf844cf3df3fb15c4a4bac6a69
@@ -3,32 +3,101 @@ require 'pathname'
3
3
 
4
4
  module JekyllBookshop
5
5
  class Tag < Jekyll::Tags::IncludeTag
6
- def initialize(tag_name, markup, tokens)
7
- cpath = markup.strip.partition(" ").first
8
- cname = cpath.strip.split("/").last
9
- tag = markup.strip.partition(" ").last
10
- markup = "#{cpath}/#{cname}.jekyll.html #{tag}"
11
- super
12
- end
13
6
 
7
+ # Look for includes in the built bookshop directory
14
8
  def tag_includes_dirs(context)
15
- Array(Pathname.new(context['site']['bookshop_path'] + '/components').cleanpath.to_s).freeze
9
+ Array([
10
+ Pathname.new(context['site']['bookshop_theme_path'] + '/components').cleanpath.to_s,
11
+ Pathname.new(context['site']['bookshop_site_path'] + '/components').cleanpath.to_s
12
+ ]).freeze
13
+ end
14
+
15
+ # Support the bind syntax, spreading an object into params
16
+ def parse_params(context)
17
+ params = super
18
+
19
+ params.each do |key, value|
20
+ if key == 'bind'
21
+ valueHash = {}.merge(value)
22
+ params = valueHash.merge(params)
23
+ next
24
+ end
25
+ end
26
+
27
+ params
28
+ end
29
+
30
+ # Map component names to the .jekyll.html files found in bookshop
31
+ def render(context)
32
+ site = context.registers[:site]
33
+
34
+ file = render_variable(context) || @file
35
+ cname = file.strip.split("/").last
36
+ file = "#{file}/#{cname}.jekyll.html"
37
+ validate_file_name(file)
38
+
39
+ path = locate_include_file(context, file, site.safe)
40
+ return unless path
41
+
42
+ add_include_to_dependency(site, path, context)
43
+
44
+ partial = load_cached_partial(path, context)
45
+
46
+ context.stack do
47
+ context["include"] = parse_params(context) if @params
48
+ begin
49
+ partial.render!(context)
50
+ rescue Liquid::Error => e
51
+ e.template_name = path
52
+ e.markup_context = "included " if e.markup_context.nil?
53
+ raise e
54
+ end
55
+ end
16
56
  end
17
57
  end
18
58
 
19
59
  class Styles
60
+
61
+ # Add the paths to find bookshop's styles
20
62
  def self.open_bookshop(site)
21
- bookshop_path = site.theme.root + '/_bookshop'
22
- site.config['bookshop_path'] = Pathname.new(bookshop_path).cleanpath.to_s
63
+ bookshop_theme_path = site.theme.root + '/_bookshop'
64
+ bookshop_site_path = site.source + '/_bookshop'
65
+ site.config['bookshop_theme_path'] = Pathname.new(bookshop_theme_path).cleanpath.to_s
66
+ site.config['bookshop_site_path'] = Pathname.new(bookshop_site_path).cleanpath.to_s
67
+
23
68
  site.config['sass'] ||= {}
24
69
  site.config['sass']['load_paths'] ||= []
25
- site.config['sass']['load_paths'].push(Pathname.new(bookshop_path + '/sass').cleanpath.to_s)
70
+ site.config['sass']['load_paths'].push(Pathname.new(bookshop_theme_path + '/sass').cleanpath.to_s)
71
+ site.config['sass']['load_paths'].push(Pathname.new(bookshop_site_path + '/sass').cleanpath.to_s)
72
+ end
73
+ end
74
+
75
+ module Filters
76
+ def addmods(classname, mods = {})
77
+ base = classname.partition(" ").first
78
+ mods.each do |mod|
79
+ if mod[1]
80
+ classname = "#{classname} #{base}--#{mod[0]}"
81
+ end
82
+ end
83
+ return classname
84
+ end
85
+
86
+ def addstates(classname, states = {})
87
+ states.each do |state|
88
+ if state[1]
89
+ classname = "#{classname} is-#{state[0]}"
90
+ end
91
+ end
92
+ return classname
26
93
  end
27
94
  end
28
95
  end
29
96
 
30
97
  Liquid::Template.register_tag("component", JekyllBookshop::Tag)
31
98
 
99
+ Liquid::Template.register_filter(JekyllBookshop::Filters)
100
+
32
101
  Jekyll::Hooks.register :site, :after_init do |site|
33
102
  JekyllBookshop::Styles.open_bookshop(site)
34
103
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllBookshop
2
- VERSION = "1.1.10"
2
+ VERSION = "1.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-bookshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam Bigelow
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-01 00:00:00.000000000 Z
11
+ date: 2020-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -30,7 +30,7 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5.0'
33
- description:
33
+ description:
34
34
  email:
35
35
  - liam@cloudcannon.com
36
36
  executables: []
@@ -43,7 +43,7 @@ homepage: https://github.com/cloudcannon/bookshop
43
43
  licenses:
44
44
  - MIT
45
45
  metadata: {}
46
- post_install_message:
46
+ post_install_message:
47
47
  rdoc_options: []
48
48
  require_paths:
49
49
  - lib
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubygems_version: 3.0.3
62
- signing_key:
62
+ signing_key:
63
63
  specification_version: 4
64
64
  summary: A Jekyll plugin to load components from bookshop
65
65
  test_files: []