From 2afb1242ccc1898f42e73a060fe237e8f033dbf2 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 16 Aug 2013 21:02:25 +0100 Subject: [PATCH] Build an asset manifest for iD --- app/helpers/asset_helper.rb | 11 +++++++++++ app/views/site/id.html.erb | 1 + 2 files changed, 12 insertions(+) create mode 100644 app/helpers/asset_helper.rb 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) %> -- 2.43.2