From c6f6fe1e1315151b4050adfa3a1da459132aa015 Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 3 Jan 2026 23:29:02 +0100 Subject: [PATCH] PDF rendering for page 2 is fixed --- ToDo.md | 5 ++ backend/.env.example | 57 --------------------- backend/.env.production | 28 ----------- backend/pdfrender/template_metadata.go | 5 +- backend/scripts/check_chrome.sh | 69 ++++++++++++++++++++++++++ backend/scripts/test_pdf_gorun.sh | 33 ++++++++++++ backend/startserver.sh | 29 +++++++++++ 7 files changed, 140 insertions(+), 86 deletions(-) delete mode 100644 backend/.env.example delete mode 100644 backend/.env.production create mode 100755 backend/scripts/check_chrome.sh create mode 100644 backend/scripts/test_pdf_gorun.sh create mode 100755 backend/startserver.sh diff --git a/ToDo.md b/ToDo.md index 3e0d2ca..cbbe2b8 100644 --- a/ToDo.md +++ b/ToDo.md @@ -30,6 +30,11 @@ * verbessere Versionserstellung * Waffenfertigkeiten haben keine Bonuseigenschaft. * waffenfertigkeiten müssen in andere Katagorien eingeteilt werden. Nahkampf, Schusswaffen, Verteidigungswaffen etc. +* ersetzen: + if dbURL == "" { + dbURL = "bamort:bG4)efozrc@tcp(192.168.0.5:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local" +* fehlgeschlagene Tests ausbessern + ./backend$ go test ./... -v 2>&1 |grep FAIL ## Refaktor diff --git a/backend/.env.example b/backend/.env.example deleted file mode 100644 index 189b541..0000000 --- a/backend/.env.example +++ /dev/null @@ -1,57 +0,0 @@ -# Bamort Server Konfiguration - -# ====================== -# Server Einstellungen -# ====================== -PORT=8180 -SERVER_PORT=8180 - -# ====================== -# Umgebung -# ====================== -# Optionen: development, production, test -ENVIRONMENT=development -# Alternative: -# GO_ENV=development - -# ====================== -# Logging Konfiguration -# ====================== -# Debug-Modus (true/false oder 1/0) -DEBUG=true - -# Log-Level (DEBUG, INFO, WARN, ERROR) -LOG_LEVEL=DEBUG - -# ====================== -# Datenbank Konfiguration -# ====================== -# Unterstützte Typen: mysql, sqlite -DATABASE_TYPE=mysql -# Beispiel-URLs für verschiedene Datenbank-Typen: -# MySQL: DATABASE_URL=user:password@tcp(localhost:3306)/database?charset=utf8mb4&parseTime=True&loc=Local -# PostgreSQL: DATABASE_URL=postgresql://user:password@localhost:5432/database -# SQLite: DATABASE_URL=./database.db -DATABASE_URL= - -# ====================== -# Beispiel-Konfigurationen -# ====================== - -# Development: -# ENVIRONMENT=development -# DEBUG=true -# LOG_LEVEL=DEBUG -# PORT=8180 - -# Production: -# ENVIRONMENT=production -# DEBUG=false -# LOG_LEVEL=INFO -# PORT=8180 - -# Testing: -# ENVIRONMENT=test -# DEBUG=true -# LOG_LEVEL=WARN -# PORT=8181 diff --git a/backend/.env.production b/backend/.env.production deleted file mode 100644 index 867dc7d..0000000 --- a/backend/.env.production +++ /dev/null @@ -1,28 +0,0 @@ -# Bamort Server Konfiguration - Produktionsumgebung -# Diese Datei sollte für die Produktionsumgebung verwendet werden - -# ====================== -# Server Einstellungen -# ====================== -PORT=8180 - -# ====================== -# Umgebung -# ====================== -ENVIRONMENT=production - -# ====================== -# Logging Konfiguration -# ====================== -# Debug-Modus (deaktiviert für Produktion) -DEBUG=false - -# Log-Level (nur wichtige Nachrichten in Produktion) -LOG_LEVEL=INFO - -# ====================== -# Datenbank Konfiguration -# ====================== -# Unterstützte Typen: mysql, sqlite -DATABASE_TYPE=mysql -# DATABASE_URL=user:password@tcp(prod-host:3306)/bamort_prod?charset=utf8mb4&parseTime=True&loc=Local diff --git a/backend/pdfrender/template_metadata.go b/backend/pdfrender/template_metadata.go index 57cc7f8..1ee87ca 100644 --- a/backend/pdfrender/template_metadata.go +++ b/backend/pdfrender/template_metadata.go @@ -1,6 +1,7 @@ package pdfrender import ( + "bamort/config" "fmt" "os" ) @@ -91,7 +92,9 @@ func LoadTemplateSetFromFiles(templateDir string) (TemplateSet, error) { // Now loads from actual template files instead of hardcoded values func DefaultA4QuerTemplateSet() TemplateSet { // Try to load from files - templateSet, err := LoadTemplateSetFromFiles("backend/templates/Default_A4_Quer") + cfg := config.Cfg + templateDir := cfg.TemplatesDir + "/Default_A4_Quer" + templateSet, err := LoadTemplateSetFromFiles(templateDir) if err != nil { // Fallback to relative path from test directory templateSet, err = LoadTemplateSetFromFiles("../templates/Default_A4_Quer") diff --git a/backend/scripts/check_chrome.sh b/backend/scripts/check_chrome.sh new file mode 100755 index 0000000..6344e69 --- /dev/null +++ b/backend/scripts/check_chrome.sh @@ -0,0 +1,69 @@ +#!/bin/bash +# check_chrome.sh - Verify Chrome/Chromium is available for PDF export + +echo "=== Chrome/Chromium Availability Check ===" +echo "" + +# Check for Chrome in common locations +CHROME_PATHS=( + "/usr/bin/google-chrome" + "/usr/bin/google-chrome-stable" + "/usr/bin/chromium" + "/usr/bin/chromium-browser" + "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" + "/snap/bin/chromium" +) + +FOUND=false + +for path in "${CHROME_PATHS[@]}"; do + if [ -x "$path" ]; then + echo "✓ Found Chrome at: $path" + VERSION=$("$path" --version 2>/dev/null || echo "Unknown") + echo " Version: $VERSION" + FOUND=true + + # Suggest setting CHROME_BIN if not already set + if [ -z "$CHROME_BIN" ]; then + echo " Suggestion: export CHROME_BIN=\"$path\"" + fi + echo "" + fi +done + +# Check PATH +echo "Checking PATH for chrome/chromium..." +if command -v google-chrome &> /dev/null; then + echo "✓ 'google-chrome' found in PATH" + google-chrome --version + FOUND=true +elif command -v chromium-browser &> /dev/null; then + echo "✓ 'chromium-browser' found in PATH" + chromium-browser --version + FOUND=true +elif command -v chromium &> /dev/null; then + echo "✓ 'chromium' found in PATH" + chromium --version + FOUND=true +else + echo "✗ No chrome/chromium found in PATH" +fi + +echo "" +echo "Current CHROME_BIN: ${CHROME_BIN:-not set}" +echo "" + +if [ "$FOUND" = true ]; then + echo "✓ Chrome/Chromium is available - PDF export should work" + exit 0 +else + echo "✗ Chrome/Chromium NOT found - PDF export will FAIL" + echo "" + echo "Please install Chrome or Chromium:" + echo " Debian/Ubuntu: sudo apt-get install chromium-browser" + echo " Alpine: apk add chromium" + echo " macOS: brew install --cask google-chrome" + echo "" + echo "Or set CHROME_BIN to point to your Chrome installation" + exit 1 +fi diff --git a/backend/scripts/test_pdf_gorun.sh b/backend/scripts/test_pdf_gorun.sh new file mode 100644 index 0000000..0385a62 --- /dev/null +++ b/backend/scripts/test_pdf_gorun.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Test PDF export via running server + +echo "Testing PDF export with go run..." +echo "" + +# Start the server in background +cd /data/dev/bamort/backend +/usr/local/go/bin/go run ./cmd/main.go & +SERVER_PID=$! + +echo "Server started with PID: $SERVER_PID" +echo "Waiting for server to start..." +sleep 5 + +# Check if server is running +if ! kill -0 $SERVER_PID 2>/dev/null; then + echo "✗ Server failed to start" + exit 1 +fi + +echo "Server is running, testing PDF export..." + +# Get auth token (you'll need to implement this based on your auth) +# For now, just try to access the endpoint +curl -s "http://localhost:8180/api/pdf/templates" || echo "Server not responding yet..." + +echo "" +echo "Press Ctrl+C to stop the server (PID: $SERVER_PID)" +echo "Then manually test: curl -H 'Authorization: Bearer YOUR_TOKEN' 'http://localhost:8180/api/pdf/export/18?template=Default_A4_Quer'" + +# Wait for user interrupt +wait $SERVER_PID diff --git a/backend/startserver.sh b/backend/startserver.sh new file mode 100755 index 0000000..62323fe --- /dev/null +++ b/backend/startserver.sh @@ -0,0 +1,29 @@ +# Environment variables for Bamort development environment + +# API Configuration +# API_URL=http://localhost:8180 + +# Database Configuration (for development) +DATABASE_TYPE=mysql +DATABASE_URL="bamort:bG4)efozrc@tcp(mariadb-dev:3306)/bamort?charset=utf8mb4&parseTime=True&loc=Local" + +# MariaDB Configuration (development) +MARIADB_ROOT_PASSWORD=root_password_dev +MARIADB_PASSWORD="bG4)efozrc" +MARIADB_DATABASE=bamort +MARIADB_USER=bamort + +# Frontend Configuration +API_URL="http://192.168.0.36:8180" +VITE_API_URL="http://192.168.0.36:8180" +API_PORT=8180 +BASE_URL="http://localhost:5173" +TEMPLATES_DIR=./templates +EXPORT_TEMP_DIR=./export_temp +GIT_COMMIT=d0c177b +LOG_LEVEL=debug +COMPOSE_PROJECT_NAME=bamort +CHROME_BIN="/usr/bin/chromium" + +#./server +/usr/local/go/bin/go run ./cmd/main.go