rails_appcache 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a80a1ab0bc8b2d888c5d699a012c907bac05b921
|
4
|
+
data.tar.gz: 675a9c02678f4e2fa3df4e8261980ceb57d08e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d41d5df2a9e99c0e526dcf595e754a735b9fcbfcfed0cf86a2f24e9d8962744aa2c430f2c5d6d81d9f3ed3b1c9d54ccfbb3d195e7b4c85035310a38f9ae434f9
|
7
|
+
data.tar.gz: e435f9ca87e6a6060387269ae37dc89ecb2989ba278217dd4e1cc13a1769eb0ae328182dacd3c5d1097e3992cf6eb699f1e11f009f5356a595a84a4c801d9bfb
|
@@ -1,6 +1,31 @@
|
|
1
1
|
|
2
2
|
class RailsAppcache::ManifestsController < RailsAppcache::ApplicationController
|
3
|
+
include RailsAppcache::ApplicationHelper
|
4
|
+
|
5
|
+
before_filter :check_caching_enabled
|
6
|
+
|
3
7
|
def show
|
4
|
-
|
8
|
+
if params[:version] == appcache_version_string
|
9
|
+
# This is a request from a current version of the page
|
10
|
+
render params[:manifest]
|
11
|
+
else
|
12
|
+
# This is a request from an obsolete page, using an obsolete manifest
|
13
|
+
# Serving a 404 enough to trigger an obsoletion event, which is purge
|
14
|
+
# the manifest from the appcache.
|
15
|
+
#
|
16
|
+
# The client will get the correct version on the *next* page request
|
17
|
+
display_404
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def display_404
|
24
|
+
render status: :not_found, text: ''
|
25
|
+
end
|
26
|
+
|
27
|
+
def check_caching_enabled
|
28
|
+
display_404 unless RailsAppcache.config.perform_caching?
|
5
29
|
end
|
30
|
+
|
6
31
|
end
|
data/config/routes.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
module RailsAppcache
|
2
2
|
module ApplicationHelper
|
3
3
|
def appcache_manifest_path(path)
|
4
|
-
"
|
4
|
+
return "" unless RailsAppcache.config.perform_caching?
|
5
|
+
|
6
|
+
"/#{path}-#{appcache_version_string}.appcache"
|
5
7
|
end
|
6
8
|
|
7
9
|
# In development, serve up a new manifest every time
|
8
10
|
# In production, serve the current Git revision
|
9
11
|
def appcache_version_string
|
12
|
+
|
10
13
|
if Rails.env.development?
|
11
|
-
|
14
|
+
Rails.application.config.assets.version
|
12
15
|
else
|
13
16
|
# Use the REVISION file left in root from capistrano
|
14
17
|
if File.exists?(Rails.root.join('REVISION'))
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
module RailsAppcache
|
3
|
+
|
4
|
+
def self.config
|
5
|
+
@config ||= Config.new
|
6
|
+
end
|
7
|
+
|
8
|
+
class Config
|
9
|
+
# Default to off outside of production
|
10
|
+
def perform_caching?
|
11
|
+
@perform_caching || !Rails.env.development?
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform_caching=(val)
|
15
|
+
@perform_caching = !!val
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
data/lib/rails_appcache.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_appcache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Eagar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/generators/appcache_manifest_generator.rb
|
40
40
|
- lib/rails_appcache.rb
|
41
41
|
- lib/rails_appcache/application_helper.rb
|
42
|
+
- lib/rails_appcache/config.rb
|
42
43
|
- lib/rails_appcache/engine.rb
|
43
44
|
- lib/rails_appcache/version.rb
|
44
45
|
- test/dummy/README.rdoc
|