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 00:26:25 +01:00
#blogs_folders=("dragonfeu_blog" "tykayn_blog" "cipherbliss_blog" "qzine_blog" "cil_gometz")
2024-11-04 00:13:58 +01:00
# blogs_folders=("dragonfeu_blog")
2024-11-04 09:35:31 +01:00
blogs_folders = ( "tykayn_blog" "qzine_blog" "dragonfeu_blog" )
# blogs_folders=("cil_gometz")
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-03 12:32:08 +01:00
#!/bin/bash
convert_sources( ) {
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-04 00:13:58 +01:00
echo "to HTML:"
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-04 00:13:58 +01:00
echo "to GMI:"
2024-11-03 12:32:08 +01:00
pandoc --template $templates_path ../../template_gemini.lua -f " ${ source_file_extension } " -t $templates_path ../../gmi.lua -s " ${ i } " -o " converted/ ${ i %. ${ source_file_extension } } .gmi "
# ajout des footers à chaque article
# cat '../../templates/website_pages/footer-articles.md.gmi' >> "${i%.${source_file_extension}}.gmi"
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-03 12:32:08 +01:00
rm -rf gemini-capsules/$website_name /*
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-03 12:32:08 +01:00
mv converted/*.html ../../html-websites/$website_name /
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 ../
mv converted/*.html ../../../html-websites/$website_name /lang_fr/
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 ../
mv converted/*.html ../../../html-websites/$website_name /lang_en/
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
# 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-03 11:42:44 +01:00
# python3 build_index_gemini.py
# mv index.gmi source/converted
2024-11-03 11:06:34 +01:00
2024-11-03 12:32:08 +01:00
cd ..
cd ..
cd ..
pwd
python3 enrich_html.py html-websites/dragonfeu_blog -t $website_name --style style_general.css
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 00:13:58 +01:00
python3 build_index_gemini.py $website_name
mv " index_ $website_name .html " " html-websites/ $website_name "
mv " index_ $website_name .gmi " " gemini-capsules/ $website_name "
2024-11-03 11:06:34 +01:00
done