jekyll-bookshop 2.0.0.pre.beta.8 → 2.0.0.pre.beta.12

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: f27d3ef56987d4cb0697e1b1b76ffb7dbaf14bf1e0d664a8fd8b8e189a3ea19d
4
- data.tar.gz: bf1cabac88826cd381d42ccb7d71a0621ebaeefa42b12eba67e770db1a837685
3
+ metadata.gz: 1c27acbf119b2591a6bf5338666e2e6d4e31c019d45e462a38fb8479b6138f45
4
+ data.tar.gz: ed5d3f499e7466724f504f545eef5ed513a28c2e378b512f0e860490f699ab39
5
5
  SHA512:
6
- metadata.gz: db0d31e14a9d37245d1be758b477ff320433632229f5070944272e84a79646f1ee97c95a8a77fffb528bef2359c4d9c62ba695cc3e632c956b0c58b263563c56
7
- data.tar.gz: 1313d6d992b35e8aaae6f94528506c91a07e04c3dd577fef626f6779156cd15f0d7e3abb51b6119cf8275847bbc9c4449b510f74085b90ea2e9f0f966b23171c
6
+ metadata.gz: a9c6c4c80fa1c79efe7cbea55a1b05698ed527d3a13ba4ea534df5600044e80cf589ff49e4f69810e982c14e138f47a94fdc67f832171e2f86c11d6210287f1a
7
+ data.tar.gz: c8aae3e4cd0739e5737976df7c18df5f13d953268ca0926cc50b49f664a4959104f798bc1eecf496ba516215a09e23dfb5b6c4c2f5bfbcf5676548fd47574f0e
@@ -4,18 +4,21 @@ require "jekyll"
4
4
  require "pathname"
5
5
  require "dry/inflector"
6
6
 
7
+ require_relative "jekyll-bookshop/tags/bookshop-common-tag"
8
+ require_relative "jekyll-bookshop/tags/bookshop-include-tag"
7
9
  require_relative "jekyll-bookshop/tags/bookshop-tag"
8
10
  require_relative "jekyll-bookshop/tags/browser-tag"
9
11
  require_relative "jekyll-bookshop/tags/style-tag"
10
- require_relative "jekyll-bookshop/init-styles"
12
+ require_relative "jekyll-bookshop/opener"
11
13
  require_relative "jekyll-bookshop/site-data"
12
14
 
13
15
  Liquid::Template.register_tag("bookshop", JekyllBookshop::Tag)
16
+ Liquid::Template.register_tag("bookshop_include", JekyllBookshop::IncludeTag)
14
17
  Liquid::Template.register_tag("bookshop_scss", JekyllBookshop::StyleTag)
15
18
  Liquid::Template.register_tag("bookshop_browser", JekyllBookshop::BrowserTag)
16
19
 
17
20
  Jekyll::Hooks.register :site, :after_init do |site|
18
- JekyllBookshop::Styles.open_bookshop(site)
21
+ JekyllBookshop::Opener.open_bookshop(site)
19
22
  end
20
23
 
21
24
  Jekyll::Hooks.register :site, :post_render do |site|
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllBookshop
4
- class Styles
5
- # Add the paths to find bookshop's styles
4
+ class Opener
5
+ # Add the paths to find bookshop(s)
6
6
  def self.open_bookshop(site)
7
7
  return unless site.config["bookshop_locations"]
8
8
 
9
9
  bookshop_base_locations = filter_bookshops(site.source, site.config["bookshop_locations"])
10
10
  bookshop_component_locations = bookshop_component_locations(bookshop_base_locations)
11
+ bookshop_shared_locations = bookshop_shared_locations(bookshop_base_locations)
11
12
 
12
13
  site.config["sass"] ||= {}
13
14
 
@@ -16,6 +17,7 @@ module JekyllBookshop
16
17
  apply_array(site.config, "watch_dirs", bookshop_base_locations)
17
18
  apply_array(site.config, "bookshop_base_locations", bookshop_base_locations)
18
19
  apply_array(site.config, "bookshop_component_locations", bookshop_component_locations)
20
+ apply_array(site.config, "bookshop_shared_locations", bookshop_shared_locations)
19
21
  end
20
22
 
21
23
  def self.filter_bookshops(src, locations)
@@ -33,6 +35,12 @@ module JekyllBookshop
33
35
  end
34
36
  end
35
37
 
38
+ def self.bookshop_shared_locations(locations)
39
+ locations&.collect do |location|
40
+ Pathname.new("#{location}/shared/jekyll/").cleanpath.to_s
41
+ end
42
+ end
43
+
36
44
  def self.apply_array(hash, key, arr)
37
45
  hash[key] ||= []
