translating comments to english
This commit is contained in:
parent
4d4d1e42c0
commit
b3c019c6c8
2 changed files with 18 additions and 18 deletions
34
genlog.sh
34
genlog.sh
|
|
@ -1,63 +1,63 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# quelques trucs intelligents
|
# some useful things
|
||||||
# https://sharats.me/posts/shell-script-best-practices/
|
# https://sharats.me/posts/shell-script-best-practices/
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
|
||||||
# on créé un répertoire de taff temporaire pour foutre nos fichiers en cours de traitement dedans
|
# creating a temporary directory for our working stuff
|
||||||
tempdir="$(mktemp -d)"
|
tempdir="$(mktemp -d)"
|
||||||
|
|
||||||
|
|
||||||
# on vérifie s'il y a un argument passé à notre script
|
# checking args
|
||||||
if [[ -n "$1" ]]
|
if [[ -n "$1" ]]
|
||||||
then
|
then
|
||||||
# si oui, on l'utilise comme path ou aller taffer
|
# if there's an arg, using it as a working path
|
||||||
source_path="$1"
|
source_path="$1"
|
||||||
else
|
else
|
||||||
# sinon on utilise le dossier "content" à la racine de notre script
|
# if not, using the 'content' directory as working path
|
||||||
source_path=content
|
source_path=content
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# on génère la date et on la fout dans le footer
|
# generating the current date for the footer
|
||||||
date="$(date)"
|
date="$(date)"
|
||||||
sed "s/GEN_DATE/$date/" html/footer.html > "$tempdir/footer.html"
|
sed "s/GEN_DATE/$date/" html/footer.html > "$tempdir/footer.html"
|
||||||
|
|
||||||
|
|
||||||
# on cherche récursivement tous les fichiers ".gmi" dans le dossier de taff
|
# finding recursively all ".gmi" files on the working path
|
||||||
find "$source_path" -wholename "*.gmi" -type f | while read -r gmi_file
|
find "$source_path" -wholename "*.gmi" -type f | while read -r gmi_file
|
||||||
do
|
do
|
||||||
|
|
||||||
# récupérer la 1ère ligne du fichier .gmi et remplacer "# " par ""
|
# deleting the '#' of the first line and save it as title
|
||||||
title="$(sed -n '1{s/# //p}' "$gmi_file") $2"
|
title="$(sed -n '1{s/# //p}' "$gmi_file") $2"
|
||||||
|
|
||||||
# dans le header.html, remplacer "<\-- TITLE -->" par le titre récupéré
|
# in the header.html, replacing the "<\-- TITLE -->" by the previously
|
||||||
# puis enregistrer le fichier ainsi modifié dans "temp/header.html"
|
# saved title, and save the modified file in our temporary directory
|
||||||
sed "s#<\!-- TITLE -->#$title#" html/header.html > "$tempdir/header.html"
|
sed "s#<\!-- TITLE -->#$title#" html/header.html > "$tempdir/header.html"
|
||||||
|
|
||||||
# conversion du .gmi en .html
|
# convertig .gmi files in .html
|
||||||
/usr/local/bin/gmnitohtml < "$gmi_file" > "$tempdir/body.html"
|
/usr/local/bin/gmnitohtml < "$gmi_file" > "$tempdir/body.html"
|
||||||
|
|
||||||
# on récupère juste le path du dossier qui contient le .gmi
|
# retrieving of the path of the current .gmi file
|
||||||
file_path="$(dirname "$gmi_file")"
|
file_path="$(dirname "$gmi_file")"
|
||||||
# on récupère juste le nom du fichier .gmi sans son extenstion ".gmi"
|
# retrieving of the filename of the current .gmi file, without its extension
|
||||||
file_name="$(basename "$gmi_file" .gmi)"
|
file_name="$(basename "$gmi_file" .gmi)"
|
||||||
|
|
||||||
# on assemble les 3 morceaux et on l'écrit dans le dossier du .gmi qui est traité
|
# assembling the header, the converted page and the footer and saving it in the working path
|
||||||
cat "$tempdir/header.html" "$tempdir/body.html" "$tempdir/footer.html" > "$file_path/$file_name.html"
|
cat "$tempdir/header.html" "$tempdir/body.html" "$tempdir/footer.html" > "$file_path/$file_name.html"
|
||||||
|
|
||||||
# je crois c'est bon
|
# i think it's all good
|
||||||
echo "OK: $title"
|
echo "OK: $title"
|
||||||
echo " ⤷ $file_path/$file_name.html"
|
echo " ⤷ $file_path/$file_name.html"
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# on vire le dossier de taff devenu inutile
|
# removing the temporary directory, it's useless now
|
||||||
rm -r "$tempdir"
|
rm -r "$tempdir"
|
||||||
|
|
||||||
|
|
||||||
# cette fois c'est vraiment fini
|
# this time it's really the end
|
||||||
echo "All done."
|
echo "All done."
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<!-- Start footer.html -->
|
<!-- Start footer.html -->
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<p>Cette page est consultable via <a href="//gemini.circumlunar.space/">Gemini</a> à la même adresse.</p>
|
<p>Cette page est consultable via <a href="//gemini.circumlunar.space/">Gemini</a> à la même adresse.</p>
|
||||||
<!-- Généré le GEN_DATE avec Genlog https://codeberg.org/OniriCorpe/genlog -->
|
<!-- Generated on GEN_DATE with Genlog https://codeberg.org/OniriCorpe/genlog -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue