From 41286a82531a81bb092880a5cc29399fbb6ea465 Mon Sep 17 00:00:00 2001 From: Herwin Bozet Date: Mon, 25 Aug 2025 00:03:01 +0200 Subject: [PATCH] Updated png and bmp related-libs, Updated home page and sidebar Update sidebar.yml, home.yml, and 7 more files... --- data/sidebar.yml | 12 +-- data/strings/fr/home.yml | 2 +- static/resources/Externals/.gitignore | 1 + .../applets/png-analyser/png-analyser.mjs | 17 ++-- .../resources/NibblePoker/libs/bmp-utils.mjs | 57 +++++++++++++ .../resources/NibblePoker/libs/data-utils.mjs | 28 ++++++ templates/applets/png-analyser.jinja | 2 +- templates/base_www.jinja | 46 +++++++--- templates/pages/root.jinja | 85 ++++++++++--------- 9 files changed, 185 insertions(+), 65 deletions(-) create mode 100644 static/resources/Externals/.gitignore create mode 100644 static/resources/NibblePoker/libs/bmp-utils.mjs diff --git a/data/sidebar.yml b/data/sidebar.yml index b840e83..d907588 100644 --- a/data/sidebar.yml +++ b/data/sidebar.yml @@ -48,7 +48,7 @@ abs_href: "/tools" icon: fad fa-toolbox active_id: tools - has_new_until_utc: 1760986472 + has_new_until_utc: 1758726438 - title_key: text.downloads raw_href: "https://files.nibblepoker.lu/" @@ -58,11 +58,11 @@ - -- title_key: text.about - abs_href: "/about" - icon: fad fa-user - active_id: about - has_new_until_utc: 0 +#- title_key: text.about +# abs_href: "/about" +# icon: fad fa-user +# active_id: about +# has_new_until_utc: 0 - title_key: text.contact abs_href: "/contact" diff --git a/data/strings/fr/home.yml b/data/strings/fr/home.yml index ec0c34e..59da1a6 100644 --- a/data/strings/fr/home.yml +++ b/data/strings/fr/home.yml @@ -15,7 +15,7 @@ header.title: Page d'accueil intro.title: Bienvenue sur %0 intro.text.1: Ce site web contient une collection de mes travaux personnels tels que des articles de blog, des logiciels utilitaires ou d'autres formes de médias.
Tout - est accessible gratuitement et sous des licences à l'open source. + est accessible gratuitement et sous des licences open source. intro.text.2: Si vous souhaitez me contacter, vous pouvez le faire via la page de contact lié dans la barre de navigation latérale. diff --git a/static/resources/Externals/.gitignore b/static/resources/Externals/.gitignore new file mode 100644 index 0000000..756b22f --- /dev/null +++ b/static/resources/Externals/.gitignore @@ -0,0 +1 @@ +*.svg diff --git a/static/resources/NibblePoker/applets/png-analyser/png-analyser.mjs b/static/resources/NibblePoker/applets/png-analyser/png-analyser.mjs index 66364cd..5d8a38f 100644 --- a/static/resources/NibblePoker/applets/png-analyser/png-analyser.mjs +++ b/static/resources/NibblePoker/applets/png-analyser/png-analyser.mjs @@ -1,6 +1,7 @@ import {initCore} from "../../js/nibblepoker-core.mjs" import {parsePngFile} from "../../libs/png-utils.mjs"; +import {parseBmpFile} from "../../libs/bmp-utils.mjs"; { initCore(); @@ -16,12 +17,18 @@ import {parsePngFile} from "../../libs/png-utils.mjs"; console.log(files); - parsePngFile(files[0]).then(pngFile => { - console.log(pngFile); + if(files[0].name.endsWith(".png")) { + parsePngFile(files[0]).then(pngFile => { + console.log(pngFile); + console.log(pngFile.getImageHeaderChunk().getWidth()); + console.log(pngFile.getImageHeaderChunk().getHeight()); + }); + } else if(files[0].name.endsWith(".bmp")) { + parseBmpFile(files[0]).then(bmpFile => { + console.log(bmpFile); + }); + } - console.log(pngFile.getImageHeaderChunk().getWidth()); - console.log(pngFile.getImageHeaderChunk().getHeight()); - }); }); }; } diff --git a/static/resources/NibblePoker/libs/bmp-utils.mjs b/static/resources/NibblePoker/libs/bmp-utils.mjs new file mode 100644 index 0000000..16cb629 --- /dev/null +++ b/static/resources/NibblePoker/libs/bmp-utils.mjs @@ -0,0 +1,57 @@ +import {loadFileAsUint8Array} from "./file-utils.mjs"; +import {peekUInt32BE, peekUInt16BE} from "./data-utils.mjs"; + +/*export const test = { + WINDOWS: "BM", + OS2_STRUCT_BITMAP_ARRAY: "BA", + OS2_STRUCT_COLOR_ICON: "CI", + OS2_CONST_COLOR_POINTER: "CP", + OS2_STRUCT_ICON: "IC", + OS2_POINTER: "PT", +}*/ + +export class BmpHeader { + /** @type {Uint8Array} */ + data; + + /** + * @param byteArray {Uint8Array|null} + */ + constructor(byteArray) { + if(byteArray === null || byteArray === undefined) { + this.data = new Uint8Array(14); + } else { + this.data = byteArray; + } + } + + getSignature() { + return peekUInt16BE(this.data, 0); + } + + getFileSize() { + return peekUInt32BE(this.data, 2); + } + + getReserved() { + return peekUInt32BE(this.data, 6); + } + + getDataOffset() { + return peekUInt32BE(this.data, 10); + } +} + +export class CrudeBmpFile { + + constructor(file = null, fileData = null) { + this.originalFile = file; + } + +} + +export function parseBmpFile(file) { + return loadFileAsUint8Array(file).then(byteBuffer => { + return new CrudeBmpFile(file, byteBuffer); + }); +} diff --git a/static/resources/NibblePoker/libs/data-utils.mjs b/static/resources/NibblePoker/libs/data-utils.mjs index 71859cf..9d10704 100644 --- a/static/resources/NibblePoker/libs/data-utils.mjs +++ b/static/resources/NibblePoker/libs/data-utils.mjs @@ -23,6 +23,34 @@ export function areUintArraysEqual(array1, array2) { return true; } +/** + * Peeks a UInt16 from the given data at the given offset in Big-Endian. + * @param data {Uint8Array} - Data to read from. + * @param offset {number} - Offset to read from in the given `data`. + * @return {number} The peeked number. + * @throws RangeError If the given offset is too close or over the end of the data. + */ +export function peekUInt16BE(data, offset = 0) { + if(offset + 2 > data.length) { + throw new RangeError(`Offset is too far into the given data ! (${offset} & ${data.length})`); + } + return new DataView(data.buffer, offset, 2).getUint16(0, false); +} + +/** + * Peeks a UInt16 from the given data at the given offset in Little-Endian. + * @param data {Uint8Array} - Data to read from. + * @param offset {number} - Offset to read from in the given `data`. + * @return {number} The peeked number. + * @throws RangeError If the given offset is too close or over the end of the data. + */ +export function peekUInt16LE(data, offset = 0) { + if(offset + 2 > data.length) { + throw new RangeError(`Offset is too far into the given data ! (${offset} & ${data.length})`); + } + return new DataView(data.buffer, offset, 2).getUint16(0, true); +} + /** * Peeks a UInt32 from the given data at the given offset in Big-Endian. * @param data {Uint8Array} - Data to read from. diff --git a/templates/applets/png-analyser.jinja b/templates/applets/png-analyser.jinja index 78b6606..3a66a2a 100644 --- a/templates/applets/png-analyser.jinja +++ b/templates/applets/png-analyser.jinja @@ -1,3 +1,3 @@ -{{ render_file_input(tool_id + "-test-input", true, ".png", true, true) }} +{{ render_file_input(tool_id + "-test-input", true, ".png, .bmp", true, true) }} diff --git a/templates/base_www.jinja b/templates/base_www.jinja index 1ca7031..3b8c111 100644 --- a/templates/base_www.jinja +++ b/templates/base_www.jinja @@ -17,13 +17,12 @@ - - {% block extra_preloads %}{% endblock %} - + + @@ -53,16 +52,37 @@
- -