38
46
  hash[key].push(*arr)
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllBookshop
4
+ class CommonTag < Jekyll::Tags::IncludeTag
5
+ # Support the bind syntax, spreading an object into params
6
+ def parse_params(context)
7
+ params = super
8
+
9
+ params.each do |key, value|
10
+ next unless key == "bind" && value.is_a?(Hash)
11
+
12
+ value_hash = {}.merge(value)
13
+ params = value_hash.merge(params)
14
+ next
15
+ end
16
+
17
+ params.delete("bind")
18
+
19
+ params
20
+ end
21
+
22
+ def render_once_found(context, file)
23
+ site = context.registers[:site]
24
+ validate_file_name(file)
25
+
26
+ path = locate_include_file(context, file, site.safe)
27
+ return unless path
28
+
29
+ add_include_to_dependency(site, path, context)
30
+
31
+ partial = load_cached_partial(path, context)
32
+
33
+ context.stack do
34
+ context["include"] = parse_params(context) if @params
35
+ begin
36
+ partial.render!(context)
37
+ rescue Liquid::Error => e
38
+ e.template_name = path
39
+ e.markup_context = "included " if e.markup_context.nil?
40
+ raise e
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllBookshop
4
+ class IncludeTag < JekyllBookshop::CommonTag
5
+ # Look for includes in the built bookshop directory
6
+ def tag_includes_dirs(context)
7
+ context["site"]["bookshop_shared_locations"].freeze
8
+ end
9
+
10
+ # Map include names to the .jekyll.html files found in bookshop
11
+ def render(context)
12
+ file = render_variable(context) || @file
13
+
14
+ file = "#{file}.jekyll.html"
15
+ render_once_found(context, file)
16
+ end
17
+ end
18
+ end
@@ -1,56 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllBookshop
4
- class Tag < Jekyll::Tags::IncludeTag
4
+ class Tag < JekyllBookshop::CommonTag
5
5
  # Look for includes in the built bookshop directory
6
6
  def tag_includes_dirs(context)
7
7
  context["site"]["bookshop_component_locations"].freeze
8
8
  end
9
9
 
10
- # Support the bind syntax, spreading an object into params
11
- def parse_params(context)
12
- params = super
13
-
14
- params.each do |key, value|
15
- next unless key == "bind" && value.is_a?(Hash)
16
-
17
- value_hash = {}.merge(value)
18
- params = value_hash.merge(params)
19
- next
20
- end
21
-
22
- params.delete("bind")
23
-
24
- params
25
- end
26
-
27
10
  # Map component names to the .jekyll.html files found in bookshop
28
11
  def render(context)
29
- site = context.registers[:site]
30
-
31
12
  file = render_variable(context) || @file
32
13
 
33
14
  cname = file.strip.split("/").last
34
15
  file = "#{file}/#{cname}.jekyll.html"
35
- validate_file_name(file)
36
-
37
- path = locate_include_file(context, file, site.safe)
38
- return unless path
39
-
40
- add_include_to_dependency(site, path, context)
41
-
42
- partial = load_cached_partial(path, context)
43
-
44
- context.stack do
45
- context["include"] = parse_params(context) if @params
46
- begin
47
- partial.render!(context)
48
- rescue Liquid::Error => e
49
- e.template_name = path
50
- e.markup_context = "included " if e.markup_context.nil?
51
- raise e
52
- end
53
- end
16
+ render_once_found(context, file)
54
17
  end
55
18
  end
56
19
  end
@@ -18,7 +18,20 @@ module JekyllBookshop
18
18
  "@import \"#{file}\";"
19
19
  end
20
20
 
21
- "@media all, bookshop {#{bookshop_scss_files.join("\n")}}"
21
+ bookshop_scss_files.sort! do |a, b|
22
+ a_shared = a.match(%r!"shared\/!)
23
+ b_shared = b.match(%r!"shared\/!)
24
+ case
25
+ when a_shared && !b_shared
26
+ -1
27
+ when !a_shared && b_shared
28
+ 1
29
+ else
30
+ a <=> b
31
+ end
32
+ end
33
+
34
+ "@media all, bookshop {#{bookshop_scss_files.join("")}}"
22
35
  end
23
36
  end
24
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllBookshop
4
- VERSION = "2.0.0.pre.beta.8"
4
+ VERSION = "2.0.0.pre.beta.12"
5
5
  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: 2.0.0.pre.beta.8
4
+ version: 2.0.0.pre.beta.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - CloudCannon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-03 00:00:00.000000000 Z
11
+ date: 2021-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -86,8 +86,10 @@ extensions: []
86
86
  extra_rdoc_files: []
87
87
  files:
88
88
  - lib/jekyll-bookshop.rb
89
- - lib/jekyll-bookshop/init-styles.rb
89
+ - lib/jekyll-bookshop/opener.rb
90
90
  - lib/jekyll-bookshop/site-data.rb
91
+ - lib/jekyll-bookshop/tags/bookshop-common-tag.rb
92
+ - lib/jekyll-bookshop/tags/bookshop-include-tag.rb
91
93
  - lib/jekyll-bookshop/tags/bookshop-tag.rb
92
94
  - lib/jekyll-bookshop/tags/browser-tag.rb
93
95
  - lib/jekyll-bookshop/tags/style-tag.rb