middleman-appcache 1.0.0
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 +7 -0
- data/.gitignore +5 -0
- data/Gemfile +19 -0
- data/README.md +112 -0
- data/Rakefile +14 -0
- data/features/support/env.rb +4 -0
- data/lib/middleman-appcache.rb +8 -0
- data/lib/middleman-appcache/extension.rb +63 -0
- data/lib/middleman-appcache/version.rb +7 -0
- data/lib/middleman_extension.rb +1 -0
- data/middleman-appcache.gemspec +22 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cd1fa53cde33a152eb11d4fe81154f7308316c4c
|
4
|
+
data.tar.gz: 096505d049dd0c7b57eb3d6a6894f649ddcca13f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cfd67fbaa329e9abe78ddf57b5cde6c4ac2b5e6759a60d4ece822866a485e49a8b01dbe03fb3f25ae76e1327a0032067ea6fb21106ecd674196cb7d234a04e86
|
7
|
+
data.tar.gz: f19168e95979a4c448c03671be2da9c7108ac7b8550bfa07f153980f2d359be02dc5d3de3f71c7e3ee28886076c4acf235920776f5d6079d4445b49c3c435e06
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# If you have OpenSSL installed, we recommend updating
|
2
|
+
# the following line to use "https"
|
3
|
+
source 'http://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in middleman-appcache.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem 'rake'
|
10
|
+
gem 'rdoc'
|
11
|
+
gem 'yard'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem 'cucumber'
|
16
|
+
gem 'fivemat'
|
17
|
+
gem 'aruba'
|
18
|
+
gem 'rspec'
|
19
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
# Middleman Application Cache
|
2
|
+
|
3
|
+
> Generate a [Application Cache Manifest](https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache) to support offline access.
|
4
|
+
|
5
|
+
## Disclaimer
|
6
|
+
|
7
|
+
I have developed this for the intention of using it exclusively for single page applications.
|
8
|
+
|
9
|
+
While it **can** be extended to support App Cache Manifests for multiple pages, I have no intent at this point in time to develop support for this.
|
10
|
+
|
11
|
+
If it is something that you do need, please let me know and I'll investigate how it could work without compromising the configuration syntax.
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Add the following line to `Gemfile`, then run `bundle install`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'middleman-appcache'
|
19
|
+
```
|
20
|
+
|
21
|
+
Add a link to the appcache name in you html layout:
|
22
|
+
|
23
|
+
```html
|
24
|
+
<html manifest="manifest.appcache">
|
25
|
+
...
|
26
|
+
</html>
|
27
|
+
```
|
28
|
+
|
29
|
+
And active the extension inside config.rb:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
activate :app_cache do |config|
|
33
|
+
config.cache_manifest = 'manifest.appcache'
|
34
|
+
config.cache = %w(index.html favicon.ico stylesheets/*.css javascripts/*.js images/*)
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
Then when you run `middleman build`, the application cache will be generated in the build directory.
|
39
|
+
|
40
|
+
## Configuration
|
41
|
+
|
42
|
+
The extension has 5 optionally configurable fields:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
activate :app_cache do |config|
|
46
|
+
config.cache_manifest = 'manifest.appcache'
|
47
|
+
config.cache = %w(index.html offline.html favicon.ico stylesheets/*.css javascripts/*.js images/*)
|
48
|
+
config.network = %w(/ /login /logout)
|
49
|
+
config.fallback = {
|
50
|
+
'/' => 'offline.html'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
The above configuration will generate the following appcache:
|
56
|
+
|
57
|
+
```manifest.appcache
|
58
|
+
CACHE MANIFEST
|
59
|
+
|
60
|
+
CACHE:
|
61
|
+
/index.html
|
62
|
+
/offline.html
|
63
|
+
/favicon.ico
|
64
|
+
/stylesheets/all-3676b7b2.css
|
65
|
+
/stylesheets/normalize-6197e73d.css
|
66
|
+
/javascripts/all-24162989.js
|
67
|
+
/javascripts/vendor-e28aee79.js
|
68
|
+
/images/welcome-64a62e79.png
|
69
|
+
|
70
|
+
NETWORK:
|
71
|
+
/
|
72
|
+
/login
|
73
|
+
/logout
|
74
|
+
|
75
|
+
FALLBACK:
|
76
|
+
/ offline.html
|
77
|
+
|
78
|
+
```
|
79
|
+
|
80
|
+
### cachemanifest
|
81
|
+
|
82
|
+
The filename for the generate cache manifest.
|
83
|
+
|
84
|
+
**Default:** `'manifest.appcache'`
|
85
|
+
|
86
|
+
### cache
|
87
|
+
|
88
|
+
The list of files, directories, or glob patterns which should be cached.
|
89
|
+
|
90
|
+
**Default:** `['index.html']`
|
91
|
+
|
92
|
+
### cache
|
93
|
+
|
94
|
+
The list of files, directories, or glob patterns which should be cached.
|
95
|
+
|
96
|
+
**Default:** `['index.html']`
|
97
|
+
|
98
|
+
### network
|
99
|
+
|
100
|
+
The list of resources that require the user to be online.
|
101
|
+
|
102
|
+
**Default:** `['*']`
|
103
|
+
|
104
|
+
### fallback
|
105
|
+
|
106
|
+
The mapping of fallback resources if a resource is unavailable.
|
107
|
+
|
108
|
+
**Default:** `Empty`
|
109
|
+
|
110
|
+
## License
|
111
|
+
|
112
|
+
Middleman Application Cache was created by [Ryan Scott](http://github.com/archytaus) is distributed under the [MIT](http://ryanscott.mit-license.org) license.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
7
|
+
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rake/clean'
|
11
|
+
|
12
|
+
task test: ['cucumber']
|
13
|
+
|
14
|
+
task default: :test
|
@@ -0,0 +1,63 @@
|
|
1
|
+
|
2
|
+
module Middleman
|
3
|
+
|
4
|
+
class AppCacheExtension < Middleman::Extension
|
5
|
+
|
6
|
+
option :cache_manifest, 'manifest.appcache', 'The name of the generated cache manifest'
|
7
|
+
|
8
|
+
option :cache, ['index.html'], 'List of directories or files that will be cached.'
|
9
|
+
option :network, ['*'], 'Resources that require the user to be online.'
|
10
|
+
option :fallback, {}, 'Fallback resources if a resource is unavailable.'
|
11
|
+
|
12
|
+
def initialize app, options_hash = {}, &block
|
13
|
+
super
|
14
|
+
|
15
|
+
cache_manifest_filename = options.cache_manifest
|
16
|
+
cache_options = options.cache
|
17
|
+
network_options = options.network
|
18
|
+
fallback_options = options.fallback
|
19
|
+
|
20
|
+
app.after_build do |builder|
|
21
|
+
cache = []
|
22
|
+
|
23
|
+
cache_options.each do |cache_file_pattern|
|
24
|
+
directory = File.join(config[:build_dir], cache_file_pattern)
|
25
|
+
files_to_cache = Dir.glob(directory)
|
26
|
+
files_to_cache.each do |file_to_cache|
|
27
|
+
cache << file_to_cache.gsub(config[:build_dir], '')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
manifest_file = File.join(config[:build_dir], cache_manifest_filename)
|
32
|
+
File.open(manifest_file, "w") do |f|
|
33
|
+
f.write "CACHE MANIFEST\n\n"
|
34
|
+
|
35
|
+
f.write "CACHE:\n"
|
36
|
+
cache.each do |cache_file|
|
37
|
+
f.write "#{cache_file}\n"
|
38
|
+
end
|
39
|
+
f.write "\n"
|
40
|
+
|
41
|
+
if network_options.any?
|
42
|
+
f.write "NETWORK:\n"
|
43
|
+
network_options.each do |network_url|
|
44
|
+
f.write "#{network_url}\n"
|
45
|
+
end
|
46
|
+
f.write "\n"
|
47
|
+
end
|
48
|
+
|
49
|
+
if fallback_options.any?
|
50
|
+
f.write "FALLBACK:\n"
|
51
|
+
fallback_options.each do |url, fallback_resource|
|
52
|
+
f.write "#{url} #{fallback_resource}\n"
|
53
|
+
end
|
54
|
+
f.write "\n"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
builder.say_status :regenerated, cache_manifest_filename
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'middleman-appcache'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "middleman-appcache/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "middleman-appcache"
|
7
|
+
s.version = Middleman::AppCache::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Ryan Scott']
|
10
|
+
s.email = ['atthealma@gmail.com']
|
11
|
+
|
12
|
+
s.homepage = "https://github.com/Archytaus/middleman-appcache"
|
13
|
+
s.summary = %q{Generate appcache manifest for your Middleman Project}
|
14
|
+
s.description = %q{Generate appcache manifest for your Middleman Project}
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# The version of middleman-core your extension depends on
|
21
|
+
s.add_runtime_dependency("middleman-core", [">= 3.3.6"])
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-appcache
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Scott
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: middleman-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.6
|
27
|
+
description: Generate appcache manifest for your Middleman Project
|
28
|
+
email:
|
29
|
+
- atthealma@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- features/support/env.rb
|
39
|
+
- lib/middleman-appcache.rb
|
40
|
+
- lib/middleman-appcache/extension.rb
|
41
|
+
- lib/middleman-appcache/version.rb
|
42
|
+
- lib/middleman_extension.rb
|
43
|
+
- middleman-appcache.gemspec
|
44
|
+
homepage: https://github.com/Archytaus/middleman-appcache
|
45
|
+
licenses: []
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.4.1
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Generate appcache manifest for your Middleman Project
|
67
|
+
test_files:
|
68
|
+
- features/support/env.rb
|