Admin: enable download, surface Gemini errors in toast, AJAX file delete; style: make toast clickable

This commit is contained in:
hbrain 2026-05-29 23:21:56 +02:00
parent 3de0d498ce
commit 420ce99046
3 changed files with 99 additions and 24 deletions

View file

@ -195,24 +195,10 @@ if [ -z "$TEXT" ]; then
exit 1
fi
# Save raw Gemini JSON for reference in parent in-dir with YYYYMMDD-name.json
# Save raw Gemini JSON for reference using the subdirectory name as filename
OUT_PARENT="$(dirname "$IN_DIR")"
JOBNAME="$(basename "$IN_DIR")"
if [[ "$JOBNAME" =~ ^([0-9]{8})[_-](.+)$ ]]; then
DATE_PART="${BASH_REMATCH[1]}"
NAME_PART="${BASH_REMATCH[2]}"
else
firstfile="$(find "$IN_DIR" -maxdepth 1 -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' -o -iname '*.gif' -o -iname '*.mp4' -o -iname '*.mov' -o -iname '*.m4v' -o -iname '*.webm' -o -iname '*.mkv' \) -printf '%p\n' | sort | head -n1)"
if [ -n "$firstfile" ]; then
DATE_PART="$(date -r "$firstfile" +%Y%m%d 2>/dev/null || date +%Y%m%d)"
else
DATE_PART="$(date +%Y%m%d)"
fi
NAME_PART="$JOBNAME"
fi
# sanitize
SAFE_NAME="$(echo "$NAME_PART" | tr ' /' '__' | tr -c '[:alnum:]_.-' '_')"
OUT_JSON="$OUT_PARENT/${DATE_PART}-${SAFE_NAME}.json"
OUT_JSON="$OUT_PARENT/${JOBNAME}.json"
echo "$TEXT" | jq . > "$OUT_JSON"
chown www-data:www-data "$OUT_JSON" 2>/dev/null || true
chmod 664 "$OUT_JSON" 2>/dev/null || true