segundo commit
This commit is contained in:
parent
6b8b75863a
commit
d2e79d63a5
13601 changed files with 1117197 additions and 0 deletions
47
build_gallery.sh
Normal file
47
build_gallery.sh
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Carpeta de imágenes y archivo HTML a actualizar
|
||||
IMG_DIR="ARTIVISMO_THS"
|
||||
HTML="index.html"
|
||||
|
||||
# Extensiones soportadas (añade/quita lo que quieras)
|
||||
shopt -s nullglob nocaseglob
|
||||
IMGS=("$IMG_DIR"/*.{jpg,jpeg,png,webp,gif})
|
||||
|
||||
# Construye el HTML de la galería en un buffer
|
||||
TMP="$(mktemp)"
|
||||
{
|
||||
echo '<!-- GALLERY:START (no tocar, se rellena automáticamente) -->'
|
||||
echo '<section id="galeria" class="galeria" aria-label="Galería de imágenes">'
|
||||
for f in "${IMGS[@]}"; do
|
||||
base="${f##*/}" # nombre con extensión
|
||||
title="${base%.*}" # sin extensión
|
||||
title="${title//_/ }"
|
||||
title="${title//-/ }"
|
||||
# mayúscula inicial simple
|
||||
title="$(echo "$title" | awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) } ; print }')"
|
||||
|
||||
cat <<EOF
|
||||
<figure class="item">
|
||||
<img src="$IMG_DIR/$base" alt="$title" loading="lazy">
|
||||
<figcaption>
|
||||
<h3 class="title">$title</h3>
|
||||
</figcaption>
|
||||
</figure>
|
||||
EOF
|
||||
done
|
||||
echo '</section>'
|
||||
echo '<!-- GALLERY:END -->'
|
||||
} > "$TMP"
|
||||
|
||||
# Reemplaza el bloque entre marcadores en index.html
|
||||
awk -v RS= -v ORS="" -v repl="$(sed 's/[&/\]/\\&/g' "$TMP")" '
|
||||
{
|
||||
gsub(/<!-- GALLERY:START[\s\S]*?GALLERY:END -->/, repl);
|
||||
print
|
||||
}
|
||||
' "$HTML" > "$HTML.tmp" && mv "$HTML.tmp" "$HTML"
|
||||
|
||||
rm -f "$TMP"
|
||||
echo "Galería actualizada con ${#IMGS[@]} imágenes en $HTML"
|
||||
Loading…
Add table
Add a link
Reference in a new issue