jekyll-dice-tray 0.3.0 → 0.3.1
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 +4 -4
- data/README.md +1 -1
- data/lib/jekyll/dice_tray/config.rb +26 -0
- data/lib/jekyll/dice_tray/generator.rb +2 -4
- data/lib/jekyll/dice_tray/hooks.rb +1 -4
- data/lib/jekyll/dice_tray/version.rb +1 -1
- data/lib/jekyll-dice-tray.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3f1058c6701f813bd5bef233707af9e65bc2b1876de92db04675158a71a0adab
|
|
4
|
+
data.tar.gz: 6550e68c8ef38aaefebffb822c85c4090402fbfda41585f3ece54f36a1bddf7b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b5f1d58cfcced42951de3dc03660c4c1d683a7a8523af220d1817c0cf610935383a48f4e20b58409920cce03b2654040ce8a6e7ae753eb2971f5972576ad2fe
|
|
7
|
+
data.tar.gz: ecf24959ae7c875c23923be6b231ea494fc4d7fa9d0837f8567a1b161e9120f9a48de4fb76e58522a3751697213469a6bf92f6abdaf25491792ebdd99a7b4627
|
data/README.md
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Jekyll
|
|
2
|
+
module DiceTray
|
|
3
|
+
module Config
|
|
4
|
+
DEFAULT_ASSETS_PATH = "/assets/jekyll-dice-tray"
|
|
5
|
+
|
|
6
|
+
# Site-relative directory for writing static assets (no baseurl).
|
|
7
|
+
def self.assets_dir(site)
|
|
8
|
+
path = configured_path(site)
|
|
9
|
+
path.sub(%r{\A/}, "")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# URL path for linking assets in HTML (includes baseurl).
|
|
13
|
+
def self.assets_url(site)
|
|
14
|
+
baseurl = site.config["baseurl"].to_s.chomp("/")
|
|
15
|
+
"#{baseurl}#{configured_path(site)}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.configured_path(site)
|
|
19
|
+
cfg = site.config["dice_tray"] || {}
|
|
20
|
+
path = (cfg["assets_path"] || DEFAULT_ASSETS_PATH).to_s
|
|
21
|
+
path.start_with?("/") ? path : "/#{path}"
|
|
22
|
+
end
|
|
23
|
+
private_class_method :configured_path
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -8,10 +8,8 @@ module Jekyll
|
|
|
8
8
|
cfg = (site.config["dice_tray"] || {})
|
|
9
9
|
return if cfg["enabled"] == false
|
|
10
10
|
|
|
11
|
-
assets_path = cfg["assets_path"] || "/assets/jekyll-dice-tray"
|
|
12
|
-
assets_path = "/#{assets_path}" unless assets_path.start_with?("/")
|
|
13
|
-
|
|
14
11
|
asset_dir = File.expand_path("../../../assets/jekyll-dice-tray", __dir__)
|
|
12
|
+
dest_dir = Config.assets_dir(site)
|
|
15
13
|
|
|
16
14
|
files = {
|
|
17
15
|
"dice_tray.js" => File.join(asset_dir, "dice_tray.js"),
|
|
@@ -23,7 +21,7 @@ module Jekyll
|
|
|
23
21
|
site.static_files << AssetFile.new(
|
|
24
22
|
site,
|
|
25
23
|
site.source,
|
|
26
|
-
|
|
24
|
+
dest_dir,
|
|
27
25
|
name,
|
|
28
26
|
source_path: source_path
|
|
29
27
|
)
|
|
@@ -8,13 +8,10 @@ module Jekyll
|
|
|
8
8
|
next if cfg["enabled"] == false
|
|
9
9
|
next unless doc.respond_to?(:output_ext) && doc.output_ext == ".html"
|
|
10
10
|
|
|
11
|
-
assets_path = cfg["assets_path"] || "/assets/jekyll-dice-tray"
|
|
12
|
-
assets_path = "/#{assets_path}" unless assets_path.start_with?("/")
|
|
13
|
-
|
|
14
11
|
begin
|
|
15
12
|
out = doc.output.to_s
|
|
16
13
|
out = HtmlRewriter.rewrite(out) if cfg.fetch("link_dice_in_markdown", true)
|
|
17
|
-
out = HtmlRewriter.inject_tray(out, assets_path:
|
|
14
|
+
out = HtmlRewriter.inject_tray(out, assets_path: Config.assets_url(site)) if cfg.fetch("inject_tray", true)
|
|
18
15
|
doc.output = out
|
|
19
16
|
rescue StandardError => e
|
|
20
17
|
Jekyll.logger.warn("jekyll-dice-tray:", "Failed to process #{doc.relative_path}: #{e.class}: #{e.message}")
|
data/lib/jekyll-dice-tray.rb
CHANGED
|
@@ -2,6 +2,7 @@ require "jekyll"
|
|
|
2
2
|
require "nokogiri"
|
|
3
3
|
|
|
4
4
|
require_relative "jekyll/dice_tray/version"
|
|
5
|
+
require_relative "jekyll/dice_tray/config"
|
|
5
6
|
require_relative "jekyll/dice_tray/asset_file"
|
|
6
7
|
require_relative "jekyll/dice_tray/generator"
|
|
7
8
|
require_relative "jekyll/dice_tray/html_rewriter"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-dice-tray
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- directsun
|
|
@@ -54,6 +54,7 @@ files:
|
|
|
54
54
|
- assets/jekyll-dice-tray/dice_tray.js
|
|
55
55
|
- lib/jekyll-dice-tray.rb
|
|
56
56
|
- lib/jekyll/dice_tray/asset_file.rb
|
|
57
|
+
- lib/jekyll/dice_tray/config.rb
|
|
57
58
|
- lib/jekyll/dice_tray/generator.rb
|
|
58
59
|
- lib/jekyll/dice_tray/hooks.rb
|
|
59
60
|
- lib/jekyll/dice_tray/html_rewriter.rb
|