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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f27d3ef56987d4cb0697e1b1b76ffb7dbaf14bf1e0d664a8fd8b8e189a3ea19d
4
- data.tar.gz: bf1cabac88826cd381d42ccb7d71a0621ebaeefa42b12eba67e770db1a837685
3
+ metadata.gz: dd40943498b351831024f7796ec3da26eb281de58b7582209d53ae73b26d1f7a
4
+ data.tar.gz: c855b383bb59faa1b3ad04c4c398766c4751a5df793e56c8c2833e9f3bc96f3e
5
5
  SHA512:
6
- metadata.gz: db0d31e14a9d37245d1be758b477ff320433632229f5070944272e84a79646f1ee97c95a8a77fffb528bef2359c4d9c62ba695cc3e632c956b0c58b263563c56
7
- data.tar.gz: 1313d6d992b35e8aaae6f94528506c91a07e04c3dd577fef626f6779156cd15f0d7e3abb51b6119cf8275847bbc9c4449b510f74085b90ea2e9f0f966b23171c
6
+ metadata.gz: 5bf12649b6fd959511278c02306b02ca82ec583f535788dfee2d4293167d41cde749dc6884c9a520dcf5ca5c001b435a9378b6b17fda125b063ab6b0c304d126
7
+ data.tar.gz: 0f66fde3cadcf3f8f901c2ab2d77ff5328af7d0c39758de2182d0d7dfdf7fd4afb1d1f4fb43b68d131d9b8480b7ac82392d9734e42f291da613518fd193e47cc
@@ -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
@@ -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.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - CloudCannon
@@ -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