added build-script & changed version loading in backend
authorPhiTux <redacted>
Sun, 5 Oct 2025 10:48:09 +0000 (12:48 +0200)
committerPhiTux <redacted>
Sun, 5 Oct 2025 10:48:09 +0000 (12:48 +0200)
.gitignore [new file with mode: 0644]
backend/main.go
backend/version [new file with mode: 0644]
build.sh [new file with mode: 0755]
frontend/src/i18n/de.json
frontend/src/i18n/en.json
frontend/src/i18n/fr.json
frontend/src/routes/(authed)/+layout.svelte

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..1761c01
--- /dev/null
@@ -0,0 +1 @@
+.envrc
\ No newline at end of file
index 7ad6507c9ae8818591185ea10927a7b5509aa830..6b087cf0b194db5bad1fe62f302bd70209094152 100644 (file)
@@ -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 (file)
index 0000000..03a0b7f
--- /dev/null
@@ -0,0 +1 @@
+2.0.0-testing.1
diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
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 <IMAGE_TAG>"
+       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"
index 3f24c42c64a45583a3afa76b3ddc72bcb46dc17d..5d8fb6467afddea89ca26b967f28fae5fb15f064 100644 (file)
     "images_loading_per_device": "Für jedes Gerät einzeln festlegen, ob die Bilder automatisch geladen werden sollen",
     "images_loading_this_device": "Bilder auf <b>diesem Gerät</b> 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.<br/> \n<ul>\n<li>Android: \"Zum Startbildschirm hinzufügen\"</li>\n<li>Apple: \"Teilen\" -> \"Zum Home-Bildschirm\"</li>\n</ul>",
     "language": "Sprache",
     "language_auto_detect": "Sprache anhand des Browsers ermitteln. Aktuell:",
     "language_not_available": "Die Sprache <code>{browserLanguage}</code> ist nicht verfügbar. Es wird die Standardsprache <code>{defaultLanguage}</code> verwendet.",
   "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": {
index 33b836c2ece904525e4e852f53d8be058b2c6872..a54a90dcbdee615986d76f6d5fc46cb6e707ed42 100644 (file)
     "images_loading_per_device": "Decide for each device whether images should be loaded automatically",
     "images_loading_this_device": "Automatically load images on <b>this device</b>",
     "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.<br/>\n<ul>\n<li>Android: \"Add to Home screen\"</li>\n<li>Apple: \"Share\" -> \"Add to Home Screen\"</li>\n</ul>",
     "language": "Language",
     "language_auto_detect": "Determine language based on the browser. Currently:",
     "language_not_available": "The language <code>{browserLanguage}</code> is not available. The default language <code>{defaultLanguage}</code> is used.",
   "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": {
index 6cd7e025c5f4b6d528bec1fc36cb84857b1fb21a..2c7132c05bb3bef765a29e4533d6366a0e0552ba 100644 (file)
     "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.<br/> \n<ul>\n<li>Android : \"Ajouter à l'écran d'accueil\"</li>\n<li>Apple : \"Partager\" -> \"Sur l'écran d'accueil\"</li>\n</ul>",
     "language": {
       "reload_info": "Certaines modifications ne seront visibles qu'après rechargement de la page."
     },
       "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
index 174e0386f68ac5f15cfefcea4b72b0d3973652bf..a15bb17f52b900e425ca0d79e9ae2db5facb7efc 100644 (file)
                                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");
+               }
+       });
 </script>
 
 <div class="d-flex flex-column h-100">
                                        <img src={dailytxt} alt="" height="38px" />
                                        <span class="dailytxt ms-2 user-select-none">DailyTxT</span>
                                </div>
-                               1
+                               2
                        </div>
 
                        <div class="col-lg-4 col-sm-5 col pe-0 d-flex flex-row justify-content-end">
                                                                                {/each}
                                                                        </select>
                                                                </div>
+                                                               {#if showInstallationHelp}
+                                                                       <div class="alert alert-info">{@html $t('settings.installation_help')}</div>
+                                                               {/if}
                                                                <div id="appearance">
                                                                        <h3 class="text-primary">🎨 {$t('settings.appearance')}</h3>
                                                                        <div id="lightdark">
git clone https://git.99rst.org/PROJECT