jekyll-bookshop 1.1.8 → 1.4.6

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: 74dd846a69c8b663995ddfd47424d095ba5f71016d2ee1f614782b7728ae45b8
4
- data.tar.gz: 535d1e0314519f8103e488adfa3a3b98a33d9272ca23a4a97112629864f66450
3
+ metadata.gz: c7dd4ef9bde09e47ceb17a1513634053ecec2559487cdf7d70c4979da29cb54d
4
+ data.tar.gz: 3249af02f3aa9014c62101f8c82cdde9f533a9ef5c5bc29262e6cafed69f0241
5
5
  SHA512:
6
- metadata.gz: 6123421fb0ba0028c5ea03a271ab4f208b8a9d9101f033440a2d312e89709950ad33b95bed195bb9fdf4adb12c3e9d87868e339495d0840bab928624ec8847a6
7
- data.tar.gz: 113a04a56c3dc756b94e4b85e3ec7dae482374681ec3cadec5a8db2063244164a08e1d15e6b42d38e5133c1c006edce859f64ff0ad5b85dce339bc699db54ad4
6
+ metadata.gz: e57ad713b8e3c127bf7c6f011b1d549e673c466df55b6f6545411af6b907555f980ed55272edff89581477bb117abc88d001627d790934a6684b26612624307f
7
+ data.tar.gz: ea2368741bd50509f51777c67144c808bc5dbc36fb937baaa010bf9666fe6f95756b81aa803628ba28152bc32a8cf8180e41ae358119076c1e5d7d3a131653db
@@ -3,19 +3,59 @@ require 'pathname'
3
3
 
4
4
  module JekyllBookshop
5
5
  class Tag < Jekyll::Tags::IncludeTag
6
- def initialize(tag_name, markup, tokens)
7
- cname = markup.strip.partition(" ").first
8
- tag = markup.strip.partition(" ").last
9
- markup = "#{cname}.jekyll.html #{tag}"
10
- super
11
- end
12
6
 
7
+ # Look for includes in the built bookshop directory
13
8
  def tag_includes_dirs(context)
14
9
  Array(Pathname.new(context['site']['bookshop_path'] + '/components').cleanpath.to_s).freeze
15
10
  end
11
+
12
+ # Support the bind syntax, spreading an object into params
13
+ def parse_params(context)
14
+ params = super
15
+
16
+ params.each do |key, value|
17
+ if key == 'bind'
18
+ valueHash = {}.merge(value)
19
+ params = valueHash.merge(params)
20
+ next
21
+ end
22
+ end
23
+
24
+ params
25
+ end
26
+
27
+ # Map component names to the .jekyll.html files found in bookshop
28
+ def render(context)
29
+ site = context.registers[:site]
30
+
31
+ file = render_variable(context) || @file
32
+ cname = file.strip.split("/").last
33
+ file = "#{file}/#{cname}.jekyll.html"
34
+ validate_file_name(file)
35
+
36
+ path = locate_include_file(context, file, site.safe)
37
+ return unless path
38
+
39
+ add_include_to_dependency(site, path, context)
40
+
41
+ partial = load_cached_partial(path, context)
42
+
43
+ context.stack do
44
+ context["include"] = parse_params(context) if @params
45
+ begin
46
+ partial.render!(context)
47
+ rescue Liquid::Error => e
48
+ e.template_name = path
49
+ e.markup_context = "included " if e.markup_context.nil?
50
+ raise e
51
+ end
52
+ end
53
+ end
16
54
  end
17
55
 
18
56
  class Styles
57
+
58
+ # Add the paths to find bookshop's styles
19
59
  def self.open_bookshop(site)
20
60
  bookshop_path = site.theme.root + '/_bookshop'
21
61
  site.config['bookshop_path'] = Pathname.new(bookshop_path).cleanpath.to_s
@@ -24,10 +64,33 @@ module JekyllBookshop
24
64
  site.config['sass']['load_paths'].push(Pathname.new(bookshop_path + '/sass').cleanpath.to_s)
25
65
  end
26
66
  end
67
+
68
+ module Filters
69
+ def addmods(classname, mods = {})
70
+ base = classname.partition(" ").first
71
+ mods.each do |mod|
72
+ if mod[1]
73
+ classname = "#{classname} #{base}--#{mod[0]}"
74
+ end
75
+ end
76
+ return classname
77
+ end
78
+
79
+ def addstates(classname, states = {})
80
+ states.each do |state|
81
+ if state[1]
82
+ classname = "#{classname} is-#{state[0]}"
83
+ end
84
+ end
85
+ return classname
86
+ end
87
+ end
27
88
  end
28
89
 
29
90
  Liquid::Template.register_tag("component", JekyllBookshop::Tag)
30
91
 
92
+ Liquid::Template.register_filter(JekyllBookshop::Filters)
93
+
31
94
  Jekyll::Hooks.register :site, :after_init do |site|
32
95
  JekyllBookshop::Styles.open_bookshop(site)
33
96
  end
@@ -0,0 +1,3 @@
1
+ module JekyllBookshop
2
+ VERSION = "1.4.6"
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.8
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liam Bigelow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-31 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -38,6 +38,7 @@ extensions: []
38
38
  extra_rdoc_files: []
39
39
  files:
40
40
  - lib/jekyll-bookshop.rb
41
+ - lib/jekyll-bookshop/version.rb
41
42
  homepage: https://github.com/cloudcannon/bookshop
42
43
  licenses:
43
44
  - MIT