From: PhiTux Date: Sun, 5 Oct 2025 10:48:09 +0000 (+0200) Subject: added build-script & changed version loading in backend X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=bf79e9bd245bd9bde913b6f8b779358cb4a7f60c;p=DailyTxT.git added build-script & changed version loading in backend --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1761c01 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.envrc \ No newline at end of file diff --git a/backend/main.go b/backend/main.go index 7ad6507..6b087cf 100644 --- a/backend/main.go +++ b/backend/main.go @@ -6,6 +6,7 @@ import ( "net/http" "os" "os/signal" + "strings" "syscall" "time" @@ -14,8 +15,8 @@ import ( "github.com/phitux/dailytxt/backend/utils" ) -// Application version - UPDATE THIS FOR NEW RELEASES -const AppVersion = "2.0.0-testing.1" +// Application version - loaded from local 'version' file at startup +var AppVersion string // longTimeoutEndpoints defines endpoints that need extended/none timeouts // Paths are checked against the request URL path as seen by the top-level handler. @@ -46,6 +47,16 @@ func main() { logger := log.New(os.Stdout, "dailytxt: ", log.LstdFlags|log.Lmicroseconds|log.Lshortfile) logger.Println("Server starting...") + // Read application version as the very first step + data, err := os.ReadFile("version") + if err != nil { + log.Fatalf("Failed to read 'version' file: %v", err) + } + AppVersion = strings.TrimSpace(string(data)) + if AppVersion == "" { + log.Fatalf("'version' file is empty") + } + // Set application version utils.SetVersion(AppVersion) logger.Printf("DailyTxT version: %s", AppVersion) diff --git a/backend/version b/backend/version new file mode 100644 index 0000000..03a0b7f --- /dev/null +++ b/backend/version @@ -0,0 +1 @@ +2.0.0-testing.1 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..8b7b44d --- /dev/null +++ b/build.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Build script: pulls translations from Tolgee, then builds the Docker image. +# Requirements: +# - Environment variable TOLGEE_API_KEY must be set +# - tolgee CLI available +# - Docker installed +# +# Usage: +# TOLGEE_API_KEY=... ./build.sh [IMAGE_TAG] +# +# Example: +# export TOLGEE_API_KEY=xxxxx +# ./build.sh phitux/dailytxt:2.x.x-testing.1 + +if [[ $# -lt 1 ]]; then + echo "Usage: ./build.sh " + exit 1 +fi +IMAGE_TAG="$1" + +if [[ -z "${TOLGEE_API_KEY:-}" ]]; then + echo "Error: TOLGEE_API_KEY is not set." + echo "Please export your Tolgee API key, e.g.:" + echo " export TOLGEE_API_KEY=xxxxxxxxxxxxxxxx" + exit 1 +fi + +echo "[1/3] Writing IMAGE_TAG (=version) into backend/version ..." +echo "$IMAGE_TAG" > ./backend/version + +echo "[2/3] Pulling translations from Tolgee into frontend/src/i18n ..." +tolgee pull --path ./frontend/src/i18n --api-key $TOLGEE_API_KEY + +echo "[3/3] Building Docker image: $IMAGE_TAG" +docker build -t phitux/dailytxt:$IMAGE_TAG . + +echo "Done. Image built: $IMAGE_TAG" diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.json index 3f24c42..5d8fb64 100644 --- a/frontend/src/i18n/de.json +++ b/frontend/src/i18n/de.json @@ -285,6 +285,7 @@ "images_loading_per_device": "Für jedes Gerät einzeln festlegen, ob die Bilder automatisch geladen werden sollen", "images_loading_this_device": "Bilder auf diesem Gerät automatisch laden", "images_title": "Bilder automatisch laden", + "installation_help": "Du kannst DailyTxT auch wie eine App installieren. Das geht über die Einstellungen des Browsers, wird aber nicht von jedem Browser unterstützt. Aktuell wurde keine Installation erkannt.
\n", "language": "Sprache", "language_auto_detect": "Sprache anhand des Browsers ermitteln. Aktuell:", "language_not_available": "Die Sprache {browserLanguage} ist nicht verfügbar. Es wird die Standardsprache {defaultLanguage} verwendet.", @@ -403,6 +404,12 @@ "toast": { "password": { "available_backup_codes": "{count, plural, one {Noch {count} Backup-Code verfügbar!} other {Noch {count} Backup-Codes verfügbar!}}" + }, + "pwa": { + "install_button": "Installieren", + "install_description": "Installiere DailyTxT, damit es sich verhält wie eine normale App.", + "reload_button": "Neu laden", + "update_available": "Eine neue Version ist verfügbar." } }, "weekdays": { diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 33b836c..a54a90d 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -285,6 +285,7 @@ "images_loading_per_device": "Decide for each device whether images should be loaded automatically", "images_loading_this_device": "Automatically load images on this device", "images_title": "Automatically load images", + "installation_help": "You can also install DailyTxT like an app. This is done through the browser settings, but it is not supported by every browser. Currently, no installation has been detected.
\n", "language": "Language", "language_auto_detect": "Determine language based on the browser. Currently:", "language_not_available": "The language {browserLanguage} is not available. The default language {defaultLanguage} is used.", @@ -403,6 +404,12 @@ "toast": { "password": { "available_backup_codes": "{count, plural, one {Still {count} backup code available!} other {Still {count} backup codes available!}}" + }, + "pwa": { + "install_button": "Install", + "install_description": "Install DailyTxT for a better app-like experience.", + "reload_button": "Reload", + "update_available": "A new version is available." } }, "weekdays": { diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.json index 6cd7e02..2c7132c 100644 --- a/frontend/src/i18n/fr.json +++ b/frontend/src/i18n/fr.json @@ -132,6 +132,7 @@ "delete": "Supprimer", "delete_account": "Supprimer le compte utilisateur", "delete_account.delete_button": "Supprimer le compte utilisateur", + "installation_help": "Tu peux aussi installer DailyTxT comme une application. Cela se fait via les paramètres du navigateur, mais tous les navigateurs ne le prennent pas en charge. Aucune installation n'a été détectée actuellement.
\n", "language": { "reload_info": "Certaines modifications ne seront visibles qu'après rechargement de la page." }, @@ -163,5 +164,13 @@ "error_saving": "Erreur lors de la création du tag!", "error_saving_exists": "\"Le nom du tag existe déjà\"" } + }, + "toast": { + "pwa": { + "install_button": "Installer", + "install_description": "Installe DailyTxT pour qu'il se comporte comme une application normale.", + "reload_button": "Recharger", + "update_available": "Une nouvelle version est disponible." + } } } \ No newline at end of file diff --git a/frontend/src/routes/(authed)/+layout.svelte b/frontend/src/routes/(authed)/+layout.svelte index 174e038..a15bb17 100644 --- a/frontend/src/routes/(authed)/+layout.svelte +++ b/frontend/src/routes/(authed)/+layout.svelte @@ -1112,6 +1112,17 @@ console.error('Error fetching version info:', error); }); } + + let showInstallationHelp = $state(false); + $effect(() => { + if (window.matchMedia('(display-mode: standalone)').matches) { + showInstallationHelp = false; + console.log("We're installed"); + } else { + showInstallationHelp = true; + console.log("We're not installed"); + } + });
@@ -1153,7 +1164,7 @@ DailyTxT
- 1 + 2
@@ -1363,6 +1374,9 @@ {/each}
+ {#if showInstallationHelp} +
{@html $t('settings.installation_help')}
+ {/if}

🎨 {$t('settings.appearance')}