diff --git a/README.md b/README.md index 546a20e..f9749e1 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,14 @@ npm i @egoistdeveloper/operating-system-logos - 64x64 - 128x128 -## List of operating system names and custom short codes -Image files are named according to these titles (*see the **[reference](https://github.com/matomo-org/device-detector/blob/228eef9a40f611a6661f1c93ee64c2c687dd3f11/Parser/OperatingSystem.php#L40)***). Current and frequently used logos defining operating systems were selected. Therefore, the version or naming differences were ignored when listing. +## List of operating system names and short codes + +Image files are named according to these name (*see the **[reference](https://github.com/matomo-org/device-detector/blob/228eef9a40f611a6661f1c93ee64c2c687dd3f11/Parser/OperatingSystem.php#L40)***). Current and frequently used logos defining operating systems were selected. Therefore, the version or naming differences were ignored when listing. + +There is no standard or formula for OS cataloging. This project uses above referenced alpha3 codes and generic names. There are many solution for OS name showing and we can use below listing methods. We can search in `slug/name` list then use matched result code for showing os icon file (yes, I know it is not the best way. we can discuss). + +Alpha3 list [alpha3-list.json](./src/alpha3-list.json) and slug list [slug-list.json](./src/os-list.json). + ## Preview List diff --git a/src/list.json b/src/alpha3-list.json similarity index 100% rename from src/list.json rename to src/alpha3-list.json diff --git a/src/list.js b/src/list.js index b0ed6e9..5768d4b 100644 --- a/src/list.js +++ b/src/list.js @@ -9,6 +9,11 @@ const sizeList = [16, 24, 32, 48, 64, 128], baseRepoAddress = 'https://raw.githubusercontent.com/EgoistDeveloper/operating-system-logos/master', previewSize = '48x48'; +/** + * Update readme preview list + * + * @param {string} newData + */ function updateList(newData) { fs.readFile('./../README.md', 'utf8', (err, data) => { if (err) { @@ -34,10 +39,23 @@ function updateList(newData) { }); } +function copyWithSlug(osCode, osName) { + const slug = osName.toLowerCase().replace(/ /g,'-').replace(/[-]+/g, '-').replace(/[^\w-]+/g,''); + + const slugItem = { + code: osCode, + name: osName, + slug: slug + }; + + return slugItem; +} + try { - let osList = JSON.parse(fs.readFileSync('list.json')), + let osList = JSON.parse(fs.readFileSync('alpha3-list.json')), tableMarkdown = `| Preview | Code | Name | Status |\n| ------- | ---- | ---- | ------ |\n`, - availableItems = 0; + availableItems = 0, + slugList = []; osList = Object.entries(osList); @@ -64,15 +82,17 @@ try { if (logoStackCount == 0) { tableMarkdown += `| ............ | ${osCode} | ${osName} | ❌ |\n`; - // console.log(`❌ ${osName} (${osCode}): all logos not found.\n--------------------------`); + console.log(`❌ ${osName} (${osCode}): all logos not found.\n--------------------------`); } else if (logoStackCount == sizeList.length) { tableMarkdown += `| ![](${baseRepoAddress}/src/${previewSize}/${osCode}.png "${osCode} (${previewSize})") | ${osCode} | ${osName} | ✅ |\n`; + slugList.push(copyWithSlug(osCode, osName)); + availableItems += 1; } else if (logoStackCount > 0 && logoStackCount < sizeList.length) { tableMarkdown += `| ............ | ${osCode} | ${osName} | ⭕ |\n`; - // console.log(`⭕ ${osName} (${osCode}): ${sizeList.length - logoStackCount} logos missing (sizes: ${missingSizes.join(', ')})\n--------------------------`); + console.log(`⭕ ${osName} (${osCode}): ${sizeList.length - logoStackCount} logos missing (sizes: ${missingSizes.join(', ')})\n--------------------------`); } //#endregion @@ -83,6 +103,14 @@ try { console.log(`\n${totalStatistics}\n\n`); updateList(`${totalStatistics}\n\n${tableMarkdown}`); + + if (slugList) { + fs.writeFile('./os-list.json', JSON.stringify(slugList, null, 2), function (err) { + if (err) throw err; + + console.log('slug-list.json updated!'); + }); + } } catch (err) { console.log(err.toString()); } \ No newline at end of file diff --git a/src/os-list.json b/src/os-list.json new file mode 100644 index 0000000..ba62c14 --- /dev/null +++ b/src/os-list.json @@ -0,0 +1,417 @@ +[ + { + "code": "AIX", + "name": "AIX", + "slug": "aix" + }, + { + "code": "AND", + "name": "Android", + "slug": "android" + }, + { + "code": "AMG", + "name": "AmigaOS", + "slug": "amigaos" + }, + { + "code": "ATV", + "name": "tvOS", + "slug": "tvos" + }, + { + "code": "ARL", + "name": "Arch Linux", + "slug": "arch-linux" + }, + { + "code": "BTR", + "name": "BackTrack", + "slug": "backtrack" + }, + { + "code": "SBA", + "name": "Bada", + "slug": "bada" + }, + { + "code": "BEO", + "name": "BeOS", + "slug": "beos" + }, + { + "code": "BLB", + "name": "BlackBerry OS", + "slug": "blackberry-os" + }, + { + "code": "QNX", + "name": "BlackBerry Tablet OS", + "slug": "blackberry-tablet-os" + }, + { + "code": "CAI", + "name": "Caixa Mágica", + "slug": "caixa-mgica" + }, + { + "code": "CES", + "name": "CentOS", + "slug": "centos" + }, + { + "code": "COS", + "name": "Chrome OS", + "slug": "chrome-os" + }, + { + "code": "CYN", + "name": "CyanogenMod", + "slug": "cyanogenmod" + }, + { + "code": "DEB", + "name": "Debian", + "slug": "debian" + }, + { + "code": "DEE", + "name": "Deepin", + "slug": "deepin" + }, + { + "code": "DFB", + "name": "DragonFly", + "slug": "dragonfly" + }, + { + "code": "FED", + "name": "Fedora", + "slug": "fedora" + }, + { + "code": "FOS", + "name": "Firefox OS", + "slug": "firefox-os" + }, + { + "code": "FIR", + "name": "Fire OS", + "slug": "fire-os" + }, + { + "code": "BSD", + "name": "FreeBSD", + "slug": "freebsd" + }, + { + "code": "FYD", + "name": "FydeOS", + "slug": "fydeos" + }, + { + "code": "GNT", + "name": "Gentoo", + "slug": "gentoo" + }, + { + "code": "GTV", + "name": "Google TV", + "slug": "google-tv" + }, + { + "code": "HPX", + "name": "HP-UX", + "slug": "hp-ux" + }, + { + "code": "HAI", + "name": "Haiku OS", + "slug": "haiku-os" + }, + { + "code": "IPA", + "name": "iPadOS", + "slug": "ipados" + }, + { + "code": "HAR", + "name": "HarmonyOS", + "slug": "harmonyos" + }, + { + "code": "KOS", + "name": "KaiOS", + "slug": "kaios" + }, + { + "code": "KNO", + "name": "Knoppix", + "slug": "knoppix" + }, + { + "code": "KBT", + "name": "Kubuntu", + "slug": "kubuntu" + }, + { + "code": "LIN", + "name": "GNU/Linux", + "slug": "gnulinux" + }, + { + "code": "LBT", + "name": "Lubuntu", + "slug": "lubuntu" + }, + { + "code": "MAC", + "name": "Mac", + "slug": "mac" + }, + { + "code": "MAE", + "name": "Maemo", + "slug": "maemo" + }, + { + "code": "MAG", + "name": "Mageia", + "slug": "mageia" + }, + { + "code": "MDR", + "name": "Mandriva", + "slug": "mandriva" + }, + { + "code": "SMG", + "name": "MeeGo", + "slug": "meego" + }, + { + "code": "MIN", + "name": "Mint", + "slug": "mint" + }, + { + "code": "MOR", + "name": "MorphOS", + "slug": "morphos" + }, + { + "code": "NBS", + "name": "NetBSD", + "slug": "netbsd" + }, + { + "code": "WII", + "name": "Nintendo", + "slug": "nintendo" + }, + { + "code": "NDS", + "name": "Nintendo Mobile", + "slug": "nintendo-mobile" + }, + { + "code": "OS2", + "name": "OS/2", + "slug": "os2" + }, + { + "code": "OBS", + "name": "OpenBSD", + "slug": "openbsd" + }, + { + "code": "OWR", + "name": "OpenWrt", + "slug": "openwrt" + }, + { + "code": "PCL", + "name": "PCLinuxOS", + "slug": "pclinuxos" + }, + { + "code": "PSP", + "name": "PlayStation Portable", + "slug": "playstation-portable" + }, + { + "code": "PS3", + "name": "PlayStation", + "slug": "playstation" + }, + { + "code": "RHT", + "name": "Red Hat", + "slug": "red-hat" + }, + { + "code": "ROS", + "name": "RISC OS", + "slug": "risc-os" + }, + { + "code": "ROK", + "name": "Roku OS", + "slug": "roku-os" + }, + { + "code": "RSO", + "name": "Rosa", + "slug": "rosa" + }, + { + "code": "REM", + "name": "Remix OS", + "slug": "remix-os" + }, + { + "code": "REX", + "name": "REX", + "slug": "rex" + }, + { + "code": "SAB", + "name": "Sabayon", + "slug": "sabayon" + }, + { + "code": "SSE", + "name": "SUSE", + "slug": "suse" + }, + { + "code": "SAF", + "name": "Sailfish OS", + "slug": "sailfish-os" + }, + { + "code": "SLW", + "name": "Slackware", + "slug": "slackware" + }, + { + "code": "SOS", + "name": "Solaris", + "slug": "solaris" + }, + { + "code": "SYL", + "name": "Syllable", + "slug": "syllable" + }, + { + "code": "SYM", + "name": "Symbian", + "slug": "symbian" + }, + { + "code": "SYS", + "name": "Symbian OS", + "slug": "symbian-os" + }, + { + "code": "S40", + "name": "Symbian OS Series 40", + "slug": "symbian-os-series-40" + }, + { + "code": "S60", + "name": "Symbian OS Series 60", + "slug": "symbian-os-series-60" + }, + { + "code": "SY3", + "name": "Symbian^3", + "slug": "symbian3" + }, + { + "code": "TDX", + "name": "ThreadX", + "slug": "threadx" + }, + { + "code": "TIZ", + "name": "Tizen", + "slug": "tizen" + }, + { + "code": "UBT", + "name": "Ubuntu", + "slug": "ubuntu" + }, + { + "code": "WAS", + "name": "watchOS", + "slug": "watchos" + }, + { + "code": "WHS", + "name": "Whale OS", + "slug": "whale-os" + }, + { + "code": "WIN", + "name": "Windows", + "slug": "windows" + }, + { + "code": "WCE", + "name": "Windows CE", + "slug": "windows-ce" + }, + { + "code": "WIO", + "name": "Windows IoT", + "slug": "windows-iot" + }, + { + "code": "WMO", + "name": "Windows Mobile", + "slug": "windows-mobile" + }, + { + "code": "WPH", + "name": "Windows Phone", + "slug": "windows-phone" + }, + { + "code": "WRT", + "name": "Windows RT", + "slug": "windows-rt" + }, + { + "code": "XBX", + "name": "Xbox", + "slug": "xbox" + }, + { + "code": "XBT", + "name": "Xubuntu", + "slug": "xubuntu" + }, + { + "code": "YNS", + "name": "YunOs", + "slug": "yunos" + }, + { + "code": "IOS", + "name": "iOS", + "slug": "ios" + }, + { + "code": "POS", + "name": "palmOS", + "slug": "palmos" + }, + { + "code": "WOS", + "name": "webOS", + "slug": "webos" + } +] \ No newline at end of file