middleman-appcache 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -8
- data/lib/middleman-appcache/extension.rb +14 -0
- data/lib/middleman-appcache/version.rb +1 -1
- 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: 10aecb04431c1fad6a0baeca55b2fbebbe6a7fad
|
4
|
+
data.tar.gz: d4bad95040ee5c0354b3140f0def8d4485953b53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbf0c5fcce7a50a03180ede1a70877665aec9141097920ae09d5630e77cbd5238c37aa7244e9892adb063cd52aee974c38de06da00c418b0d06de9a763040c67
|
7
|
+
data.tar.gz: 19366f57ef7649ba825d1de359f1aad995f2badeb8755e7a58845b5500beac9d6c302d80b35d733ba0d135a0adb50c1cf788c4d8ab7c8764260fbc6fc6ff7023
|
data/README.md
CHANGED
@@ -50,6 +50,7 @@ activate :app_cache do |config|
|
|
50
50
|
'/' => 'offline.html'
|
51
51
|
}
|
52
52
|
config.use_relative = false
|
53
|
+
config.version_hash = true
|
53
54
|
end
|
54
55
|
```
|
55
56
|
|
@@ -58,6 +59,8 @@ The above configuration will generate the following appcache:
|
|
58
59
|
```manifest.appcache
|
59
60
|
CACHE MANIFEST
|
60
61
|
|
62
|
+
# version 1aadc03fe3f695a96d64f1a190b6253e
|
63
|
+
|
61
64
|
CACHE:
|
62
65
|
/index.html
|
63
66
|
/offline.html
|
@@ -80,7 +83,7 @@ FALLBACK:
|
|
80
83
|
|
81
84
|
### cachemanifest
|
82
85
|
|
83
|
-
The filename for the generate cache manifest.
|
86
|
+
The filename for the generate cache manifest.
|
84
87
|
|
85
88
|
**Default:** `'manifest.appcache'`
|
86
89
|
|
@@ -88,13 +91,7 @@ The filename for the generate cache manifest.
|
|
88
91
|
|
89
92
|
The list of files, directories, or glob patterns which should be cached.
|
90
93
|
|
91
|
-
**Default:** `['index.html']`
|
92
|
-
|
93
|
-
### cache
|
94
|
-
|
95
|
-
The list of files, directories, or glob patterns which should be cached.
|
96
|
-
|
97
|
-
**Default:** `['index.html']`
|
94
|
+
**Default:** `['index.html']`
|
98
95
|
|
99
96
|
### network
|
100
97
|
|
@@ -114,6 +111,12 @@ If the resources should be treated as relative from the appcache.
|
|
114
111
|
|
115
112
|
**Default:** `true`
|
116
113
|
|
114
|
+
### version_hash
|
115
|
+
|
116
|
+
If a version hash should be generated from the contents of the referenced files.
|
117
|
+
|
118
|
+
**Default:** `true`
|
119
|
+
|
117
120
|
## License
|
118
121
|
|
119
122
|
Middleman Application Cache was created by [Ryan Scott](http://github.com/archytaus) is distributed under the [MIT](http://ryanscott.mit-license.org) license.
|
@@ -9,6 +9,7 @@ module Middleman
|
|
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
|
+
option :version_hash, true, 'If the contents of the files should be hashed and added as a comment.'
|
12
13
|
|
13
14
|
def initialize app, options_hash = {}, &block
|
14
15
|
super
|
@@ -18,6 +19,12 @@ module Middleman
|
|
18
19
|
network_options = options.network
|
19
20
|
fallback_options = options.fallback
|
20
21
|
use_relative = options.use_relative
|
22
|
+
version_hash = options.version_hash
|
23
|
+
|
24
|
+
if version_hash
|
25
|
+
require 'digest'
|
26
|
+
hash = Digest::MD5.new
|
27
|
+
end
|
21
28
|
|
22
29
|
app.after_build do |builder|
|
23
30
|
cache = []
|
@@ -29,6 +36,9 @@ module Middleman
|
|
29
36
|
build_dir = config[:build_dir]
|
30
37
|
build_dir = "#{build_dir}/" if use_relative
|
31
38
|
cache << file_to_cache.gsub(build_dir, '')
|
39
|
+
if version_hash
|
40
|
+
hash.file file_to_cache if File.file? file_to_cache
|
41
|
+
end
|
32
42
|
end
|
33
43
|
end
|
34
44
|
|
@@ -36,6 +46,10 @@ module Middleman
|
|
36
46
|
File.open(manifest_file, "w") do |f|
|
37
47
|
f.write "CACHE MANIFEST\n\n"
|
38
48
|
|
49
|
+
if version_hash
|
50
|
+
f.write "\# version #{hash.hexdigest}\n\n"
|
51
|
+
end
|
52
|
+
|
39
53
|
f.write "CACHE:\n"
|
40
54
|
cache.each do |cache_file|
|
41
55
|
f.write "#{cache_file}\n"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-appcache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Scott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|