#!/usr/bin/env bash
# ONE-TIME asset importer — run once from the site root on a machine with internet.
# Downloads the client-owned photographs into assets/img/ with the local names
# the site expects. After this runs, the site has zero external references.
set -u
BASE="https://website.ziplink.in"
DIR="assets/img"
mkdir -p "$DIR"

fetch () { # fetch <localname> <candidate-path> [candidate-path...]
  local out="$DIR/$1"; shift
  [ -s "$out" ] && { echo "skip  $out (exists)"; return; }
  for p in "$@"; do
    if curl -fsSL --connect-timeout 15 "$BASE/$p" -o "$out" 2>/dev/null && [ -s "$out" ]; then
      echo "ok    $out  <=  $p"; return
    fi
  done
  rm -f "$out"; echo "MISS  $out"
}

fetch logo-mm.png            assets/img/logo-mm.png
fetch logo-mm-org.png        assets/img/logo-mm-org.png
fetch mohol-banner-1.png     assets/img/mohol-banner-1.png
fetch mohol-banner-2.jpg     assets/img/mohol-banner-2.jpg assets/img/mohol-banner-2.png
fetch vector-mohol-1.png     assets/img/vector-mohol-1.png
fetch activity-satkar.jpg    assets/img/EBSM-Mohol-2.jpg
fetch activity-sanskrutik.png assets/img/sanskrutik-mohotsav.png
fetch activity-krida.jpeg    assets/img/krida-mohotsav.jpeg
fetch event-sankalp.jpg      assets/img/sankalpa-sabha.jpg
fetch event-sahakar.jpeg     assets/img/sahkar-samruddhi.jpeg
fetch event-arogya.jpeg      assets/img/blood-donation.jpeg
for n in 2 3 4 5 9; do fetch gallery-$n.jpg uploads/gallery/$n.jpg; done
fetch feedback-1.jpg         uploads/feedback/1.jpeg
fetch feedback-2.png         uploads/feedback/2.png
fetch feedback-3.jpg         uploads/feedback/3.jpeg
for n in 1 3 5 6 9; do fetch gal-$n.jpg assets/img/gal-$n.jpg assets/img/gal-$n.jpeg assets/img/gal-$n.png; done
for n in 1 2 3; do fetch socialwork-$n.jpg assets/img/socialwork$n.jpg assets/img/socialwork-$n.jpg assets/img/socialwork$n.jpeg; done

echo; echo "Done. Missing files (if any) keep their bundled placeholder automatically."
