fffleche/genlinks.sh

28 lines
862 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
temp="$(mktemp)"
echo -n "" > "${temp}"
# Pour chaque fichier sans extention
while read f ; do
# On crée la ligne de tableau HTML
echo -n "<tr><td>${f}</td><td>" >> "${temp}"
# On crée un lien de téléchargement par type existant
for ext in pdf epub ods ; do
fullname="grilles/${f}.${ext}"
[[ -e "$fullname" ]] && echo -n "<a href=\"${fullname}\">${ext}</a> " >> "${temp}"
done
# Fin de la ligne de tableau HTML
echo "</td></tr>" >> "${temp}"
done < <(ls grilles/ | sed 's#\.[^.]*$##' | sort -u)
# On insert ce quon a calculé dans la page html
awk 'BEGIN { while ((getline < "'"${temp}"'") > 0) lines[++i] = $0 }
/<!-- AUTOGENERATED -->/{ print; print lines[1]; for (j=2; j<=i; j++) print lines[j]; next }
/<!-- END AUTOGENERATED -->/ { print; next }
{ print }' index.template.html > index.html
rm "${temp}"