jekyll-bookshop 2.6.0 → 3.0.0.pre.beta.1

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: 8516c5306d5e873f6f3be82b20c0fcc8ffc19b2ff94293b98a808417eb5a66cd
4
- data.tar.gz: 1af0b6a38187b7430237b51edec9df2b8385d8e24a6114d4ab1994d3262386b5
3
+ metadata.gz: afa118aafb4e947191251a4cac32e592ff1d94b5adc4d4464f22ccc10b515eb4
4
+ data.tar.gz: 6c8d5c082bc3875abdc9e703591ed7e6332f99e7bb1d7b477fb467d6a6e4629b
5
5
  SHA512:
6
- metadata.gz: b807a68fee6e59c93ea20bea6afe3857253abe731187f80cf3c1769014717cb1a79eb9a5c66fba5ddcca3a573f80f70bbf2dd73f43f568275cfce136ecad15a9
7
- data.tar.gz: 550619f34d58ed39441b2bd08753b9a30b860d72dbf25d5175efb8384d7f1a98bd90e29e3c284ee857a1f394cd3acfd79d7d9adfe5b3cb5e7621c400f74e056a
6
+ metadata.gz: 683693c767c8ad1aa0bcb1da03846affeaf739a9e2fff3705973bf85c0d50db2f68441ca14a622e284b49ec96ed2271f05bcd50eac0af714ad2cb34b281e7e23
7
+ data.tar.gz: 7a16097286b4363a31670b136f001939b223e7ab0dab83587b281f15e311fff53b80ba90147ec40809f47a74e1681e7d9499d2b0642b32edf48fd3f4c7ef899c
@@ -37,12 +37,17 @@ module JekyllBookshop
37
37
  loop_context = "#{name}[#{index}]"
38
38
  end
39
39
 
40
+ # If this component is not a subcomponent,
41
+ # we also drop in some site metadata here so that it can be used in the render.
42
+ meta_comment = context["__bookshop__nested"] ? "" : "<!--bookshop-live meta(version=\"#{JekyllBookshop::VERSION.gsub(".pre.", "-")}\" baseurl=\"#{site.baseurl}\" title=\"#{site.config["title"]&.gsub('"', '\"') || ""}\") -->\n"
43
+
40
44
  context.stack do
41
45
  context["include"] = parse_params(context) if @params
46
+ context["__bookshop__nested"] = true
42
47
  begin
43
- "<!--bookshop-live name(#{file}) params(#{@params}) context(#{loop_context.gsub(/-/, '=').gsub(/=include\./, '=')}) -->
44
- #{partial.render!(context)}
45
- <!--bookshop-live end-->"
48
+ "#{meta_comment}<!--bookshop-live name(#{file}) params(#{@params}) context(#{loop_context.gsub(/-/, '=').gsub(/=include\./, '=')}) -->
49
+ #{partial.render!(context)}
50
+ <!--bookshop-live end-->"
46
51
  rescue Liquid::Error => e
47
52
  e.template_name = path
48
53
  e.markup_context = "included " if e.markup_context.nil?
@@ -30,17 +30,11 @@ module JekyllBookshop
30
30
  site = context.registers[:site]
31
31
  page = context.registers[:page]
32
32
 
33
- site.data["_bookshop_data_pages"] ||= []
34
- unless site.data["_bookshop_data_pages"].include?(page["url"])
35
- site.data["_bookshop_data_pages"].push(page["url"])
36
- end
37
-
38
33
  "<div data-bookshop-browser></div>
39
- <script>window.bookshop_browser_site_data = null;</script>
40
34
  <script src=\"#{host}\"></script>
41
35
  <script>
42
36
  window.bookshopBrowser = new window.BookshopBrowser({
43
- globals: [window.bookshop_browser_site_data]
37
+ globals: []
44
38
  });
45
39
  window.bookshopBrowser.render();
46
40
  </script>"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllBookshop
4
- VERSION = "2.6.0"
4
+ VERSION = "3.0.0.pre.beta.1"
5
5
  end
