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 +4 -4
- data/lib/jekyll-bookshop.rb +80 -11
- data/lib/jekyll-bookshop/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aa1795f0a5014047a0b8cfb8609c7823b7d2c7bbf77fe8407eb9bd1253fb2bb
|
4
|
+
data.tar.gz: 83960fdbd3ffa085318d97dc88585fe834e4a6ad2fb9d8df37cc9e857f14cd36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50bd3c38d1908c97a4383528b41cd50058734ba6122b45ee06009700f49b07d56bccdd4b15beb2f60a88f536d73335519d5ae294511ec05d572b3f5fab7df68c
|
7
|
+
data.tar.gz: ae5991b08a43512539b82306083253a869c8984be25a4b7e16cc700119ece2142b3f1b189047e4161c7108fbdbdbd039899d6fcf844cf3df3fb15c4a4bac6a69
|
data/lib/jekyll-bookshop.rb
CHANGED
@@ -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(
|
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
|
-
|
22
|
-
site.
|
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(
|
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
|
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.
|
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-
|
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: []
|