{{ l10n("english", "langs", user_lang) }}

-
- -

{{ l10n("french", "langs", user_lang) }}

-
-
- -

{{ l10n("automatic", "langs", user_lang) }}

-
+ + + + + + + + + + + + + + + + +
+ + {{ l10n("english", "langs", user_lang) }} + +
+ + {{ l10n("french", "langs", user_lang) }} + +
+
+
+ + {{ l10n("automatic", "langs", user_lang) }} + +
diff --git a/templates/pages/root.jinja b/templates/pages/root.jinja index 5045b45..f3b132e 100644 --- a/templates/pages/root.jinja +++ b/templates/pages/root.jinja @@ -12,51 +12,58 @@ {% endblock %} {% block main_content %} - {{ render_h1(l10n("intro.title", "home", user_lang, ["NibblePoker." + domain_tld] )) }} +
+ {{ render_h1(l10n("intro.title", "home", user_lang, ["NibblePoker." + domain_tld] )) }} - {{ render_paragraph(l10n("intro.text.1", "home", user_lang)) }} - {{ render_paragraph(l10n("intro.text.2", "home", user_lang)) }} +
+ {{ render_paragraph(l10n("intro.text.1", "home", user_lang)) }} + {{ render_paragraph(l10n("intro.text.2", "home", user_lang)) }} +
+
+ +
+ {{ render_h2(l10n("updates.title", "home", user_lang)) }} +
+

