jekyll-bookshop 2.0.0.pre.alpha.51 → 2.0.0.pre.beta.2
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 +2 -0
- data/lib/jekyll-bookshop/site-data.rb +15 -0
- data/lib/jekyll-bookshop/tags/browser-tag.rb +28 -0
- data/lib/jekyll-bookshop/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e041dbf2b970cf5a28fbbfbc57c1b90a94b592ee7badd14e2486ef3d9eb8ffe9
|
4
|
+
data.tar.gz: 1a37979335470ddb4ce0be4f8c715ca7a1826aa4e7336e0635c9710d843919d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f82ad31ada15033bfe6a6b8aafce9c88f826dff454dfa17324a3dde8d98bbf8bad73f3cdb9978b07562aa2738e958381b0719743bf50fdf19ccbaf774956a2b2
|
7
|
+
data.tar.gz: de39014b0eab7c14da7e8c6950f5566dce1b4515a93e50c702d2187bcf81b39bc6ff4087b739d9a510124f82e923226e52a0e3470c5fc4f021aaa68254a72e4c
|
data/lib/jekyll-bookshop.rb
CHANGED
@@ -5,12 +5,14 @@ require "pathname"
|
|
5
5
|
require "dry/inflector"
|
6
6
|
|
7
7
|
require_relative "jekyll-bookshop/tags/bookshop-tag"
|
8
|
+
require_relative "jekyll-bookshop/tags/browser-tag"
|
8
9
|
require_relative "jekyll-bookshop/tags/style-tag"
|
9
10
|
require_relative "jekyll-bookshop/init-styles"
|
10
11
|
require_relative "jekyll-bookshop/site-data"
|
11
12
|
|
12
13
|
Liquid::Template.register_tag("bookshop", JekyllBookshop::Tag)
|
13
14
|
Liquid::Template.register_tag("bookshop_scss", JekyllBookshop::StyleTag)
|
15
|
+
Liquid::Template.register_tag("bookshop_browser", JekyllBookshop::BrowserTag)
|
14
16
|
|
15
17
|
Jekyll::Hooks.register :site, :after_init do |site|
|
16
18
|
JekyllBookshop::Styles.open_bookshop(site)
|
@@ -20,6 +20,9 @@ module JekyllBookshop
|
|
20
20
|
end
|
21
21
|
|
22
22
|
@site.data["_bookshop_site_data"] = { "site" => payload_collections }
|
23
|
+
|
24
|
+
update_browser_pages
|
25
|
+
|
23
26
|
Jekyll.logger.info "Bookshop:",
|
24
27
|
"Bookshop site data generated"
|
25
28
|
end
|
@@ -36,5 +39,17 @@ module JekyllBookshop
|
|
36
39
|
"excerpt" => document.data["excerpt"].output,
|
37
40
|
})
|
38
41
|
end
|
42
|
+
|
43
|
+
def self.update_browser_pages
|
44
|
+
@site.pages.each do |page|
|
45
|
+
next unless @site.data["_bookshop_data_pages"]&.include?(page.url)
|
46
|
+
|
47
|
+
page.output = page.output.gsub(
|
48
|
+
%r!bookshop_browser_site_data = null!,
|
49
|
+
"bookshop_browser_site_data = #{@site.data["_bookshop_site_data"].to_json}"
|
50
|
+
)
|
51
|
+
end
|
52
|
+
@site.data["_bookshop_data_pages"] = nil
|
53
|
+
end
|
39
54
|
end
|
40
55
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllBookshop
|
4
|
+
class BrowserTag < Liquid::Tag
|
5
|
+
def initialize(tag_name, markup, tokens)
|
6
|
+
super
|
7
|
+
@host = markup.strip
|
8
|
+
end
|
9
|
+
|
10
|
+
def render(context)
|
11
|
+
return unless @host
|
12
|
+
return if Jekyll.env == "production"
|
13
|
+
|
14
|
+
site = context.registers[:site]
|
15
|
+
page = context.registers[:page]
|
16
|
+
|
17
|
+
site.data["_bookshop_data_pages"] ||= []
|
18
|
+
unless site.data["_bookshop_data_pages"].include?(page["url"])
|
19
|
+
site.data["_bookshop_data_pages"].push(page["url"])
|
20
|
+
end
|
21
|
+
|
22
|
+
"<div data-bookshop-browser></div>
|
23
|
+
<script>window.bookshop_browser_site_data = null;</script>
|
24
|
+
<script src=\"//#{@host}\"></script>
|
25
|
+
<script>window.BookshopBrowser = new window.BookshopBrowserClass(); window.BookshopBrowser.render();</script>"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
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.
|
4
|
+
version: 2.0.0.pre.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CloudCannon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/jekyll-bookshop/init-styles.rb
|
90
90
|
- lib/jekyll-bookshop/site-data.rb
|
91
91
|
- lib/jekyll-bookshop/tags/bookshop-tag.rb
|
92
|
+
- lib/jekyll-bookshop/tags/browser-tag.rb
|
92
93
|
- lib/jekyll-bookshop/tags/style-tag.rb
|
93
94
|
- lib/jekyll-bookshop/version.rb
|
94
95
|
homepage: https://github.com/cloudcannon/bookshop
|