Challenge offline apps on Rails 3.2
Below articles depended on rails 3.0.3. I try to this on Rails 3.2.2.
- http://railscasts.com/episodes/247-offline-apps-part-1
- http://railscasts.com/episodes/248-offline-apps-part-2
rack-offline gem is not latest
- rack-offline gem is v0.6.2 August 16, 2011. At github repos, after that this is fixed for rails3.1 or higher.
- I can use Gemfile:
gem 'rack-offline', :git => 'git://github.com/wycats/rack-offline.git'
This is shown v0.6.1, but this is higher than v0.6.2(as v0.6.3).
- I create a issue:
assets pipeline
- set config/route.rb as
match "/application.manifest" => Rails::Offline
does not contain assets/application.js and assets/application.css - I write config/route.rb manually rely on https://github.com/wycats/rack-offline/blob/master/README.textile
offline = Rack::Offline.configure do
cache "assets/application.js"
cache "assets/application.css"
files = Dir[
"#{root}/**/*.html"]
files.each do |file|
public_dir = Pathname.new("#{root}/public")
cache Pathname.new(file).relative_path_from(public_dir)
end
files = Dir[
"#{root}/assets/**/*.{js,css,jpg,png,gif}"]
files.each do |file|
cache Pathname.new(file).relative_path_from(root)
end
network "/"
end
match "/application.manifest" => offline
Write cache manifest mapping is too hard
app/assets/javascripts/application.js #=> assets/application.js
app/assets/javascripts/items.js.coffee #=> assets/items.js
vendor/assets/javascripts/foo.js.erb #=> assets/foo.js
rubygems ;)