{{ l10n("updates.5.date", "home", user_lang) }}

+ {{ render_list_ul([ + l10n("updates.5.text.1", "home", user_lang), + l10n("updates.5.text.2", "home", user_lang), + l10n("updates.text.privacy", "home", user_lang) + ]) }} - {{ render_h2(l10n("updates.title", "home", user_lang)) }} +

{{ l10n("updates.4.date", "home", user_lang) }}

+ {{ render_list_ul([ + l10n("updates.4.text.1", "home", user_lang), + l10n("updates.4.text.2", "home", user_lang), + l10n("updates.4.text.3", "home", user_lang), + l10n("updates.text.privacy", "home", user_lang) + ]) }} -

{{ l10n("updates.5.date", "home", user_lang) }}

- {{ render_list_ul([ - l10n("updates.5.text.1", "home", user_lang), - l10n("updates.5.text.2", "home", user_lang), - l10n("updates.text.privacy", "home", user_lang) - ]) }} +

{{ l10n("updates.3.date", "home", user_lang) }}

+ {{ render_list_ul([ + l10n("updates.3.text.1", "home", user_lang), + l10n("updates.3.text.2", "home", user_lang), + l10n("updates.3.text.3", "home", user_lang), + l10n("updates.text.privacy", "home", user_lang) + ]) }} -

{{ l10n("updates.4.date", "home", user_lang) }}

- {{ render_list_ul([ - l10n("updates.4.text.1", "home", user_lang), - l10n("updates.4.text.2", "home", user_lang), - l10n("updates.4.text.3", "home", user_lang), - l10n("updates.text.privacy", "home", user_lang) - ]) }} +

{{ l10n("updates.2.date", "home", user_lang) }}

+ {{ render_list_ul([ + l10n("updates.2.text.1", "home", user_lang), + l10n("updates.2.text.2", "home", user_lang), + l10n("updates.2.text.3", "home", user_lang), + l10n("updates.2.text.4", "home", user_lang), + l10n("updates.text.privacy", "home", user_lang) + ]) }} -

{{ l10n("updates.3.date", "home", user_lang) }}

- {{ render_list_ul([ - l10n("updates.3.text.1", "home", user_lang), - l10n("updates.3.text.2", "home", user_lang), - l10n("updates.3.text.3", "home", user_lang), - l10n("updates.text.privacy", "home", user_lang) - ]) }} - -

{{ l10n("updates.2.date", "home", user_lang) }}

- {{ render_list_ul([ - l10n("updates.2.text.1", "home", user_lang), - l10n("updates.2.text.2", "home", user_lang), - l10n("updates.2.text.3", "home", user_lang), - l10n("updates.2.text.4", "home", user_lang), - l10n("updates.text.privacy", "home", user_lang) - ]) }} - -

{{ l10n("updates.1.date", "home", user_lang) }}

- {{ render_list_ul([ - l10n("updates.1.text.1", "home", user_lang), - l10n("updates.text.privacy", "home", user_lang) - ]) }} +

{{ l10n("updates.1.date", "home", user_lang) }}

+ {{ render_list_ul([ + l10n("updates.1.text.1", "home", user_lang), + l10n("updates.text.privacy", "home", user_lang) + ]) }} +
+
{% endblock %}