From cb373ffef2ed834e27691563b03ebf944db303b7 Mon Sep 17 00:00:00 2001 From: sHa Date: Thu, 19 Jun 2025 17:21:55 +0300 Subject: [PATCH] Refactor SVG gradients and IDs for consistency and clarity - Updated gradient IDs in google_chrome_icon.svg to be more descriptive. - Refactored gradient IDs in grafana.svg for better identification. - Changed gradient IDs in homebridge.svg to follow a consistent naming convention. - Modified gradient IDs in jellyfin.svg for clarity and consistency. - Updated gradient IDs in shadoll.svg to avoid conflicts. - Renamed ID in tesla.svg for better identification. - Enhanced svg-cleanup.js to fix single-letter ID conflicts by prefixing them with the filename, improving SVG file integrity. --- .../emblems/Coat_of_arms_of_Andorra.svg | 48 +- .../Royal_Badge_of_Wales_2008-2024.svg | 8 +- public/images/flags/ag-1962–1967.svg | 1968 ++++++++--------- public/images/flags/er.svg | 4 +- public/images/flags/ua-BilaCerkva.svg | 4 +- public/images/flags/ua-Kyiv.svg | 4 +- public/images/flags/us-hi.svg | 4 +- public/images/flags/us-in.svg | 48 +- public/images/flags/us-ks.svg | 20 +- public/images/flags/us-la.svg | 20 +- public/images/flags/us-mo.svg | 48 +- public/images/flags/us-oh.svg | 2 +- public/images/flags/us-tn.svg | 17 +- public/images/flags/us-tx.svg | 14 +- public/images/flags/us-ut.svg | 2 +- public/images/flags/us-vt.svg | 2 +- public/images/logos/android-auto.svg | 8 +- public/images/logos/apache.svg | 40 +- public/images/logos/dockge.svg | 4 +- public/images/logos/facebook-messenger.svg | 4 +- public/images/logos/firefox.svg | 48 +- public/images/logos/forgejo.svg | 2 +- public/images/logos/google_chrome.svg | 40 +- public/images/logos/google_chrome_icon.svg | 12 +- public/images/logos/grafana.svg | 4 +- public/images/logos/homebridge.svg | 8 +- public/images/logos/jellyfin.svg | 8 +- public/images/logos/shadoll.svg | 4 +- public/images/logos/tesla.svg | 2 +- scripts/svg-cleanup.js | 63 +- 30 files changed, 1260 insertions(+), 1200 deletions(-) diff --git a/public/images/emblems/Coat_of_arms_of_Andorra.svg b/public/images/emblems/Coat_of_arms_of_Andorra.svg index 609d235..d0caea1 100644 --- a/public/images/emblems/Coat_of_arms_of_Andorra.svg +++ b/public/images/emblems/Coat_of_arms_of_Andorra.svg @@ -287,38 +287,38 @@ d="M509.436 463.299a44.84 44.84 0 0 1-4.679 14.295c-3.195 5.047-2.016 4.911-9.248 12.982a51.84 51.84 0 0 1-13.473 9.724 58.215 58.215 0 0 1-14.799 5.397 110.221 110.221 0 0 1-35.855 3.459c-7.427-.379-14.827-1.147-22.174-2.297-7.974-1.14-16-1.869-24.05-2.185-4.614-.195-8.978-.238-13.287 0a111.346 111.346 0 0 0-15.812 2.185 178.3 178.3 0 0 0-23.868 6.897l.123-185.299 177.809-.05v126.647s-.363 6.187-.688 8.242z" class="e" /> - + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - + - - - - - - - - + + \ No newline at end of file diff --git a/public/images/emblems/Royal_Badge_of_Wales_2008-2024.svg b/public/images/emblems/Royal_Badge_of_Wales_2008-2024.svg index 7e9bd31..edf1607 100644 --- a/public/images/emblems/Royal_Badge_of_Wales_2008-2024.svg +++ b/public/images/emblems/Royal_Badge_of_Wales_2008-2024.svg @@ -1608,8 +1608,8 @@ - - + + @@ -1645,7 +1645,7 @@ + width="1010" xlink:href="#Royal_Badge_of_Wales_2008-2024_b" /> @@ -2033,7 +2033,7 @@ transform="matrix(-1.0403497 .85243782 .85243782 1.0403497 -419.41861 -1578.5122)" /> - diff --git a/public/images/flags/ag-1962–1967.svg b/public/images/flags/ag-1962–1967.svg index d852720..fe95edb 100644 --- a/public/images/flags/ag-1962–1967.svg +++ b/public/images/flags/ag-1962–1967.svg @@ -74,990 +74,990 @@ d="M-36.117-273.063a2.469 2.469 0 0 0-2.475 2.475c-.034.938-.027 1.954.113 2.828h-6.125v10.961H-19.5v-10.96h-4.358c.212-.908.114-1.864.114-2.829a2.469 2.469 0 0 0-2.475-2.475z" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/images/flags/er.svg b/public/images/flags/er.svg index acd9aeb..c8ee9b4 100644 --- a/public/images/flags/er.svg +++ b/public/images/flags/er.svg @@ -4,8 +4,8 @@ - + - + \ No newline at end of file diff --git a/public/images/flags/ua-BilaCerkva.svg b/public/images/flags/ua-BilaCerkva.svg index 66f4036..a52072a 100644 --- a/public/images/flags/ua-BilaCerkva.svg +++ b/public/images/flags/ua-BilaCerkva.svg @@ -9,11 +9,11 @@ - + - + \ No newline at end of file diff --git a/public/images/flags/ua-Kyiv.svg b/public/images/flags/ua-Kyiv.svg index 068924c..df10b00 100644 --- a/public/images/flags/ua-Kyiv.svg +++ b/public/images/flags/ua-Kyiv.svg @@ -202,11 +202,11 @@ d="M459.69 152.94c6.3 7.16 14.82 6.92 19.64 0 .49 7.66 1.36 11.98 7.16 16.06-5.93 3.46-30.38 2.96-36.43 0 6.05-.86 9.26-4.57 9.63-16.06z" class="R W X" /> - + - - + - + diff --git a/public/images/flags/us-in.svg b/public/images/flags/us-in.svg index bd7ed43..30c0f3b 100644 --- a/public/images/flags/us-in.svg +++ b/public/images/flags/us-in.svg @@ -1,26 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - + + + - + - - - - @@ -183,7 +183,7 @@ fill="#fff" transform="matrix(6.9830469 0 0 6.9830469 139.6122 -8.282961)" /> - + fill="url(#us-ks_e)" /> + fill="url(#us-ks_d)" stroke="#000" stroke-width="5.586438" /> @@ -487,7 +487,7 @@ fill="#d15b25" /> + fill="url(#us-ks_c)" fill-rule="evenodd" stroke="#000" stroke-width="2.618643" /> @@ -668,7 +668,7 @@ + fill="url(#us-ks_b)" /> - + - + - - - - + fill="url(#us-la_d)" /> + fill="url(#us-la_c)" /> @@ -990,8 +990,8 @@ + fill="url(#us-la_e)" /> + fill="url(#us-la_f)" /> \ No newline at end of file diff --git a/public/images/flags/us-mo.svg b/public/images/flags/us-mo.svg index 53e19fd..7286e98 100644 --- a/public/images/flags/us-mo.svg +++ b/public/images/flags/us-mo.svg @@ -1522,49 +1522,49 @@ stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width=".518009" /> - - + xlink:href="#us-mo_a" /> + + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> - + xlink:href="#us-mo_a" /> + + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> - + xlink:href="#us-mo_a" /> + + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> + xlink:href="#us-mo_a" /> - + xlink:href="#us-mo_a" /> + - + xlink:href="#us-mo_a" /> + \ No newline at end of file diff --git a/public/images/flags/us-oh.svg b/public/images/flags/us-oh.svg index da5e60b..ce4a148 100644 --- a/public/images/flags/us-oh.svg +++ b/public/images/flags/us-oh.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/images/flags/us-tn.svg b/public/images/flags/us-tn.svg index 8704616..54b0967 100644 --- a/public/images/flags/us-tn.svg +++ b/public/images/flags/us-tn.svg @@ -1,5 +1,4 @@ - Flag of Tenessee, United States @@ -7,16 +6,16 @@ - - - + + + - - - - + + + + - \ No newline at end of file + diff --git a/public/images/flags/us-tx.svg b/public/images/flags/us-tx.svg index 094ead8..5530844 100644 --- a/public/images/flags/us-tx.svg +++ b/public/images/flags/us-tx.svg @@ -3,13 +3,13 @@ - - - + + + - - - - + + + + \ No newline at end of file diff --git a/public/images/flags/us-ut.svg b/public/images/flags/us-ut.svg index cac9096..2bc5b53 100644 --- a/public/images/flags/us-ut.svg +++ b/public/images/flags/us-ut.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/images/flags/us-vt.svg b/public/images/flags/us-vt.svg index 2cac94f..9b7c73f 100644 --- a/public/images/flags/us-vt.svg +++ b/public/images/flags/us-vt.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/public/images/logos/android-auto.svg b/public/images/logos/android-auto.svg index a66a15f..3d104e7 100644 --- a/public/images/logos/android-auto.svg +++ b/public/images/logos/android-auto.svg @@ -2,11 +2,11 @@ - + - + @@ -28,11 +28,11 @@ - + - \ No newline at end of file diff --git a/public/images/logos/apache.svg b/public/images/logos/apache.svg index 1565a4a..57db2f2 100644 --- a/public/images/logos/apache.svg +++ b/public/images/logos/apache.svg @@ -1,74 +1,74 @@ - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/public/images/logos/dockge.svg b/public/images/logos/dockge.svg index 206b986..71d30b7 100644 --- a/public/images/logos/dockge.svg +++ b/public/images/logos/dockge.svg @@ -1,12 +1,12 @@ - + style="stroke:#f2f2f2;stroke-opacity:.51;stroke-width:190;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:url(#dockge_a);fill-rule:nonzero;opacity:1" /> \ No newline at end of file diff --git a/public/images/logos/facebook-messenger.svg b/public/images/logos/facebook-messenger.svg index 8c9aea4..c98ace4 100644 --- a/public/images/logos/facebook-messenger.svg +++ b/public/images/logos/facebook-messenger.svg @@ -1,5 +1,5 @@ - @@ -8,7 +8,7 @@ + style="fill:url(#facebook-messenger_a)" /> diff --git a/public/images/logos/firefox.svg b/public/images/logos/firefox.svg index bdfd4b6..468dae7 100644 --- a/public/images/logos/firefox.svg +++ b/public/images/logos/firefox.svg @@ -1,103 +1,103 @@ - + - + - + - + - + - + - + - + - + - + - + - + + fill="url(#firefox_a)" /> + fill="url(#firefox_b)" /> + fill="url(#firefox_c)" /> + fill="url(#firefox_d)" /> + fill="url(#firefox_e)" /> + fill="url(#firefox_f)" /> + fill="url(#firefox_g)" /> + fill="url(#firefox_h)" /> + fill="url(#firefox_i)" /> + fill="url(#firefox_j)" /> + fill="url(#firefox_k)" /> + fill="url(#firefox_l)" /> \ No newline at end of file diff --git a/public/images/logos/forgejo.svg b/public/images/logos/forgejo.svg index eca6b87..b4b7888 100644 --- a/public/images/logos/forgejo.svg +++ b/public/images/logos/forgejo.svg @@ -20,7 +20,7 @@ d="M202.327,241.983c-11.787,0 -22.365,-2.569 -31.734,-7.706c-9.217,-5.289 -16.546,-12.543 -21.986,-21.76c-5.289,-9.218 -7.934,-19.72 -7.934,-31.507c0,-11.938 2.645,-22.44 7.934,-31.507c5.44,-9.218 12.769,-16.395 21.986,-21.533c9.218,-5.289 19.796,-7.933 31.734,-7.933c11.786,-0 22.289,2.644 31.506,7.933c9.369,5.138 16.698,12.315 21.987,21.533c5.289,9.067 7.933,19.569 7.933,31.507c0,11.787 -2.644,22.289 -7.933,31.507c-5.289,9.217 -12.618,16.471 -21.987,21.76c-9.217,5.137 -19.72,7.706 -31.506,7.706Zm-0,-16.546c8.16,-0 15.413,-1.814 21.76,-5.44c6.346,-3.778 11.333,-8.991 14.96,-15.64c3.778,-6.8 5.666,-14.583 5.666,-23.347c0,-8.916 -1.888,-16.698 -5.666,-23.347c-3.627,-6.649 -8.614,-11.786 -14.96,-15.413c-6.347,-3.627 -13.6,-5.44 -21.76,-5.44c-8.16,-0 -15.414,1.813 -21.76,5.44c-6.347,3.627 -11.409,8.764 -15.187,15.413c-3.627,6.649 -5.44,14.431 -5.44,23.347c0,8.764 1.813,16.547 5.44,23.347c3.778,6.649 8.84,11.862 15.187,15.64c6.346,3.626 13.6,5.44 21.76,5.44l-0,-0Z" style="fill:#f50;fill-rule:nonzero;" /> - + diff --git a/public/images/logos/google_chrome.svg b/public/images/logos/google_chrome.svg index 1693f35..e4e71d9 100644 --- a/public/images/logos/google_chrome.svg +++ b/public/images/logos/google_chrome.svg @@ -3,80 +3,80 @@ - - + - - - - + - - + - - - - + - - + - - - + - + @@ -117,12 +117,12 @@ - - + diff --git a/public/images/logos/google_chrome_icon.svg b/public/images/logos/google_chrome_icon.svg index 08f3de9..7dd3d46 100644 --- a/public/images/logos/google_chrome_icon.svg +++ b/public/images/logos/google_chrome_icon.svg @@ -1,14 +1,14 @@ - + - + - + @@ -18,12 +18,12 @@ d="M3.2154,36A24,24,0,1,0,12,3.2154,24,24,0,0,0,3.2154,36ZM34.3923,18A12,12,0,1,1,18,13.6077,12,12,0,0,1,34.3923,18Z" style="fill:none" /> + style="fill:url(#google_chrome_icon_a)" /> + style="fill:url(#google_chrome_icon_b)" /> + style="fill:url(#google_chrome_icon_c)" /> \ No newline at end of file diff --git a/public/images/logos/grafana.svg b/public/images/logos/grafana.svg index 12d574c..53dfdce 100644 --- a/public/images/logos/grafana.svg +++ b/public/images/logos/grafana.svg @@ -1,10 +1,10 @@ - + style="fill:url(#grafana_a)" /> \ No newline at end of file diff --git a/public/images/logos/homebridge.svg b/public/images/logos/homebridge.svg index 566a804..79b046d 100644 --- a/public/images/logos/homebridge.svg +++ b/public/images/logos/homebridge.svg @@ -1,17 +1,17 @@ - - - + - + diff --git a/public/images/logos/jellyfin.svg b/public/images/logos/jellyfin.svg index 7a3e939..2f3c6c6 100644 --- a/public/images/logos/jellyfin.svg +++ b/public/images/logos/jellyfin.svg @@ -1,16 +1,16 @@ - - - + + style="fill:url(#jellyfin_b)" /> \ No newline at end of file diff --git a/public/images/logos/shadoll.svg b/public/images/logos/shadoll.svg index 6ded17e..01096fd 100644 --- a/public/images/logos/shadoll.svg +++ b/public/images/logos/shadoll.svg @@ -1,7 +1,7 @@ - - + diff --git a/public/images/logos/tesla.svg b/public/images/logos/tesla.svg index 911ed14..0300811 100644 --- a/public/images/logos/tesla.svg +++ b/public/images/logos/tesla.svg @@ -36,7 +36,7 @@ /> - + diff --git a/scripts/svg-cleanup.js b/scripts/svg-cleanup.js index 855e9da..b780797 100644 --- a/scripts/svg-cleanup.js +++ b/scripts/svg-cleanup.js @@ -10,6 +10,57 @@ const { collections } = require('../src/collections.js'); const collectionArg = process.argv.find(arg => arg.startsWith('--collection=')); const collectionName = collectionArg ? collectionArg.split('=')[1] : (process.env.COLLECTION || 'logos'); +// Fix single-letter ID conflicts in SVG content +function fixSvgIds(svgContent, filename) { + let content = svgContent; + let updated = false; + let count = 0; + + // Find all single-letter IDs (both lowercase and uppercase) + const idMatches = content.match(/\bid\s*=\s*["']([a-zA-Z])["']/g); + + if (!idMatches) { + return { content, updated, count }; + } + + // Create a map of old ID to new ID + const idMap = new Map(); + + for (const match of idMatches) { + const idMatch = match.match(/\bid\s*=\s*["']([a-zA-Z])["']/); + if (idMatch) { + const oldId = idMatch[1]; + const newId = `${filename}_${oldId}`; + + if (!idMap.has(oldId)) { + idMap.set(oldId, newId); + } + } + } + + // Replace all single-letter IDs with prefixed versions + for (const [oldId, newId] of idMap) { + // Replace id attribute declarations + const idRegex = new RegExp(`\\bid\\s*=\\s*["']${oldId}["']`, 'g'); + content = content.replace(idRegex, `id="${newId}"`); + + // Replace references to the ID in url(), href, and other attributes + const urlRegex = new RegExp(`url\\(#${oldId}\\)`, 'g'); + content = content.replace(urlRegex, `url(#${newId})`); + + const hrefRegex = new RegExp(`href\\s*=\\s*["']#${oldId}["']`, 'g'); + content = content.replace(hrefRegex, `href="#${newId}"`); + + const xlinkHrefRegex = new RegExp(`xlink:href\\s*=\\s*["']#${oldId}["']`, 'g'); + content = content.replace(xlinkHrefRegex, `xlink:href="#${newId}"`); + + count++; + updated = true; + } + + return { content, updated, count }; +} + // SVG validation and fixing function function validateAndFixSvg(svgPath) { try { @@ -86,8 +137,18 @@ function validateAndFixSvg(svgPath) { console.log(`${path.basename(svgPath)}: Updated height to 100%`); } + // Fix ID conflicts - rename single-letter IDs + const idUpdates = fixSvgIds(svgContent, path.basename(svgPath, '.svg')); + if (idUpdates.updated) { + svgContent = idUpdates.content; + modified = true; + console.log(`${path.basename(svgPath)}: Updated ${idUpdates.count} single-letter IDs`); + } + if (modified) { - svgContent = svgContent.replace(svgTag, newSvgTag); + if (newSvgTag !== svgTag) { + svgContent = svgContent.replace(svgTag, newSvgTag); + } fs.writeFileSync(svgPath, svgContent, 'utf8'); console.log(`${path.basename(svgPath)}: SVG file updated`); }