Removed static content index, Added independant base files for content system's index

Update compile-content.cmd, compile.bat, and 11 more files...
This commit is contained in:
2024-01-08 11:55:17 +01:00
parent 153c7967ff
commit b0fbd2199f
14 changed files with 231 additions and 109 deletions

1
.gitignore vendored
View File

@@ -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

20
compile-content.cmd Normal file
View File

@@ -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

View File

@@ -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"

0
content-index-maker.py Normal file
View File

View File

@@ -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.<br>This tool is intended to replace the tedious task of having to use the <code>mode</code> command, and the <i>Device Manager</i> 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.<br>Cet outil a pour bût de faciliter cette tâche sans avoir à utiliser la commande <code>mode</code> ou le <i>Gestionnaire de périphérique</i>."
},
"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.<br>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.<br>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.<br>This tool is intended to replace the tedious task of having to use the <code>mode</code> command, and the <i>Device Manager</i> 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.<br>Cet outil a pour bût de faciliter cette tâche sans avoir à utiliser la commande <code>mode</code> ou le <i>Gestionnaire de périphérique</i>."
},
"image": "/resources/NibblePoker/images/content/lscom/lscom-legacy-simple.png",
"tags": ["application", "tool" ,"lscom", "purebasic", "windows"]
}
]

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 <code>mode</code> command, and the <i>Device Manager</i> 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 <code>mode</code> ou le <i>Gestionnaire de périphérique</i>."
image: "/resources/NibblePoker/images/content/lscom/lscom-v2-text-01-bkgd-cli.png"
tags:
- "application"
- "tool"
- "lscom"
- "dotnet"
- "windows"
priority: 100

View File

@@ -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 <code>mode</code> command, and the <i>Device Manager</i> 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 <code>mode</code> ou le <i>Gestionnaire de périphérique</i>."
image: "/resources/NibblePoker/images/content/lscom/lscom-legacy-simple.png"
tags:
- "application"
- "tool"
- "lscom"
- "purebasic"
- "windows"
priority: 1

View File

@@ -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

View File

@@ -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

100
content_index_maker.py Normal file
View File

@@ -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 <input_folder> <output_file>\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] = "<br>".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"))

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
PyYAML>=6.0.1