jekyll-workbox-plugin 0.0.1 → 0.0.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-workbox-plugin.rb +32 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff93700daea5a10de6770f6985dcc454a4149d11
|
4
|
+
data.tar.gz: b22530b99d82dc4f437d0c061ed18d98b46d94ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b2063f638aac7c439e92586ca0d387cc603dfbf02e5ed4a9330161a65cdd0c0f5bad57bfae12f8bcc10b05ad94b0a94018e2b26f7b945cc871fa16f1afa471a
|
7
|
+
data.tar.gz: 9137fefd76fe53a29272bdc3c3e675b1d73179efb695d3d8c11443d47d4e6406fd9a4dedd87e2d9c67470521128f091e1a0a494d9e4817bfe75ac2a5b6aedee5
|
@@ -21,8 +21,31 @@ class WorkboxHelper
|
|
21
21
|
# find precache files with glob
|
22
22
|
precache_files = []
|
23
23
|
patterns.each do |pattern|
|
24
|
-
|
25
|
-
|
24
|
+
name_to_aliases = {}
|
25
|
+
|
26
|
+
# this means there's no alias defined - just use file as only alias
|
27
|
+
if pattern.is_a?(String)
|
28
|
+
name_to_aliases = { pattern => pattern }
|
29
|
+
elsif pattern.is_a?(Hash)
|
30
|
+
name_to_aliases = pattern
|
31
|
+
end
|
32
|
+
|
33
|
+
# at this point, name_to_aliases is file -> alias or
|
34
|
+
# file -> [alias1, alias2], etc. there will never be more
|
35
|
+
# than one key per yaml conventions
|
36
|
+
filename, aliases = name_to_aliases.first
|
37
|
+
|
38
|
+
# glob the filename, and push all aliases as just values
|
39
|
+
Dir.glob(File.join(directory, filename)) do |filepath|
|
40
|
+
if aliases.is_a?(String)
|
41
|
+
file_alias = File.join(directory, aliases)
|
42
|
+
precache_files.push({ filepath => file_alias })
|
43
|
+
elsif aliases.is_a?(Array)
|
44
|
+
aliases.each do |filepath_alias|
|
45
|
+
file_alias = File.join(directory, filepath_alias)
|
46
|
+
precache_files.push({ filepath => file_alias })
|
47
|
+
end
|
48
|
+
end
|
26
49
|
end
|
27
50
|
end
|
28
51
|
precache_files = precache_files.uniq
|
@@ -35,7 +58,7 @@ class WorkboxHelper
|
|
35
58
|
.reverse.take(recent_posts_num)
|
36
59
|
.map do |post|
|
37
60
|
posts_path_url_map[post.path] = post.url
|
38
|
-
post.path
|
61
|
+
{ post.path => post.path }
|
39
62
|
end
|
40
63
|
)
|
41
64
|
end
|
@@ -43,19 +66,22 @@ class WorkboxHelper
|
|
43
66
|
# filter with ignores
|
44
67
|
ignores.each do |pattern|
|
45
68
|
Dir.glob(File.join(directory, pattern)) do |ignored_filepath|
|
46
|
-
precache_files.
|
69
|
+
precache_files = precache_files.select { |file_map|
|
70
|
+
file_map.first.first != ignored_filepath
|
71
|
+
}.map{ |file_map| file_map }
|
47
72
|
end
|
48
73
|
end
|
49
74
|
|
50
75
|
# generate md5 for each precache file
|
51
76
|
md5 = Digest::MD5.new
|
52
|
-
precache_files.each do |
|
77
|
+
precache_files.each do |filepath_map|
|
78
|
+
filepath, filepath_alias = filepath_map.first
|
53
79
|
md5.reset
|
54
80
|
md5 << File.read(filepath)
|
55
81
|
if posts_path_url_map[filepath]
|
56
82
|
url = posts_path_url_map[filepath]
|
57
83
|
else
|
58
|
-
url =
|
84
|
+
url = filepath_alias.sub(@site.dest, '')
|
59
85
|
end
|
60
86
|
@precache_list.push({
|
61
87
|
url: @site.baseurl.to_s + url,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-workbox-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benedikt Meurer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This plugin provides workbox support for Jekyll. Generate a service worker
|
14
14
|
and provides precache with Google Workbox.
|