2024-11-02 18:30:04 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
# conversion des pages d'articles depuis le dossier source en orgmode
|
2024-11-03 11:06:34 +01:00
|
|
|
|
|
|
|
|
|
# liste des dossiers à convertir
|
2024-11-04 14:14:28 +01:00
|
|
|
|
# blogs_folders=("dragonfeu_blog" "tykayn_blog" "cipherbliss_blog" "qzine_blog" "cil_gometz")
|
2024-11-05 00:35:49 +01:00
|
|
|
|
blogs_folders=()
|
2024-11-04 10:48:39 +01:00
|
|
|
|
# blogs_folders=("tykayn_blog" "qzine_blog" "dragonfeu_blog")
|
2024-11-04 09:35:31 +01:00
|
|
|
|
# blogs_folders=("cil_gometz")
|
2024-11-04 11:52:45 +01:00
|
|
|
|
# blogs_folders=("qzine_blog")
|
2024-11-04 00:13:58 +01:00
|
|
|
|
# blogs_folders=("cipherbliss_blog")
|
2024-11-03 11:06:34 +01:00
|
|
|
|
source_file_extension="org"
|
|
|
|
|
|
2024-11-04 14:14:28 +01:00
|
|
|
|
|
|
|
|
|
# Boucle à travers tous les arguments passés en entrée
|
|
|
|
|
for arg in "$@"
|
|
|
|
|
do
|
|
|
|
|
# Si l'argument est connu, ajouter le nom de blog correspondant à la liste
|
|
|
|
|
blogs_folders+=("$arg")
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Afficher la liste des noms de blogs
|
|
|
|
|
echo "La liste des noms de blogs est :"
|
|
|
|
|
for blog in "${blogs_folders[@]}"
|
|
|
|
|
do
|
|
|
|
|
echo "- $blog"
|
2024-11-05 00:35:49 +01:00
|
|
|
|
done
|
2024-11-04 14:14:28 +01:00
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
convert_sources() {
|
2024-11-05 00:35:49 +01:00
|
|
|
|
# convertir les fichiers orgmode vers gemini et html dans le dossier source/nom_du_blog/ racine, lang_fr et lang_en
|
2024-11-03 12:32:08 +01:00
|
|
|
|
source_file_extension="org"
|
|
|
|
|
|
|
|
|
|
templates_path=$1
|
|
|
|
|
|
|
|
|
|
mkdir -p converted
|
2024-11-03 11:18:48 +01:00
|
|
|
|
|
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
|
for i in *.${source_file_extension} ; do
|
|
|
|
|
echo "$i"
|
|
|
|
|
# Transformer en html
|
2024-11-05 00:35:49 +01:00
|
|
|
|
# echo "to HTML:"
|
|
|
|
|
# pwd
|
2024-11-05 11:17:52 +01:00
|
|
|
|
# TODO assembler la page de footer avec le fichier en entrée
|
|
|
|
|
temp_page="temp_page.$source_file_extension"
|
|
|
|
|
echo ''> $temp_page
|
|
|
|
|
|
|
|
|
|
cat "templates/header_page.$source_file_extension" >> $temp_page
|
|
|
|
|
cat "${i}" >> $temp_page
|
|
|
|
|
cat "templates/footer_page.$source_file_extension" >> $temp_page
|
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
|
pandoc -f "${source_file_extension}" -t html -s "${i}" -o "converted/${i%.${source_file_extension}}.html" --metadata title="$website_name"
|
|
|
|
|
# Transformer en gmi
|
2024-11-05 01:14:45 +01:00
|
|
|
|
# echo "to GMI:"
|
|
|
|
|
# pwd
|
|
|
|
|
# ls -l $templates_path/../../templates/pandoc
|
2024-11-05 00:35:49 +01:00
|
|
|
|
pandoc --template $templates_path/../../templates/pandoc/template_gemini.lua -f "${source_file_extension}" -t $templates_path/../../templates/pandoc/gmi.lua -s "${i}" -o "converted/${i%.${source_file_extension}}.gmi"
|
2024-11-03 12:32:08 +01:00
|
|
|
|
# ajout des footers à chaque article
|
|
|
|
|
# cat '../../templates/website_pages/footer-articles.md.gmi' >> "${i%.${source_file_extension}}.gmi"
|
2024-11-05 11:17:52 +01:00
|
|
|
|
rm $temp_page
|
2024-11-03 12:32:08 +01:00
|
|
|
|
done
|
2024-11-03 11:18:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
|
# Définition de la fonction generate_website
|
|
|
|
|
generate_website() {
|
|
|
|
|
echo " Génération du site $1..."
|
|
|
|
|
|
2024-11-03 11:18:48 +01:00
|
|
|
|
|
|
|
|
|
mkdir -p gemini-capsules/$website_name
|
2024-11-05 00:35:49 +01:00
|
|
|
|
#rm -rf gemini-capsules/$website_name/*
|
2024-11-03 12:32:08 +01:00
|
|
|
|
mkdir -p gemini-capsules/$website_name/lang_fr
|
|
|
|
|
mkdir -p gemini-capsules/$website_name/lang_en
|
2024-11-03 11:42:44 +01:00
|
|
|
|
|
2024-11-03 11:18:48 +01:00
|
|
|
|
mkdir -p html-websites/$website_name
|
2024-11-03 12:32:08 +01:00
|
|
|
|
rm -rf html-websites/$website_name/*
|
|
|
|
|
mkdir -p html-websites/$website_name/lang_fr
|
|
|
|
|
mkdir -p html-websites/$website_name/lang_en
|
2024-11-03 11:42:44 +01:00
|
|
|
|
|
2024-11-03 11:18:48 +01:00
|
|
|
|
mkdir -p sources/$website_name/img
|
|
|
|
|
mkdir -p sources/$website_name/lang_fr
|
|
|
|
|
mkdir -p sources/$website_name/lang_en
|
2024-11-03 11:06:34 +01:00
|
|
|
|
|
|
|
|
|
# Ajoutez ici le code pour générer le site Web
|
|
|
|
|
echo "Le site $1 a été généré avec succès."
|
2024-11-03 11:18:48 +01:00
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
|
# conversion des pages statiques
|
|
|
|
|
cd sources/$website_name
|
|
|
|
|
convert_sources
|
2024-11-03 11:18:48 +01:00
|
|
|
|
#déplacer dans le site généré
|
2024-11-05 23:06:54 +01:00
|
|
|
|
# mv converted/*.html ../../html-websites/$website_name/
|
2024-11-05 00:35:49 +01:00
|
|
|
|
ls converted/*.gmi
|
2024-11-03 12:32:08 +01:00
|
|
|
|
mv converted/*.gmi ../../gemini-capsules/$website_name/
|
|
|
|
|
|
|
|
|
|
# traduction fr
|
2024-11-03 11:18:48 +01:00
|
|
|
|
cd lang_fr
|
2024-11-03 12:32:08 +01:00
|
|
|
|
convert_sources ../
|
2024-11-05 23:06:54 +01:00
|
|
|
|
# mv converted/*.html ../../../html-websites/$website_name/lang_fr/
|
2024-11-03 12:32:08 +01:00
|
|
|
|
mv converted/*.gmi ../../../gemini-capsules/$website_name/lang_fr/
|
2024-11-03 11:42:44 +01:00
|
|
|
|
echo "pages en français du site web $website_name converties"
|
2024-11-03 13:16:33 +01:00
|
|
|
|
cd ..
|
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
|
# traduction en
|
|
|
|
|
cd lang_en
|
|
|
|
|
convert_sources ../
|
2024-11-05 23:06:54 +01:00
|
|
|
|
# mv converted/*.html ../../../html-websites/$website_name/lang_en/
|
2024-11-03 12:32:08 +01:00
|
|
|
|
mv converted/*.gmi ../../../gemini-capsules/$website_name/lang_en/
|
|
|
|
|
echo "pages en anglais du site web $website_name converties"
|
|
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
|
cd ..
|
|
|
|
|
cd ..
|
|
|
|
|
cd ..
|
|
|
|
|
pwd
|
2024-11-04 11:52:45 +01:00
|
|
|
|
|
|
|
|
|
# création de l'index:
|
|
|
|
|
# prendre les fichiers markdown du dossier md/ ,
|
|
|
|
|
# et créer un index des fichiers situés dedans, rangés par nom de fichier décroissant,
|
|
|
|
|
# sauver le tout dans un fichier index.gmi
|
2024-11-05 11:17:52 +01:00
|
|
|
|
python3 build_indexes.py $website_name "$website_name"
|
2024-11-04 11:52:45 +01:00
|
|
|
|
|
2024-11-04 23:57:13 +01:00
|
|
|
|
python3 enrich_html.py html-websites/$website_name -t $website_name --style templates/style_general.css
|
|
|
|
|
python3 enrich_html.py html-websites/$website_name/lang_fr -t $website_name --style templates/style_general.css
|
|
|
|
|
python3 enrich_html.py html-websites/$website_name/lang_en -t $website_name --style templates/style_general.css
|
2024-11-04 11:52:45 +01:00
|
|
|
|
# python3 enrich_html.py html-websites/dragonfeu_blog/lang_fr -t $website_name --style style_general.css
|
|
|
|
|
# python3 enrich_html.py html-websites/dragonfeu_blog/lang_en -t $website_name --style style_general.css
|
2024-11-03 11:42:44 +01:00
|
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
# regrouper les types de fichiers générés
|
|
|
|
|
|
|
|
|
|
# Boucle à travers la liste des sites Web
|
2024-11-03 11:42:44 +01:00
|
|
|
|
for website_name in "${blogs_folders[@]}"; do
|
2024-11-03 11:06:34 +01:00
|
|
|
|
generate_website $website_name
|
2024-11-04 11:52:45 +01:00
|
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
|
done
|