From 9b95855d4e48db14d4020b79e0df0d67f4986385 Mon Sep 17 00:00:00 2001 From: sHa Date: Sun, 4 May 2025 13:05:06 +0300 Subject: [PATCH] Add MySQL logo; enhance logo scanning logic --- public/data/logos.json | 75 +++++++++++++++++++++++------------------- public/logos/mysql.svg | 27 +++++++++++++++ scripts/scanLogos.js | 66 +++++++++++++++++++++++-------------- 3 files changed, 110 insertions(+), 58 deletions(-) create mode 100644 public/logos/mysql.svg diff --git a/public/data/logos.json b/public/data/logos.json index f6f65b8..156df79 100644 --- a/public/data/logos.json +++ b/public/data/logos.json @@ -508,6 +508,17 @@ "brand": "Mikrotik", "tags": [] }, + { + "name": "Monobank", + "path": "logos/monobank_text.svg", + "format": "SVG", + "disable": false, + "brand": "Monobank", + "tags": [ + "bank", + "finance" + ] + }, { "name": "Mono Black", "path": "logos/mono_black.svg", @@ -553,15 +564,15 @@ ] }, { - "name": "Monobank (text)", - "path": "logos/monobank_text.svg", + "name": "MySQL", + "path": "logos/mysql.svg", "format": "SVG", "disable": false, - "brand": "Monobank", "tags": [ - "bank", - "finance" - ] + "software", + "database" + ], + "brand": "MySQL" }, { "name": "Nationwide", @@ -607,16 +618,16 @@ "brand": "Nikamebel" }, { - "name": "Nova Global", - "path": "logos/nova_global.svg", + "name": "Nova Post", + "path": "logos/nova_post.svg", "format": "SVG", "disable": false, "brand": "Nova Post", "tags": [] }, { - "name": "Nova Post", - "path": "logos/nova_post.svg", + "name": "Nova Global", + "path": "logos/nova_global.svg", "format": "SVG", "disable": false, "brand": "Nova Post", @@ -657,7 +668,6 @@ "format": "SVG", "disable": false, "tags": [ - "tech", "software", "database" ], @@ -732,11 +742,10 @@ }, { "name": "Python", - "path": "logos/python-logo.svg", + "path": "logos/python.svg", "format": "SVG", "disable": false, "tags": [ - "tech", "software", "programming" ], @@ -744,24 +753,15 @@ }, { "name": "Python", - "path": "logos/python.svg", + "path": "logos/python-logo.svg", "format": "SVG", "disable": false, "tags": [ - "tech", "software", "programming" ], "brand": "Python" }, - { - "name": "RabbitMQ", - "path": "logos/rabbitmq-logo.svg", - "format": "SVG", - "disable": false, - "tags": [], - "brand": "RabbitMQ" - }, { "name": "RabbitMQ", "path": "logos/rabbitmq.svg", @@ -771,16 +771,12 @@ "brand": "RabbitMQ" }, { - "name": "Redis", - "path": "logos/redis-logo.svg", + "name": "RabbitMQ", + "path": "logos/rabbitmq-logo.svg", "format": "SVG", "disable": false, - "tags": [ - "tech", - "software", - "database" - ], - "brand": "Redis" + "tags": [], + "brand": "RabbitMQ" }, { "name": "Redis", @@ -788,7 +784,6 @@ "format": "SVG", "disable": false, "tags": [ - "tech", "software", "database" ], @@ -803,6 +798,18 @@ "selector": "#text" } }, + { + "name": "Redis", + "path": "logos/redis-logo.svg", + "format": "SVG", + "disable": false, + "tags": [ + "tech", + "software", + "database" + ], + "brand": "Redis" + }, { "name": "Reebok", "path": "logos/reebok.svg", @@ -938,7 +945,7 @@ }, { "name": "Signal", - "path": "logos/signal-logo.svg", + "path": "logos/signal.svg", "format": "SVG", "disable": false, "tags": [ @@ -958,7 +965,7 @@ }, { "name": "Signal", - "path": "logos/signal.svg", + "path": "logos/signal-logo.svg", "format": "SVG", "disable": false, "tags": [ diff --git a/public/logos/mysql.svg b/public/logos/mysql.svg new file mode 100644 index 0000000..0166786 --- /dev/null +++ b/public/logos/mysql.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + diff --git a/scripts/scanLogos.js b/scripts/scanLogos.js index 2fd91b6..35b9fa2 100644 --- a/scripts/scanLogos.js +++ b/scripts/scanLogos.js @@ -119,36 +119,54 @@ function scanLogos() { console.log(`Found ${logoFiles.length} logo files`); - // Create logo objects - const logos = logoFiles.map(file => { - const format = getFileExtension(file); - const logoPath = `logos/${file}`; - const existingItem = existingMap.get(logoPath); - let logoObj; - if (existingItem) { - // Preserve name, tags, and disable, update format/path - logoObj = { - ...existingItem, - path: logoPath, - format: format, - disable: typeof existingItem.disable === 'boolean' ? existingItem.disable : false, - brand: existingItem.brand || existingItem.name || formatName(file) - }; - } else { - // New logo - logoObj = { + // Create a Set of all logo paths in the directory + const logoPathsSet = new Set(logoFiles.map(file => `logos/${file}`)); + + // 1. Keep all existing logos that still exist in the directory, in their original order + const keptLogos = existing.filter(item => logoPathsSet.has(item.path)); + const keptPaths = new Set(keptLogos.map(item => item.path)); + + // 2. Add new logos (not present in existing) and sort them alphabetically by name + const newLogos = logoFiles + .filter(file => !keptPaths.has(`logos/${file}`)) + .map(file => { + const format = getFileExtension(file); + const logoPath = `logos/${file}`; + return { name: formatName(file), path: logoPath, format: format, disable: false, + tags: [], }; + }) + .sort((a, b) => a.name.localeCompare(b.name)); + + // 3. Merge: existing (kept) + new (sorted) + // Instead of just appending newLogos, insert each new logo in the correct sorted position by name + let merged = [...keptLogos]; + for (const newLogo of newLogos) { + // Find the first index where newLogo.name < merged[i].name + let insertIdx = merged.findIndex(l => newLogo.name.localeCompare(l.name) < 0); + if (insertIdx === -1) { + merged.push(newLogo); + } else { + merged.splice(insertIdx, 0, newLogo); } - // Ensure tags field exists and is an array - if (!Array.isArray(logoObj.tags)) { - logoObj.tags = []; - } - return logoObj; - }); + } + const logos = merged; + + // 4. For all, update format/path/brand fields if needed + for (const logoObj of logos) { + const file = path.basename(logoObj.path); + logoObj.format = getFileExtension(file); + logoObj.path = `logos/${file}`; + if (!logoObj.name) logoObj.name = formatName(file); + if (!logoObj.brand) logoObj.brand = logoObj.name; + if (!Array.isArray(logoObj.tags)) logoObj.tags = []; + if (typeof logoObj.disable !== 'boolean') logoObj.disable = false; + } + return logos; } catch (error) { console.error('Error scanning logos directory:', error);