From 3072086424210789c79e88af2fa7040322421cf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Jakse?= Date: Sat, 3 May 2025 11:04:09 +0200 Subject: [PATCH] Add a way to advertise a source code location --- l10n/po/fr/trivabble.po | 3 +++ l10n/pot/trivabble.pot | 3 +++ public/config.js.sample | 3 +++ public/index.html | 5 ++++- public/trivabble.css | 4 +++- public/trivabble.js | 21 +++++++++++++++++++++ 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/l10n/po/fr/trivabble.po b/l10n/po/fr/trivabble.po index acf756e..8e2cd30 100644 --- a/l10n/po/fr/trivabble.po +++ b/l10n/po/fr/trivabble.po @@ -1,3 +1,6 @@ +msgid "Info & source code at {0}" +msgstr "Information et code source : {0}" + msgid "Your game is not over. Are you sure you want to leave now?" msgstr "Votre partie n'est pas terminée. Êtes-vous sûr·e de vouloir la quitter ?" diff --git a/l10n/pot/trivabble.pot b/l10n/pot/trivabble.pot index 447f3de..f58c379 100644 --- a/l10n/pot/trivabble.pot +++ b/l10n/pot/trivabble.pot @@ -1,5 +1,8 @@ #TranslationFunction trivabble +msgid "Info & source code at {0}" +msgstr "" + msgid "Your game is not over. Are you sure you want to leave now?" msgstr "" diff --git a/public/config.js.sample b/public/config.js.sample index c95d261..e06bc0d 100644 --- a/public/config.js.sample +++ b/public/config.js.sample @@ -2,6 +2,9 @@ // configuration of the client. window.TrivabbleConf = { + // Info & code source (if you edited the source code, the AGPLv3 license requires you to share your version at this address) + //SOURCE_URL: 'https://trivabble.org', + // The amount of time to wait after a connection failure //POLLING_DELAY: 2000, diff --git a/public/index.html b/public/index.html index 0659b75..e3baaad 100644 --- a/public/index.html +++ b/public/index.html @@ -170,7 +170,10 @@ - + diff --git a/public/trivabble.css b/public/trivabble.css index 1003296..c88a23b 100644 --- a/public/trivabble.css +++ b/public/trivabble.css @@ -654,9 +654,11 @@ td.blink { content: "⚙️ " } -#info-spell-checking { +#info-spell-checking, #source-code-info p { font-size:small; color:gray; + margin: 0; + padding: 0; } #info-spell-checking a { diff --git a/public/trivabble.js b/public/trivabble.js index ac455f9..3debe49 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -48,6 +48,7 @@ return setting[Math.floor(setting.length / 2)]; } + setConf("SOURCE_URL", "https://trivabble.org"); setConf("POLLING_DELAY", 2000); setConf("ENABLE_WEBSOCKETS", true); setConf("ENABLE_EVENT_SOURCE", true); @@ -2481,6 +2482,25 @@ trivabble.run(); }; + function addSourceCodeInfo() { + const info = document.getElementById("source-code-info"); + if (info) { + const sourceLink = document.createElement("a"); + const source = getSetting("SOURCE_URL"); + sourceLink.href = source; + sourceLink.textContent = source; + sourceLink.target = "_blank"; + const translated = _("Info & source code at {0}").split("\{0\}"); + const pinfo = document.createElement("p"); + pinfo.textContent = translated[0]; + pinfo.appendChild(sourceLink); + if (translated[1]) { + pinfo.appendChild(document.createTextNode(translated[1])); + } + info.appendChild(pinfo); + } + } + function setAvailableBoardLangs(availableBoardLangs) { if (!boardLangSelect) { const boardLangSelection = document.getElementById("board-lang-selection"); @@ -2698,6 +2718,7 @@ } trivabble.run = function () { + addSourceCodeInfo(); initGlobals(); initEvents(); initChat(); -- 2.30.2