#!/bin/bash # Build script for Kantine Bookmarklet # Creates a self-contained bookmarklet URL and standalone HTML file set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" DIST_DIR="$SCRIPT_DIR/dist" CSS_FILE="$SCRIPT_DIR/style.css" JS_FILE="$SCRIPT_DIR/kantine.js" # === VERSION === if [ -f "$SCRIPT_DIR/version.txt" ]; then VERSION=$(cat "$SCRIPT_DIR/version.txt" | tr -d '\n') else echo "ERROR: version.txt not found" exit 1 fi mkdir -p "$DIST_DIR" echo "=== Kantine Bookmarklet Builder ($VERSION) ===" # Check files exist if [ ! -f "$CSS_FILE" ]; then echo "ERROR: $CSS_FILE not found"; exit 1; fi if [ ! -f "$JS_FILE" ]; then echo "ERROR: $JS_FILE not found"; exit 1; fi CSS_CONTENT=$(cat "$CSS_FILE") # Inject version into JS JS_CONTENT=$(cat "$JS_FILE" | sed "s|{{VERSION}}|$VERSION|g") # === 1. Build standalone HTML (for local testing/dev) === cat > "$DIST_DIR/kantine-standalone.html" << HTMLEOF Kantine Weekly Menu (Standalone) HTMLEOF echo "✅ Standalone HTML: $DIST_DIR/kantine-standalone.html" # === 2. Build bookmarklet (JavaScript URL) === # The bookmarklet injects CSS + JS into the current page # Escape CSS for embedding in JS string CSS_ESCAPED=$(echo "$CSS_CONTENT" | sed "s/'/\\\\'/g" | tr '\n' ' ' | sed 's/ */ /g') # Build bookmarklet payload cat > "$DIST_DIR/bookmarklet-payload.js" << PAYLOADEOF (function(){ if(window.__KANTINE_LOADED){alert('Kantine Wrapper already loaded!');return;} var s=document.createElement('style'); s.textContent='${CSS_ESCAPED}'; document.head.appendChild(s); var sc=document.createElement('script'); sc.textContent=$(echo "$JS_CONTENT" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))" 2>/dev/null || echo "$JS_CONTENT" | sed 's/\\/\\\\/g' | sed "s/'/\\\\'/g" | sed 's/"/\\\\"/g' | tr '\n' ' ' | sed 's/^/"/' | sed 's/$/"/'); document.head.appendChild(sc); })(); PAYLOADEOF # URL-encode for bookmark BOOKMARKLET_RAW=$(cat "$DIST_DIR/bookmarklet-payload.js" | tr '\n' ' ' | sed 's/ */ /g') echo "javascript:${BOOKMARKLET_RAW}" > "$DIST_DIR/bookmarklet.txt" echo "✅ Bookmarklet URL: $DIST_DIR/bookmarklet.txt" # === 3. Create an easy-to-use HTML installer page === cat > "$DIST_DIR/install.html" << INSTALLEOF Kantine Wrapper Installer ($VERSION)

🍽️ Kantine Wrapper $VERSION

"Mahlzeit! Jetzt bessa einfach."

👇 Diesen Button in die Lesezeichen-Leiste ziehen:

⏳ Wird generiert...

So funktioniert's

  1. Ziehe den Button oben in deine Lesezeichen-Leiste (Drag & Drop)
  2. Navigiere zu web.bessa.app/knapp-kantine
  3. Klicke auf das Lesezeichen Kantine $VERSION

✨ Features

⚠️ Haftungsausschluss:
Die Verwendung dieses Bookmarklets erfolgt auf eigene Verantwortung. Der Entwickler übernimmt keine Haftung für Schäden, Datenverlust oder ungewollte Bestellungen, die durch die Nutzung dieser Software entstehen.
Changelog & Version History

Powered by Kaufi-Kitchen 👨‍🍳

INSTALLEOF echo "✅ Installer page: $DIST_DIR/install.html" echo "" echo "=== Build Complete ===" echo "Files in $DIST_DIR:" ls -la "$DIST_DIR/" # === 4. Run build-time tests === echo "" echo "=== Running Logic Tests ===" node "$SCRIPT_DIR/test_logic.js" LOGIC_EXIT=$? if [ $LOGIC_EXIT -ne 0 ]; then echo "❌ Logic tests FAILED! See above for details." exit 1 fi echo "=== Running Build Tests ===" python3 "$SCRIPT_DIR/test_build.py" TEST_EXIT=$? if [ $TEST_EXIT -ne 0 ]; then echo "❌ Build tests FAILED! See above for details." exit 1 fi echo "✅ All build tests passed." # === 5. Auto-tag version === echo "" echo "=== Tagging $VERSION ===" if git rev-parse "$VERSION" >/dev/null 2>&1; then git tag -f "$VERSION" echo "🔄 Tag $VERSION moved to current commit." echo " ⚠️ Force-push required: git push origin --force tag $VERSION" else git tag "$VERSION" echo "✅ Created tag: $VERSION" fi