assets_offline 0.0.1
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.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README +0 -0
- data/Rakefile +1 -0
- data/app/controllers/assets_offline_controller.rb +85 -0
- data/assets_offline.gemspec +20 -0
- data/config/routes.rb +3 -0
- data/lib/assets_offline/version.rb +3 -0
- data/lib/assets_offline.rb +5 -0
- metadata +54 -0
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "assets_offline/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "assets_offline"
|
7
|
+
s.version = AssetsOffline::VERSION
|
8
|
+
s.authors = ["Broomyocymru"]
|
9
|
+
s.email = ["broomyocymru@hotmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Rails 3.1 offline cache manifest view}
|
12
|
+
s.description = %q{Rails 3.1 offline cache manifest view}
|
13
|
+
|
14
|
+
s.rubyforge_project = "assets_offline"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
data/config/routes.rb
ADDED
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: assets_offline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Broomyocymru
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-02 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Rails 3.1 offline cache manifest view
|
15
|
+
email:
|
16
|
+
- broomyocymru@hotmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- README
|
24
|
+
- Rakefile
|
25
|
+
- app/controllers/assets_offline_controller.rb
|
26
|
+
- assets_offline.gemspec
|
27
|
+
- config/routes.rb
|
28
|
+
- lib/assets_offline.rb
|
29
|
+
- lib/assets_offline/version.rb
|
30
|
+
homepage: ''
|
31
|
+
licenses: []
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project: assets_offline
|
50
|
+
rubygems_version: 1.8.11
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: Rails 3.1 offline cache manifest view
|
54
|
+
test_files: []
|