Skip to content

Commit

Permalink
Move browserconfig.xml and manifest.json to actions
Browse files Browse the repository at this point in the history
The application manifest files need to be generated with asset urls
so it's simplest to just make them into Rails actions.
  • Loading branch information
pixeltrix committed Jul 20, 2015
1 parent e2ba8c6 commit c18bf31
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 57 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ gem 'dalli'
gem 'connection_pool'
gem 'lograge'
gem 'logstash-logger'
gem 'jbuilder'

group :development, :test do
gem 'rspec-rails'
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ GEM
phantomjs (>= 1.9)
railties (>= 3.2.0)
sprockets-rails
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jmespath (1.0.2)
multi_json (~> 1.0)
jquery-rails (4.0.4)
Expand Down Expand Up @@ -305,6 +308,7 @@ DEPENDENCIES
faraday
faraday_middleware
jasmine-rails
jbuilder
jquery-rails
json
launchy
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ def index

def help
end

def privacy
end

def browserconfig
end

def manifest
end
end
14 changes: 14 additions & 0 deletions app/views/pages/browserconfig.xml.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cache :browserconfig, expires_in: 5.minutes do
xml.instruct! :xml, version: "1.0"
xml.browserconfig do
xml.msapplication do
xml.tile do
xml.square70x70logo src: path_to_image('os-social/windows/tiny.png')
xml.square150x150logo src: path_to_image('os-social/windows/square.png')
xml.wide310x150logo src: path_to_image('os-social/windows/wide.png')
xml.square310x310logo src: path_to_image('os-social/windows/large.png')
xml.TileColor "#008800"
end
end
end
end
50 changes: 50 additions & 0 deletions app/views/pages/manifest.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
json.cache! :manifest, expires_in: 5.minutes do
json.name "Petitions"
json.display "standalone"
json.orientation "portrait"
json.start_url "/"

json.icons do
json.child! do
json.src path_to_image("os-social/android/launcher-icon-0-75x.png")
json.sizes "36x36"
json.type "image/png"
json.density "0.75"
end

json.child! do
json.src path_to_image("os-social/android/launcher-icon-1x.png")
json.sizes "48x48"
json.type "image/png"
json.density "1.0"
end

json.child! do
json.src path_to_image("os-social/android/launcher-icon-1-5x.png")
json.sizes "72x72"
json.type "image/png"
json.density "1.5"
end

json.child! do
json.src path_to_image("os-social/android/launcher-icon-2x.png")
json.sizes "96x96"
json.type "image/png"
json.density "2.0"
end

json.child! do
json.src path_to_image("os-social/android/launcher-icon-3x.png")
json.sizes "144x144"
json.type "image/png"
json.density "3.0"
end

json.child! do
json.src path_to_image("os-social/android/launcher-icon-4x.png")
json.sizes "192x192"
json.type "image/png"
json.density "4.0"
end
end
end
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
get '/' => 'pages#index', :as => :home
get 'help' => 'pages#help', :as => :help
get 'privacy' => 'pages#privacy', :as => :privacy

get 'browserconfig' => 'pages#browserconfig', format: 'xml'
get 'manifest' => 'pages#manifest', format: 'json'

get 'feedback' => 'feedback#index', :as => 'feedback'
get 'feedback/thanks' => 'feedback#thanks', :as => 'thanks_feedback'
Expand Down
12 changes: 0 additions & 12 deletions public/browserconfig.xml

This file was deleted.

44 changes: 0 additions & 44 deletions public/manifest.json

This file was deleted.

0 comments on commit c18bf31

Please sign in to comment.