middleman-appcache 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/lib/middleman-appcache/extension.rb +7 -3
- data/lib/middleman-appcache/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff3c0e8e1908b28b41d986c053ea2e85edf98eb4
|
4
|
+
data.tar.gz: 052074f5070aea717c0f26a3534a298693222f23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d28408b8b6acaf4bf4e10e21c6e60a2c3f596be221a801ab34a64042fb017c6b987b03c6d89c4a4370ce86ed873acc4e5a888b2b2a92b7b4b7601bb8122d3e5
|
7
|
+
data.tar.gz: 282a26b428c25f39925cb9e94b1f1073cae59079437dab8a0d0a433062c2121c6299ed01bb6fd9321ac54b2b1700496659dbd7e527f3e7f7456b8d913a5e7395
|
data/README.md
CHANGED
@@ -49,6 +49,7 @@ activate :app_cache do |config|
|
|
49
49
|
config.fallback = {
|
50
50
|
'/' => 'offline.html'
|
51
51
|
}
|
52
|
+
config.use_relative = false
|
52
53
|
end
|
53
54
|
```
|
54
55
|
|
@@ -73,7 +74,7 @@ NETWORK:
|
|
73
74
|
/logout
|
74
75
|
|
75
76
|
FALLBACK:
|
76
|
-
/ offline.html
|
77
|
+
/ /offline.html
|
77
78
|
|
78
79
|
```
|
79
80
|
|
@@ -107,6 +108,12 @@ The mapping of fallback resources if a resource is unavailable.
|
|
107
108
|
|
108
109
|
**Default:** `Empty`
|
109
110
|
|
111
|
+
### use_relative
|
112
|
+
|
113
|
+
If the resources should be treated as relative from the appcache.
|
114
|
+
|
115
|
+
**Default:** `true`
|
116
|
+
|
110
117
|
## License
|
111
118
|
|
112
119
|
Middleman Application Cache was created by [Ryan Scott](http://github.com/archytaus) is distributed under the [MIT](http://ryanscott.mit-license.org) license.
|
@@ -8,7 +8,8 @@ module Middleman
|
|
8
8
|
option :cache, ['index.html'], 'List of directories or files that will be cached.'
|
9
9
|
option :network, ['*'], 'Resources that require the user to be online.'
|
10
10
|
option :fallback, {}, 'Fallback resources if a resource is unavailable.'
|
11
|
-
|
11
|
+
option :use_relative, true, 'If the cached files should be generated as relative paths.'
|
12
|
+
|
12
13
|
def initialize app, options_hash = {}, &block
|
13
14
|
super
|
14
15
|
|
@@ -16,7 +17,8 @@ module Middleman
|
|
16
17
|
cache_options = options.cache
|
17
18
|
network_options = options.network
|
18
19
|
fallback_options = options.fallback
|
19
|
-
|
20
|
+
use_relative = options.use_relative
|
21
|
+
|
20
22
|
app.after_build do |builder|
|
21
23
|
cache = []
|
22
24
|
|
@@ -24,7 +26,9 @@ module Middleman
|
|
24
26
|
directory = File.join(config[:build_dir], cache_file_pattern)
|
25
27
|
files_to_cache = Dir.glob(directory)
|
26
28
|
files_to_cache.each do |file_to_cache|
|
27
|
-
|
29
|
+
build_dir = config[:build_dir]
|
30
|
+
build_dir = "#{build_dir}/" if use_relative
|
31
|
+
cache << file_to_cache.gsub(build_dir, '')
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|