From: Tom Hughes Date: Fri, 16 Aug 2013 20:02:25 +0000 (+0100) Subject: Build an asset manifest for iD X-Git-Tag: live~4759 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2afb1242ccc1898f42e73a060fe237e8f033dbf2?hp=d23f2625437a93e028fbe74d1c606f8d30698a1e Build an asset manifest for iD --- diff --git a/app/helpers/asset_helper.rb b/app/helpers/asset_helper.rb new file mode 100644 index 000000000..67c1a141d --- /dev/null +++ b/app/helpers/asset_helper.rb @@ -0,0 +1,11 @@ +module AssetHelper + def assets(directory) + assets = {} + + Rails.application.assets.index.each_logical_path("#{directory}/*") do |path| + assets[path.sub(/^#{directory}\//, "")] = asset_path(path) + end + + assets + end +end diff --git a/app/views/site/id.html.erb b/app/views/site/id.html.erb index 6000b7da0..469bb3f91 100644 --- a/app/views/site/id.html.erb +++ b/app/views/site/id.html.erb @@ -21,6 +21,7 @@ var id = iD() .embed(true) .assetPath("/assets/iD/") <%# Can't use asset_path('iD/') in production. %> + .assetMap(<%= assets("iD").to_json.html_safe %>) .locale("<%= locale %>", "<%= asset_path("iD/locales/#{locale}.json") %>") .preauth({ <% token = @user.access_token(ID_KEY) %>