Revamped XML sitemap, Added run configs, Added release script, Removed commented HTML

Update .gitignore, app.py - Minify.run.xml, and 11 more files...
This commit is contained in:
2025-09-13 18:13:24 +02:00
parent abd7046fe2
commit 1612416d9d
13 changed files with 245 additions and 34 deletions

3
.gitignore vendored
View File

@@ -19,9 +19,8 @@ static/resources/DecimalJs*
static/resources/SortableJS
static/resources/Standalone
# Secrets
# Golang revamp
src/
bin/
app/
.run/
*.tmpl

View File

@@ -0,0 +1,26 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="app.py - Minify" type="PythonConfigurationType" factoryName="Python">
<module name="Web-NibblePoker" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
<env name="NP_HTML_POST_PROCESS" value="MINIFY" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/app.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@@ -0,0 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="compile-js-site" type="BatchConfigurationType" factoryName="Batch">
<module name="Web-NibblePoker" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="WORKING_DIRECTORY" value="./scripts" />
<option name="PARENT_ENVS" value="true" />
<option name="SCRIPT_NAME" value="compile-js-site.cmd" />
<option name="PARAMETERS" value="" />
<method v="2" />
</configuration>
</component>

View File

@@ -0,0 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="delete-minified-js" type="BatchConfigurationType" factoryName="Batch">
<module name="Web-NibblePoker" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="WORKING_DIRECTORY" value="./scripts" />
<option name="PARENT_ENVS" value="true" />
<option name="SCRIPT_NAME" value="delete-minified-js.cmd" />
<option name="PARAMETERS" value="" />
<method v="2" />
</configuration>
</component>

View File

@@ -0,0 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="delete-pycache" type="BatchConfigurationType" factoryName="Batch">
<module name="Web-NibblePoker" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="WORKING_DIRECTORY" value="./scripts" />
<option name="PARENT_ENVS" value="true" />
<option name="SCRIPT_NAME" value="delete-pycache.cmd" />
<option name="PARAMETERS" value="" />
<method v="2" />
</configuration>
</component>

View File

@@ -0,0 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="go build np_web_main" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
<module name="Web-NibblePoker" />
<working_directory value="$PROJECT_DIR$" />
<go_parameters value="-ldflags=&quot;-s -w -extldflags '-static'&quot;" />
<kind value="PACKAGE" />
<package value="np_web_main" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/app/main.go" />
<output_directory value="$PROJECT_DIR$/bin" />
<method v="2" />
</configuration>
</component>

11
.run/nodejs-setup.run.xml Normal file
View File

@@ -0,0 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="nodejs-setup" type="BatchConfigurationType" factoryName="Batch">
<module name="Web-NibblePoker" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="WORKING_DIRECTORY" value="./scripts" />
<option name="PARENT_ENVS" value="true" />
<option name="SCRIPT_NAME" value="nodejs-setup.cmd" />
<option name="PARAMETERS" value="" />
<method v="2" />
</configuration>
</component>

View File

@@ -0,0 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="package-for-release" type="BatchConfigurationType" factoryName="Batch">
<module name="Web-NibblePoker" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="WORKING_DIRECTORY" value="./scripts" />
<option name="PARENT_ENVS" value="true" />
<option name="SCRIPT_NAME" value="package-for-release.cmd" />
<option name="PARAMETERS" value="" />
<method v="2" />
</configuration>
</component>

10
app.py
View File

@@ -24,7 +24,7 @@ from website.renderers.lists import render_list_ul
from website.renderers.splide import render_splide
from website.renderers.standalone import get_standalone_common_headers
from website.sidebar import reload_sidebar_entries, get_sidebar_entries
from website.sitemap import reload_sitemap_entries, get_sitemap_entries
from website.sitemap import reload_sitemap_entries, get_sitemap_entries, get_sitemap_xml
try:
from rich import print
@@ -164,11 +164,15 @@ def route_robots_txt():
@app.route('/sitemap.txt')
def route_sitemap():
# FIXME: Add the domain !!!
def route_sitemap_txt():
return Response("\n".join(get_sitemap_entries()), mimetype="")
@app.route('/sitemap.xml')
def route_sitemap_xml():
return Response(get_sitemap_xml(request.headers['Host']), mimetype="application/xml")
@app.route('/', defaults={'lang': None})
@app.route('/en/', defaults={'lang': "en"})
@app.route('/fr/', defaults={'lang': "fr"})

View File

@@ -1,17 +1,63 @@
# Sitemap definition
- "/"
- "/about/"
#- "/articles/"
- "/contact/"
- "/content/"
- "/content/circuitpython-ebyte-e32/"
- "/content/docker-mini-cctv-nvr/"
- "/content/lscom-cli-dotnet/"
- "/links/"
- "/privacy/"
- "/tools/"
- "/tools/iban-generator/"
- "/tools/excel-password-remover/"
- "/tools/uuid-generator/"
- "/tools/vat-calculator/"
# changefreq: "monthly" is implied unless specified
sitemap:
"/":
lastmod: "2025-03-30T00:00:00+01:00"
priority: "1"
"/contact/":
lastmod: "2025-03-01T07:40:00+01:00"
priority: "0.5"
"/content/":
lastmod: "2025-09-13T16:19:00+02:00"
priority: "0.2"
"/content/circuitpython-ebyte-e32/":
lastmod: "2025-03-30T14:52:00+02:00"
priority: "0.5"
"/content/docker-mini-cctv-nvr/":
lastmod: "2025-03-30T14:52:00+02:00"
priority: "0.3"
"/content/lscom-cli-dotnet/":
lastmod: "2025-09-13T16:19:00+02:00"
priority: "0.6"
"/links/":
lastmod: "2025-03-01T07:40:00+01:00"
priority: "0.6"
"/privacy/":
lastmod: "2025-03-30T00:00:00+01:00"
priority: "0.4"
"/tools/":
lastmod: "2025-09-13T16:19:00+02:00"
priority: "0.2"
"/tools/iban-generator/":
lastmod: "2025-08-28T21:23:00+02:00"
priority: "0.6"
"/tools/excel-password-remover/":
lastmod: "2025-09-13T16:19:00+02:00"
priority: "0.9"
"/tools/uuid-generator/":
lastmod: "2025-08-28T21:23:00+02:00"
priority: "0.3"
"/tools/vat-calculator/":
lastmod: "2025-09-18T00:15:00+02:00"
priority: "0.6"
#"/about/":
# lastmod: ""
# priority: ""
#"/articles/":
# lastmod: ""
# priority: ""

