assets_offline 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +97 -0
- data/app/.svn/all-wcprops +5 -0
- data/app/.svn/entries +31 -0
- data/app/controllers/.svn/all-wcprops +11 -0
- data/app/controllers/.svn/entries +62 -0
- data/app/controllers/.svn/text-base/assets_offline_controller.rb.svn-base +85 -0
- data/app/controllers/assets_offline_controller.rb +3 -3
- data/config/.svn/all-wcprops +11 -0
- data/config/.svn/entries +62 -0
- data/config/.svn/text-base/routes.rb.svn-base +3 -0
- data/lib/.svn/all-wcprops +11 -0
- data/lib/.svn/entries +65 -0
- data/lib/.svn/text-base/assets_offline.rb.svn-base +6 -0
- data/lib/assets_offline/.svn/all-wcprops +11 -0
- data/lib/assets_offline/.svn/entries +62 -0
- data/lib/assets_offline/.svn/text-base/version.rb.svn-base +3 -0
- data/lib/assets_offline/version.rb +1 -1
- metadata +17 -4
- data/README +0 -1
- data/README~ +0 -0
data/README.textile
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
assets_offline
|
2
|
+
============
|
3
|
+
|
4
|
+
**Stable Version**: 0.0.3
|
5
|
+
|
6
|
+
This gem is specifically for Rails 3.1 projects that wish to use HTML5 and its offline cache feature with the Asset Pipeline.
|
7
|
+
|
8
|
+
Installing
|
9
|
+
----------
|
10
|
+
|
11
|
+
Installation is straight forward simply add the gem to your gemfile and do a bundle install or on the terminal as follows
|
12
|
+
|
13
|
+
<pre>
|
14
|
+
$ gem install assets_offline
|
15
|
+
</pre>
|
16
|
+
|
17
|
+
<pre>
|
18
|
+
# Last Updated DD/MM/YYYY
|
19
|
+
application:
|
20
|
+
asset-cache:
|
21
|
+
- "application.css"
|
22
|
+
- "checkout.js"
|
23
|
+
- "favicon.ico"
|
24
|
+
- "favicon.png"
|
25
|
+
- "logo.png"
|
26
|
+
cache:
|
27
|
+
- "/dictionary.json"
|
28
|
+
fallback:
|
29
|
+
- "/prompts.json # /prompts.json"
|
30
|
+
- "/prices.json # /prices.json"
|
31
|
+
network:
|
32
|
+
- "/checkout/start_transaction.json"
|
33
|
+
- "/checkout/submit_transaction.json"
|
34
|
+
</pre>
|
35
|
+
|
36
|
+
Documentation
|
37
|
+
----------------------
|
38
|
+
|
39
|
+
The yaml file "assets_offline.yml" needs to be added to the rails config folder. The yaml is split by route name. So the exmaple above can be added to html using "/assets_offline/application". You can add as many root nodes to the yaml as you require and just add the name to the path to get the generated file.
|
40
|
+
|
41
|
+
There are 6 sections to add files to in the Yaml
|
42
|
+
* asset-cache
|
43
|
+
* cache
|
44
|
+
* asset-fallback
|
45
|
+
* fallback
|
46
|
+
* network
|
47
|
+
* asset-network
|
48
|
+
|
49
|
+
Sections starting asset will use the rails asset_path() helper to get the file path. Non asset sections will use the path specified.
|
50
|
+
Fallback requires two paths which need to be seperated by a "#"
|
51
|
+
|
52
|
+
Manifest file generates a hash key in development this key is changed every 5 seconds so the cache will never function, in production the key is based on the hash of the yaml file. To force a cache refresh you must update the last updated value in the yaml file.
|
53
|
+
|
54
|
+
Roadmap
|
55
|
+
---------
|
56
|
+
* Rake task to create YAML files
|
57
|
+
* Automating key update in production mode
|
58
|
+
* Adding directories to cache file rather than individual files
|
59
|
+
|
60
|
+
|
61
|
+
Changelog
|
62
|
+
---------
|
63
|
+
|
64
|
+
**v0.0.3**
|
65
|
+
|
66
|
+
* Beta release
|
67
|
+
|
68
|
+
|
69
|
+
Credits
|
70
|
+
-------
|
71
|
+
|
72
|
+
* [broomyocymru](mailto: broomyocymru@hotmail.com)
|
73
|
+
|
74
|
+
|
75
|
+
License
|
76
|
+
-------
|
77
|
+
|
78
|
+
Copyright (c) 2011 broomyocymru
|
79
|
+
|
80
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
81
|
+
a copy of this software and associated documentation files (the
|
82
|
+
"Software"), to deal in the Software without restriction, including
|
83
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
84
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
85
|
+
permit persons to whom the Software is furnished to do so, subject to
|
86
|
+
the following conditions:
|
87
|
+
|
88
|
+
The above copyright notice and this permission notice shall be
|
89
|
+
included in all copies or substantial portions of the Software.
|
90
|
+
|
91
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
92
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
93
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
94
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
95
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
96
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
97
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/app/.svn/entries
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
3734
|
5
|
+
https://svn.torex.com/svn/TorexNG/trunk/gems/assets_offline/app
|
6
|
+
https://svn.torex.com/svn/TorexNG
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-12-02T15:46:33.442319Z
|
11
|
+
3734
|
12
|
+
Anthony.Broome
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
45178cb0-7fed-444c-b58d-06e1424a9ccb
|
28
|
+
|
29
|
+
controllers
|
30
|
+
dir
|
31
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
K 25
|
2
|
+
svn:wc:ra_dav:version-url
|
3
|
+
V 68
|
4
|
+
/svn/TorexNG/!svn/ver/3734/trunk/gems/assets_offline/app/controllers
|
5
|
+
END
|
6
|
+
assets_offline_controller.rb
|
7
|
+
K 25
|
8
|
+
svn:wc:ra_dav:version-url
|
9
|
+
V 97
|
10
|
+
/svn/TorexNG/!svn/ver/3734/trunk/gems/assets_offline/app/controllers/assets_offline_controller.rb
|
11
|
+
END
|
@@ -0,0 +1,62 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
3734
|
5
|
+
https://svn.torex.com/svn/TorexNG/trunk/gems/assets_offline/app/controllers
|
6
|
+
https://svn.torex.com/svn/TorexNG
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-12-02T15:46:33.442319Z
|
11
|
+
3734
|
12
|
+
Anthony.Broome
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
45178cb0-7fed-444c-b58d-06e1424a9ccb
|
28
|
+
|
29
|
+
assets_offline_controller.rb
|
30
|
+
file
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
2011-12-02T14:38:49.402396Z
|
36
|
+
fa45977fe7a847e4fa4be00ea5d80b3d
|
37
|
+
2011-12-02T15:46:33.442319Z
|
38
|
+
3734
|
39
|
+
Anthony.Broome
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
2490
|
62
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class AssetsOfflineController < ActionController::Base
|
4
|
+
|
5
|
+
def show
|
6
|
+
config = YAML.load_file("#{Rails.root}/config/assets_offline.yml")
|
7
|
+
root = config[params[:id]]
|
8
|
+
|
9
|
+
body = "# GENERATED USING ASSET_OFFLINE\n"
|
10
|
+
body << "# Mode: #{Rails.env} \n"
|
11
|
+
body << "# #{generate_key()} \n\n"
|
12
|
+
|
13
|
+
body << "CACHE MANIFEST \n"
|
14
|
+
# CACHE SECTION
|
15
|
+
if !root["asset-cache"].blank? and root["asset-cache"].count() > 0
|
16
|
+
root["asset-cache"].each do |asset_name|
|
17
|
+
body << "#{view_context.asset_path(asset_name)}\n"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
if !root["cache"].blank? and root["cache"].count() > 0
|
21
|
+
root["cache"].each do |asset_name|
|
22
|
+
body << "#{asset_name}\n"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
body << "\n"
|
26
|
+
|
27
|
+
# NETWORK SECTION
|
28
|
+
body << "NETWORK:\n"
|
29
|
+
body << "# Resources where a connection is required \n"
|
30
|
+
if !root["asset-network"].blank? and root["asset-network"].count() > 0
|
31
|
+
root["asset-network"].each do |asset_name|
|
32
|
+
body << "#{view_context.asset_path(asset_name)}\n"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
if !root["network"].blank? and root["network"].count() > 0
|
36
|
+
root["network"].each do |asset_name|
|
37
|
+
body << "#{asset_name}\n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
body << "\n"
|
41
|
+
|
42
|
+
#FALLBACK SECTION
|
43
|
+
body << "FALLBACK:\n"
|
44
|
+
body << "# Resources where a connection is used if available \n"
|
45
|
+
if !root["asset-fallback"].blank? and root["asset-fallback"].count() > 0
|
46
|
+
root["asset-fallback"].each do |asset_name|
|
47
|
+
asset_name_part = asset_name.split("#")
|
48
|
+
body << "#{view_context.asset_path(asset_name_part[0].strip())} #{view_context.asset_path(asset_name_part[1].strip())}\n"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
if !root["fallback"].blank? and root["fallback"].count() > 0
|
52
|
+
root["fallback"].each do |asset_name|
|
53
|
+
asset_name_part = asset_name.split("#")
|
54
|
+
body << "#{asset_name_part[0].strip()} #{asset_name_part[1].strip()}\n"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
body << "\n"
|
58
|
+
|
59
|
+
headers['Content-Type'] = 'text/cache-manifest'
|
60
|
+
render :text => body, :layout => false
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def generate_key
|
66
|
+
if Rails.env.production?
|
67
|
+
production_key
|
68
|
+
else
|
69
|
+
development_key
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
def production_key
|
75
|
+
#Invalidate production by updating the datetime stamp in the comment
|
76
|
+
path = "#{Rails.root}/config/assets_offline.yml"
|
77
|
+
Digest::SHA2.hexdigest(File.read(path)) if ::File.file?(path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def development_key
|
81
|
+
now = Time.now.to_i - Time.now.to_i % 5
|
82
|
+
Digest::SHA2.hexdigest(now.to_s)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -6,12 +6,12 @@ class AssetsOfflineController < ActionController::Base
|
|
6
6
|
config = YAML.load_file("#{Rails.root}/config/assets_offline.yml")
|
7
7
|
root = config[params[:id]]
|
8
8
|
|
9
|
-
body =
|
9
|
+
body = "CACHE MANIFEST \n"
|
10
|
+
body << "# GENERATED USING ASSET_OFFLINE\n"
|
10
11
|
body << "# Mode: #{Rails.env} \n"
|
11
12
|
body << "# #{generate_key()} \n\n"
|
12
|
-
|
13
|
-
body << "CACHE MANIFEST \n"
|
14
13
|
# CACHE SECTION
|
14
|
+
body << "CACHE:\n"
|
15
15
|
if !root["asset-cache"].blank? and root["asset-cache"].count() > 0
|
16
16
|
root["asset-cache"].each do |asset_name|
|
17
17
|
body << "#{view_context.asset_path(asset_name)}\n"
|
data/config/.svn/entries
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
3734
|
5
|
+
https://svn.torex.com/svn/TorexNG/trunk/gems/assets_offline/config
|
6
|
+
https://svn.torex.com/svn/TorexNG
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-12-02T15:46:33.442319Z
|
11
|
+
3734
|
12
|
+
Anthony.Broome
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
45178cb0-7fed-444c-b58d-06e1424a9ccb
|
28
|
+
|
29
|
+
routes.rb
|
30
|
+
file
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
2011-12-02T14:39:29.970397Z
|
36
|
+
1b9a1db281aa1d112beb8340d29ead47
|
37
|
+
2011-12-02T15:46:33.442319Z
|
38
|
+
3734
|
39
|
+
Anthony.Broome
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
66
|
62
|
+
|
data/lib/.svn/entries
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
3734
|
5
|
+
https://svn.torex.com/svn/TorexNG/trunk/gems/assets_offline/lib
|
6
|
+
https://svn.torex.com/svn/TorexNG
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-12-02T15:46:33.442319Z
|
11
|
+
3734
|
12
|
+
Anthony.Broome
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
45178cb0-7fed-444c-b58d-06e1424a9ccb
|
28
|
+
|
29
|
+
assets_offline
|
30
|
+
dir
|
31
|
+
|
32
|
+
assets_offline.rb
|
33
|
+
file
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
2011-12-02T15:12:09.590444Z
|
39
|
+
7f49316f1e14bcd77b955b39158c6a6d
|
40
|
+
2011-12-02T15:46:33.442319Z
|
41
|
+
3734
|
42
|
+
Anthony.Broome
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
145
|
65
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
K 25
|
2
|
+
svn:wc:ra_dav:version-url
|
3
|
+
V 71
|
4
|
+
/svn/TorexNG/!svn/ver/3734/trunk/gems/assets_offline/lib/assets_offline
|
5
|
+
END
|
6
|
+
version.rb
|
7
|
+
K 25
|
8
|
+
svn:wc:ra_dav:version-url
|
9
|
+
V 82
|
10
|
+
/svn/TorexNG/!svn/ver/3734/trunk/gems/assets_offline/lib/assets_offline/version.rb
|
11
|
+
END
|
@@ -0,0 +1,62 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
3734
|
5
|
+
https://svn.torex.com/svn/TorexNG/trunk/gems/assets_offline/lib/assets_offline
|
6
|
+
https://svn.torex.com/svn/TorexNG
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-12-02T15:46:33.442319Z
|
11
|
+
3734
|
12
|
+
Anthony.Broome
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
45178cb0-7fed-444c-b58d-06e1424a9ccb
|
28
|
+
|
29
|
+
version.rb
|
30
|
+
file
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
2011-12-02T15:16:44.894451Z
|
36
|
+
c47858446fefbb4d8ef552e650df25ea
|
37
|
+
2011-12-02T15:46:33.442319Z
|
38
|
+
3734
|
39
|
+
Anthony.Broome
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
45
|
62
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assets_offline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-05 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Rails 3.1 offline cache manifest view
|
15
15
|
email:
|
@@ -20,14 +20,27 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- .gitignore
|
22
22
|
- Gemfile
|
23
|
-
- README
|
24
|
-
- README~
|
23
|
+
- README.textile
|
25
24
|
- Rakefile
|
25
|
+
- app/.svn/all-wcprops
|
26
|
+
- app/.svn/entries
|
27
|
+
- app/controllers/.svn/all-wcprops
|
28
|
+
- app/controllers/.svn/entries
|
29
|
+
- app/controllers/.svn/text-base/assets_offline_controller.rb.svn-base
|
26
30
|
- app/controllers/assets_offline_controller.rb
|
27
31
|
- assets_offline.gemspec
|
32
|
+
- config/.svn/all-wcprops
|
33
|
+
- config/.svn/entries
|
34
|
+
- config/.svn/text-base/routes.rb.svn-base
|
28
35
|
- config/routes.rb
|
29
36
|
- init.rb
|
37
|
+
- lib/.svn/all-wcprops
|
38
|
+
- lib/.svn/entries
|
39
|
+
- lib/.svn/text-base/assets_offline.rb.svn-base
|
30
40
|
- lib/assets_offline.rb
|
41
|
+
- lib/assets_offline/.svn/all-wcprops
|
42
|
+
- lib/assets_offline/.svn/entries
|
43
|
+
- lib/assets_offline/.svn/text-base/version.rb.svn-base
|
31
44
|
- lib/assets_offline/version.rb
|
32
45
|
homepage: ''
|
33
46
|
licenses: []
|
data/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
TODO
|
data/README~
DELETED
File without changes
|