@@ -10,7 +10,6 @@ require_relative "jekyll-bookshop/tags/bookshop-tag"
10
10
  require_relative "jekyll-bookshop/tags/browser-tag"
11
11
  require_relative "jekyll-bookshop/tags/style-tag"
12
12
  require_relative "jekyll-bookshop/opener"
13
- require_relative "jekyll-bookshop/site-data"
14
13
 
15
14
  Liquid::Template.register_tag("bookshop", JekyllBookshop::Tag)
16
15
  Liquid::Template.register_tag("bookshop_include", JekyllBookshop::IncludeTag)
@@ -20,7 +19,3 @@ Liquid::Template.register_tag("bookshop_browser", JekyllBookshop::BrowserTag)
20
19
  Jekyll::Hooks.register :site, :after_init do |site|
21
20
  JekyllBookshop::Opener.open_bookshop(site)
22
21
  end
23
-
24
- Jekyll::Hooks.register :site, :post_render do |site|
25
- JekyllBookshop::SiteData.extract(site)
26
- 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.6.0
4
+ version: 3.0.0.pre.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CloudCannon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-25 00:00:00.000000000 Z
11
+ date: 2022-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -87,7 +87,6 @@ extra_rdoc_files: []
87
87
  files:
88
88
  - lib/jekyll-bookshop.rb
89
89
  - lib/jekyll-bookshop/opener.rb
90
- - lib/jekyll-bookshop/site-data.rb
91
90
  - lib/jekyll-bookshop/tags/bookshop-common-tag.rb
92
91
  - lib/jekyll-bookshop/tags/bookshop-include-tag.rb
93
92
  - lib/jekyll-bookshop/tags/bookshop-tag.rb
@@ -109,9 +108,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
108
  version: '0'
110
109
  required_rubygems_version: !ruby/object:Gem::Requirement
111
110
  requirements:
112
- - - ">="
111
+ - - ">"
113
112
  - !ruby/object:Gem::Version
114
- version: '0'
113
+ version: 1.3.1
115
114
  requirements: []
116
115
  rubygems_version: 3.0.3
117
116
  signing_key:
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module JekyllBookshop
4
- class SiteData
5
- def self.extract(site)
6
- @site = site
7
-
8
- payload = {}
9
- @site.collections.each_pair do |collection, items|
10
- payload[collection] = items.docs.map do |doc|
11
- doc.data.merge(hydrate_document_fields(doc))
12
- end
13
- end
14
-
15
- payload["data"] = {}
16
- @site.data.each_pair do |key, value|
17
- next if key.to_s.start_with?("_bookshop")
18
-
19
- payload["data"][key] = value
20
- end
21
-
22
- payload["baseurl"] = @site.baseurl
23
- payload["title"] = @site.config["title"]
24
-
25
- @site.data["_bookshop_site_data"] = { "site" => payload }
26
-
27
- update_browser_pages
28
-
29
- Jekyll.logger.info "Bookshop:",
30
- "Bookshop site data generated"
31
- end
32
-
33
- def self.hydrate_document_fields(document)
34
- keys = %w(content url date relative_path permalink)
35
- hydrated_doc = {}
36
- keys.each { |key| hydrated_doc[key] = document.send(key) }
37
- hydrate_document_excerpt(document, hydrated_doc)
38
- end
39
-
40
- def self.hydrate_document_excerpt(document, hydrated_doc)
41
- hydrated_doc.merge!({
42
- "excerpt" => document.data["excerpt"].output,
43
- })
44
- end
45
-
46
- def self.update_browser_pages
47
- @site.pages.each do |page|
48
- next unless @site.data["_bookshop_data_pages"]&.include?(page.url)
49
-
50
- page.output = page.output.gsub(
51
- %r!bookshop_browser_site_data = null!,
52
- "bookshop_browser_site_data = #{@site.data["_bookshop_site_data"].to_json.gsub(%r!</script!i, "<\\/script")}"
53
- )
54
- end
55
- @site.data["_bookshop_data_pages"] = nil
56
- end
57
- end
58
- end