From b0fbd2199fc51bc6fc33bf22f2a42ab7808d68b5 Mon Sep 17 00:00:00 2001 From: Herwin Date: Mon, 8 Jan 2024 11:55:17 +0100 Subject: [PATCH] Removed static content index, Added independant base files for content system's index Update compile-content.cmd, compile.bat, and 11 more files... --- .gitignore | 1 + compile-content.cmd | 20 ++++ compile.bat | 1 + content-index-maker.py | 0 content/index.json | 109 ------------------ content/raw_index/circuitpython-ebyte-e32.yml | 15 +++ content/raw_index/dotnet-arguments.yml | 12 ++ .../excel-worksheet-password-remover.yml | 16 +++ content/raw_index/lscom-cli-dotnet.yml | 19 +++ content/raw_index/lscom-cli.yml | 19 +++ .../raw_index/mc-expanded-iron-bundles.yml | 13 +++ content/raw_index/youtube-auto-archiver.yml | 14 +++ content_index_maker.py | 100 ++++++++++++++++ requirements.txt | 1 + 14 files changed, 231 insertions(+), 109 deletions(-) create mode 100644 compile-content.cmd create mode 100644 content-index-maker.py delete mode 100644 content/index.json create mode 100644 content/raw_index/circuitpython-ebyte-e32.yml create mode 100644 content/raw_index/dotnet-arguments.yml create mode 100644 content/raw_index/excel-worksheet-password-remover.yml create mode 100644 content/raw_index/lscom-cli-dotnet.yml create mode 100644 content/raw_index/lscom-cli.yml create mode 100644 content/raw_index/mc-expanded-iron-bundles.yml create mode 100644 content/raw_index/youtube-auto-archiver.yml create mode 100644 content_index_maker.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 8f46d4b..f647804 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ resources/PlotlyJs/ *.min.php *.min.js commons/strings.json +content/index.json resources/NibblePoker/css/*.css tools/items/formula-wizard/*.js tools/items/formula-wizard/src/*.js diff --git a/compile-content.cmd b/compile-content.cmd new file mode 100644 index 0000000..4a76708 --- /dev/null +++ b/compile-content.cmd @@ -0,0 +1,20 @@ +@echo off +setlocal enabledelayedexpansion + +:: Going into the script's directory +cd /D "%~dp0" + + +:content +echo. +echo Handling the raw content files +echo ------------------------------ + +:content-compile +echo Compiling index files... +python content_index_maker.py ./content/raw_index/ ./content/index.json + +:content-end + + +:end diff --git a/compile.bat b/compile.bat index 7464d6c..6791678 100644 --- a/compile.bat +++ b/compile.bat @@ -7,6 +7,7 @@ cd /D "%~dp0" :: Running sub-scripts call "%~dp0compile-clean.cmd" call "%~dp0compile-strings.cmd" +call "%~dp0compile-content.cmd" call "%~dp0compile-sass.cmd" call "%~dp0compile-js-site.cmd" call "%~dp0compile-js-external.cmd" diff --git a/content-index-maker.py b/content-index-maker.py new file mode 100644 index 0000000..e69de29 diff --git a/content/index.json b/content/index.json deleted file mode 100644 index 4bd43b6..0000000 --- a/content/index.json +++ /dev/null @@ -1,109 +0,0 @@ -[ - { - "id": "circuitpython-ebyte-e32", - "title": { - "en": "CircuitPython Ebyte E32", - "fr": "CircuitPython Ebyte E32" - }, - "preamble": { - "en": "CircuitPython driver for Ebyte's E32 UART LoRa modules that use the SX1278/SX1276 chipsets.", - "fr": "Driver CircuitPython pour les modules sérial LoRa E32 de Ebyte tournant sous les chipset SX1278/SX1276." - }, - "image": "/resources/NibblePoker/images/content/circuitpython-ebyte-e32/main.png", - "tags": ["electronic", "python" ,"circuitpython", "lora", "library"], - "priority": 105 - }, - { - "id": "lscom-cli-dotnet", - "title": { - "en": "DotNet-ListComPort", - "fr": "DotNet-ListComPort" - }, - "preamble": { - "en": "A simple CLI tool that can list COM ports with their name, friendly name and device name easily and cleanly.
This tool is intended to replace the tedious task of having to use the mode command, and the Device Manager to find a newly plugged-in device that provides a COM port.", - "fr": "Un petit utilitaire pour invité de commande qui permet de facilement lister les noms, noms formatés et chemins des ports COM.
Cet outil a pour bût de faciliter cette tâche sans avoir à utiliser la commande mode ou le Gestionnaire de périphérique." - }, - "image": "/resources/NibblePoker/images/content/lscom/lscom-v2-text-01-bkgd-cli.png", - "tags": ["application", "tool" ,"lscom", "dotnet", "windows"], - "priority": 100 - }, - { - "id": "youtube-auto-archiver", - "title": { - "en": "Youtube-Auto-Archiver", - "fr": "Youtube-Auto-Archiver" - }, - "preamble": { - "en": "A simple and yet highly configurable Python application that automatically checks if a Youtuber is streaming, and downloads said streams while also archiving its latest uploads.", - "fr": "Conteneur et application Python hautement configurable qui permet d'automatiquement archiver et télécharger des livestreams et vidéos depuis YouTube." - }, - "image": "/resources/NibblePoker/images/content/yaa/icon-final.png", - "tags": ["docker", "application", "web", "python"], - "priority": 30 - }, - { - "id": "excel-worksheet-password-remover", - "title": { - "en": "Excel-Worksheet-Password-Remover", - "fr": "Excel-Worksheet-Password-Remover" - }, - "preamble": { - "en": "Small web page from which you can easily remove a password from an Excel worksheet.
It works by leaving the task of editing the XML files on an Excel document to your browser instead to keep everything local.", - "fr": "Petite application web qui permet de facilement retirer le mot de passe d'une feuille de calcul Excel depuis votre navigateur web sans avoir à uploader le fichier sur internet.
Cette application laisse votre navigateur modifier les fichiers XML du fichier Excel afin de tout garder en local." - }, - "image": "/resources/NibblePoker/images/content/excel-password-remover/excel-password-remover.png", - "tags": [ - "tool", - "web" - ], - "priority": 50 - }, - { - "id": "dotnet-arguments", - "title": { - "en": "DotNet-Arguments", - "fr": "DotNet-Arguments" - }, - "preamble": { - "en": "A simple and 'to-the-point' library to parse launch arguments in .NET and .NET Core applications.", - "fr": "Une petite librairie simple et efficace pour lire et interpréter les options de lancement d'un programme pour .NET et .NET Core." - }, - "image": "/resources/NibblePoker/images/content/dotnet-arguments/main.png", - "tags": [ - "library", - "dotnet" - ], - "priority": 40 - }, - { - "id": "mc-expanded-iron-bundles", - "title": { - "en": "Expanded Iron Bundles", - "fr": "Expanded Iron Bundles" - }, - "preamble": { - "en": "A small Minecraft mod that provides bundles with more storage space, and new functionalities in the future.", - "fr": "Un petit mod pour Minecraft qui ajoute des sacs avec plus d'espace de stockage et de nouvelles fonctionalitées dans le futur." - }, - "image": "/resources/NibblePoker/images/content/mc-expanded-iron-bundles/item-icon.png", - "tags": [ - "game", - "minecraft", - "mod" - ], - "priority": 20 - }, - { - "id": "lscom-cli", - "title": { - "en": "PB-ListComPort (Legacy)", - "fr": "PB-ListComPort (Legacy)" - }, - "preamble": { - "en": "A simple CLI tool that can list COM ports with their name, friendly name and device name easily and cleanly.
This tool is intended to replace the tedious task of having to use the mode command, and the Device Manager to find a newly plugged-in device that provides a COM port.", - "fr": "Un petit utilitaire pour invité de commande qui permet de facilement lister les noms, noms formatés et chemins des ports COM.
Cet outil a pour bût de faciliter cette tâche sans avoir à utiliser la commande mode ou le Gestionnaire de périphérique." - }, - "image": "/resources/NibblePoker/images/content/lscom/lscom-legacy-simple.png", - "tags": ["application", "tool" ,"lscom", "purebasic", "windows"] - } -] diff --git a/content/raw_index/circuitpython-ebyte-e32.yml b/content/raw_index/circuitpython-ebyte-e32.yml new file mode 100644 index 0000000..9dcd47f --- /dev/null +++ b/content/raw_index/circuitpython-ebyte-e32.yml @@ -0,0 +1,15 @@ +circuitpython-ebyte-e32: + title: + en: "CircuitPython Ebyte E32" + fr: "CircuitPython Ebyte E32" + preamble: + en: "CircuitPython driver for Ebyte's E32 UART LoRa modules that use the SX1278/SX1276 chipsets." + fr: "Driver CircuitPython pour les modules sérial LoRa E32 de Ebyte tournant sous les chipset SX1278/SX1276." + image: "/resources/NibblePoker/images/content/circuitpython-ebyte-e32/main.png" + tags: + - "electronic" + - "python" + - "circuitpython" + - "lora" + - "library" + priority: 105 diff --git a/content/raw_index/dotnet-arguments.yml b/content/raw_index/dotnet-arguments.yml new file mode 100644 index 0000000..fbabe47 --- /dev/null +++ b/content/raw_index/dotnet-arguments.yml @@ -0,0 +1,12 @@ +dotnet-arguments: + title: + en: "DotNet-Arguments" + fr: "DotNet-Arguments" + preamble: + en: "A simple and 'to-the-point' library to parse launch arguments in .NET and .NET Core applications." + fr: "Une petite librairie simple et efficace pour lire et interpréter les options de lancement d'un programme pour .NET et .NET Core." + image: "/resources/NibblePoker/images/content/dotnet-arguments/main.png" + tags: + - "library" + - "dotnet" + priority: 40 diff --git a/content/raw_index/excel-worksheet-password-remover.yml b/content/raw_index/excel-worksheet-password-remover.yml new file mode 100644 index 0000000..eb0d032 --- /dev/null +++ b/content/raw_index/excel-worksheet-password-remover.yml @@ -0,0 +1,16 @@ +excel-worksheet-password-remover: + title: + en: "Excel-Worksheet-Password-Remover" + fr: "Excel-Worksheet-Password-Remover" + preamble: + en: + - "Small web page from which you can easily remove a password from an Excel worksheet." + - "It works by leaving the task of editing the XML files on an Excel document to your browser instead to keep everything local." + fr: + - "Petite application web qui permet de facilement retirer le mot de passe d'une feuille de calcul Excel depuis votre navigateur web sans avoir à uploader le fichier sur internet." + - "Cette application laisse votre navigateur modifier les fichiers XML du fichier Excel afin de tout garder en local." + image: "/resources/NibblePoker/images/content/excel-password-remover/excel-password-remover.png" + tags: + - "tool" + - "web" + priority: 50 diff --git a/content/raw_index/lscom-cli-dotnet.yml b/content/raw_index/lscom-cli-dotnet.yml new file mode 100644 index 0000000..7d3431f --- /dev/null +++ b/content/raw_index/lscom-cli-dotnet.yml @@ -0,0 +1,19 @@ +lscom-cli-dotnet: + title: + en: "DotNet-ListComPort" + fr: "DotNet-ListComPort" + preamble: + en: + - "A simple CLI tool that can list COM ports with their name, friendly name and device name easily and cleanly." + - "This tool is intended to replace the tedious task of having to use the mode command, and the Device Manager to find a newly plugged-in device that provides a COM port." + fr: + - "Un petit utilitaire pour invité de commande qui permet de facilement lister les noms, noms formatés et chemins des ports COM." + - "Cet outil a pour bût de faciliter cette tâche sans avoir à utiliser la commande mode ou le Gestionnaire de périphérique." + image: "/resources/NibblePoker/images/content/lscom/lscom-v2-text-01-bkgd-cli.png" + tags: + - "application" + - "tool" + - "lscom" + - "dotnet" + - "windows" + priority: 100 diff --git a/content/raw_index/lscom-cli.yml b/content/raw_index/lscom-cli.yml new file mode 100644 index 0000000..fcfd481 --- /dev/null +++ b/content/raw_index/lscom-cli.yml @@ -0,0 +1,19 @@ +lscom-cli: + title: + en: "PB-ListComPort (Legacy)" + fr: "PB-ListComPort (Legacy)" + preamble: + en: + - "A simple CLI tool that can list COM ports with their name, friendly name and device name easily and cleanly." + - "This tool is intended to replace the tedious task of having to use the mode command, and the Device Manager to find a newly plugged-in device that provides a COM port." + fr: + - "Un petit utilitaire pour invité de commande qui permet de facilement lister les noms, noms formatés et chemins des ports COM." + - "Cet outil a pour bût de faciliter cette tâche sans avoir à utiliser la commande mode ou le Gestionnaire de périphérique." + image: "/resources/NibblePoker/images/content/lscom/lscom-legacy-simple.png" + tags: + - "application" + - "tool" + - "lscom" + - "purebasic" + - "windows" + priority: 1 diff --git a/content/raw_index/mc-expanded-iron-bundles.yml b/content/raw_index/mc-expanded-iron-bundles.yml new file mode 100644 index 0000000..edf1a11 --- /dev/null +++ b/content/raw_index/mc-expanded-iron-bundles.yml @@ -0,0 +1,13 @@ +mc-expanded-iron-bundles: + title: + en: "Expanded Iron Bundles" + fr: "Expanded Iron Bundles" + preamble: + en: "A small Minecraft mod that provides bundles with more storage space, and new functionalities in the future." + fr: "Un petit mod pour Minecraft qui ajoute des sacs avec plus d'espace de stockage et de nouvelles fonctionalitées dans le futur." + image: "/resources/NibblePoker/images/content/mc-expanded-iron-bundles/item-icon.png" + tags: + - "game" + - "minecraft" + - "mod" + priority: 20 diff --git a/content/raw_index/youtube-auto-archiver.yml b/content/raw_index/youtube-auto-archiver.yml new file mode 100644 index 0000000..348b0f7 --- /dev/null +++ b/content/raw_index/youtube-auto-archiver.yml @@ -0,0 +1,14 @@ +youtube-auto-archiver: + title: + en: "Youtube-Auto-Archiver" + fr: "Youtube-Auto-Archiver" + preamble: + en: "A simple and yet highly configurable Python application that automatically checks if a Youtuber is streaming, and downloads said streams while also archiving its latest uploads." + fr: "Conteneur et application Python hautement configurable qui permet d'automatiquement archiver et télécharger des livestreams et vidéos depuis YouTube." + image: "/resources/NibblePoker/images/content/yaa/icon-final.png" + tags: + - "docker" + - "application" + - "web" + - "python" + priority: 30 diff --git a/content_index_maker.py b/content_index_maker.py new file mode 100644 index 0000000..f5f8247 --- /dev/null +++ b/content_index_maker.py @@ -0,0 +1,100 @@ +#!/bin/python + +import argparse +import json +import os +import sys + +# Importing YAML parser safely +try: + import yaml +except ImportError: + print("You need to install the 'PyYAML' module to continue !") + sys.exit(10) + +# Including nicer-looking print function if possible. +try: + from rich import print +except ImportError: + pass + +# Preparing and parsing launch arguments +parser = argparse.ArgumentParser() +parser.add_argument("input", help="Input folder where the strings are located.") +parser.add_argument("output", help="Output file where the compiled strings will be saved.") + + +# Fixing some issues with "argparse" +def argparse_error(message): + raise argparse.ArgumentError(None, message) + + +# Parsing launch options +parser.error = argparse_error +try: + args = parser.parse_args() +except argparse.ArgumentError as err: + print(f"\033[31m\033[1mError:\033[0m\033[31m {err.message.capitalize()}\033[39m") + print("\033[36m\033[1mUsage:\033[0m\033[36m content_index_maker.py \033[39m") + sys.exit(1) + +# Checking the given options are valid +if not (os.path.exists(args.input) and os.path.isdir(args.input)): + print(f"\033[31m\033[1mError:\033[0m\033[31m The given input directory '{args.input}' doesn't exist or is a file !\033[39m") + sys.exit(2) + +if os.path.isdir(args.output): + print(f"\033[31m\033[1mError:\033[0m\033[31m The given output '{args.output}' is a directory !\033[39m") + sys.exit(3) + +# Starting the process +print(f"Compiling '{args.input}' to '{args.output}'...") +input_folder = os.path.abspath(args.input) +output_file = os.path.abspath(args.output) + +index_data = list() + +for index_entry_filename in os.listdir(input_folder): + if index_entry_filename.startswith("_"): + continue + + print("> Processing '{}'".format(index_entry_filename)) + + with open(os.path.join(input_folder, index_entry_filename), 'r') as f: + index_entry_data = yaml.safe_load(f) + + # Checking some stuff + if type(index_entry_data) is not dict: + raise ValueError(f"The data for '{index_entry_filename}' isn't a dict !") + + if len(index_entry_data.keys()) < 1: + raise ValueError(f"The '{index_entry_filename}' file is empty !") + + # Fixing the ID + _id_tmp = list(index_entry_data.keys())[0] + index_entry_data[_id_tmp]["id"] = _id_tmp + + # Un-nesting the data + index_entry_data = index_entry_data[_id_tmp] + + # Joining the preamble's lines + if "preamble" not in index_entry_data.keys(): + raise ValueError(f"The 'preamble' field is missing from ''{index_entry_filename}' !") + + if type(index_entry_data["preamble"]) is not dict: + raise ValueError(f"The 'preamble' field for '{index_entry_filename}' isn't a dict !") + + for preamble_lang_key in index_entry_data["preamble"].keys(): + if type(index_entry_data["preamble"][preamble_lang_key]) is list: + index_entry_data["preamble"][preamble_lang_key] = "
".join(index_entry_data["preamble"][preamble_lang_key]) + + # Saving the data + index_data.append(index_entry_data) + +try: + os.remove(output_file) +except IOError: + pass + +with open(output_file, "wb") as f: + f.write(json.dumps(index_data, separators=(',', ':')).encode("utf-8")) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..11b6503 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +PyYAML>=6.0.1