View File

@@ -11,7 +11,8 @@
<link rel="alternate icon" href="/favicon.ico">
<meta name="theme-color" content="#6F2F65">
<!--<link rel="dns-prefetch" href="https://cdn.nibblepoker.lu/"/>-->
<link rel="dns-prefetch" href="https://cdn.nibblepoker.lu/"/>
<link rel="dns-prefetch" href="https://files.nibblepoker.lu/"/>
<link rel="preconnect" href="https://cdn.nibblepoker.{{ domain_tld }}/"/>
<link rel="prefetch" href="https://cdn.nibblepoker.{{ domain_tld }}/FontAwesomePro/6.7.2/webfonts/fa-brands-400.woff2" as="font" />
@@ -21,7 +22,6 @@
<link rel="stylesheet" href="https://cdn.nibblepoker.{{ domain_tld }}/FontAwesomePro/6.7.2/css/all.min.css">
<link rel="stylesheet" href="https://cdn.nibblepoker.{{ domain_tld }}/NibblePoker/StandardCSS/nibblepoker.min.css">
<!--<link rel="stylesheet" href="https://cdn.nibblepoker.{{ domain_tld }}/Quantum/Quantum.min.css">-->
<link rel="stylesheet" href="https://cdn.nibblepoker.{{ domain_tld }}/FamFamFam/FlagsExtended/famfamfam-flags.min.css">
<link rel="stylesheet" href="{{ url_for("static", filename="resources/NibblePoker/css/extra.css") }}">

31
update.sh Normal file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
cd "$(dirname "$0")"
EXCLUDE=("release.tar" "docker-compose.yml" "update.sh")
for item in * .*; do
# Skip current and parent directory entries
[[ "$item" == "." || "$item" == ".." ]] && continue
delete=true
for pattern in "${EXCLUDE[@]}"; do
if [[ "$item" == $pattern ]]; then
delete=false
break
fi
done
if [ "$delete" = true ]; then
echo "Deleting '$item'"
rm -rf "$item"
fi
done
tar -xvf release.tar
rm data/tools/ico-maker.yml
rm data/tools/png-analyser.yml
docker-compose up --build --force-recreate -d

View File

@@ -1,28 +1,65 @@
from dataclasses import dataclass
from .l10n.utils import ALLOWED_LANGS
import yaml
__SITEMAP_ENTRIES: list[str] = list()
@dataclass
class SitemapEntry:
lastmod: str
priority: str
changefreq: str = "monthly"
__SITEMAP_ENTRIES: dict[str, SitemapEntry] = dict()
__XML_SITEMAP_CACHE = None
def reload_sitemap_entries(definition_file: str) -> None:
global __SITEMAP_ENTRIES
__SITEMAP_ENTRIES = list()
__SITEMAP_ENTRIES = dict()
with open(definition_file, 'r') as f:
raw_sitemap_entries = yaml.safe_load(f)
raw_sitemap_entries: dict = yaml.safe_load(f)["sitemap"]
for allowed_lang in [""] + ALLOWED_LANGS:
for sitemap_entry in raw_sitemap_entries:
__SITEMAP_ENTRIES.append(
("/" + str(allowed_lang) + "/" + str(sitemap_entry))
.replace("//", "/")
.replace("//", "/")
)
# __SITEMAP_ENTRIES.append(sitemap_entry)
# for allowed_lang in ALLOWED_LANGS:
for sitemap_entry_path in raw_sitemap_entries:
entry = SitemapEntry(**raw_sitemap_entries[sitemap_entry_path])
if not(allowed_lang == ""):
entry.priority = "0.0"
__SITEMAP_ENTRIES[
("/" + str(allowed_lang) + "/" + str(sitemap_entry_path))
.replace("//", "/")
.replace("//", "/")
] = entry
def get_sitemap_entries() -> list[str]:
return __SITEMAP_ENTRIES
return list(__SITEMAP_ENTRIES.keys())
def get_sitemap_xml(domain) -> str:
global __XML_SITEMAP_CACHE
if __XML_SITEMAP_CACHE is None:
__XML_SITEMAP_CACHE = (
"""<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">""" +
"".join([
f"""
<url>
<loc>https://{domain}{k}</loc>
<lastmod>{v.lastmod}</lastmod>
<priority>{v.priority}</priority>
<changefreq>{v.changefreq}</changefreq>
</url>"""
for k, v in __SITEMAP_ENTRIES.items()
]) +
"\n</urlset>").replace(" <priority>0.0</priority>\n ", "")
return __XML_SITEMAP_CACHE