]> git.openstreetmap.org Git - rails.git/commitdiff
Generate icon entries dynamically
authorMarwin Hochfelsner <50826859+hlfan@users.noreply.github.com>
Fri, 28 Feb 2025 11:27:18 +0000 (12:27 +0100)
committerMarwin Hochfelsner <50826859+hlfan@users.noreply.github.com>
Fri, 28 Feb 2025 11:27:18 +0000 (12:27 +0100)
app/assets/favicons/manifest.json.erb

index 0826e884111722c8073ed11e9a6e0aa4f2831c4b..8d806ac9ad96ae056f1ba1a438a1b9bd69c73d9b 100644 (file)
@@ -1,43 +1,11 @@
 {
        "name": "OpenStreetMap",
-       "icons": [
-               {
-                       "src": "<%= image_path("android-chrome-36x36.png").gsub("/", "\\/") %>",
-                       "sizes": "36x36",
-                       "type": "image\/png",
-                       "density": "0.75"
-               },
-               {
-                       "src": "<%= image_path("android-chrome-48x48.png").gsub("/", "\\/") %>",
-                       "sizes": "48x48",
-                       "type": "image\/png",
-                       "density": "1.0"
-               },
-               {
-                       "src": "<%= image_path("android-chrome-72x72.png").gsub("/", "\\/") %>",
-                       "sizes": "72x72",
-                       "type": "image\/png",
-                       "density": "1.5"
-               },
-               {
-                       "src": "<%= image_path("android-chrome-96x96.png").gsub("/", "\\/") %>",
-                       "sizes": "96x96",
-                       "type": "image\/png",
-                       "density": "2.0"
-               },
-               {
-                       "src": "<%= image_path("android-chrome-144x144.png").gsub("/", "\\/") %>",
-                       "sizes": "144x144",
-                       "type": "image\/png",
-                       "density": "3.0"
-               },
-               {
-                       "src": "<%= image_path("android-chrome-192x192.png").gsub("/", "\\/") %>",
-                       "sizes": "192x192",
-                       "type": "image\/png",
-                       "density": "4.0"
-               }
-       ],
+       "icons": <%= [36, 48, 72, 96, 144, 192].map { |res| {
+                       src: image_path("android-chrome-#{res}x#{res}.png").gsub("/", "\\/"),
+                       sizes: "#{res}x#{res}",
+                       type: "image/png",
+                       density: res.to_f / 48
+               } }.to_json %>,
        "start_url": "/",
        "display": "minimal-ui"
 }