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-08 17:40:06 +01:00
|
|
|
|
style_file="templates/style_general.css"
|
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-08 17:40:06 +01:00
|
|
|
|
first_wd=$PWD
|
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 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
|
|
|
|
|
|
2024-11-08 17:40:06 +01:00
|
|
|
|
cat "$first_wd/sources/$website_name/templates/header_page.$source_file_extension" >> $temp_page
|
2024-11-05 11:17:52 +01:00
|
|
|
|
cat "${i}" >> $temp_page
|
2024-11-08 17:40:06 +01:00
|
|
|
|
cat "$first_wd/sources/$website_name/templates/footer_page.$source_file_extension" >> $temp_page
|
2024-11-05 11:17:52 +01:00
|
|
|
|
|
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"
|
2024-11-08 17:40:06 +01:00
|
|
|
|
# --------------------------------------- Transformer en gmi ---------------------------------------
|
2024-11-05 01:14:45 +01:00
|
|
|
|
# echo "to GMI:"
|
|
|
|
|
# pwd
|
|
|
|
|
# ls -l $templates_path/../../templates/pandoc
|
2024-11-08 17:40:06 +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-08 17:40:06 +01:00
|
|
|
|
# --------------------------------------------------------------------------------------------------
|
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-08 17:40:06 +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-08 17:40:06 +01:00
|
|
|
|
# rm -rf html-websites/$website_name/*
|
2024-11-03 12:32:08 +01:00
|
|
|
|
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
|
2024-11-08 17:40:06 +01:00
|
|
|
|
# cd lang_en
|
|
|
|
|
# convert_sources ../
|
2024-11-05 23:06:54 +01:00
|
|
|
|
# mv converted/*.html ../../../html-websites/$website_name/lang_en/
|
2024-11-08 17:40:06 +01:00
|
|
|
|
# mv converted/*.gmi ../../../gemini-capsules/$website_name/lang_en/
|
|
|
|
|
# echo "pages en anglais du site web $website_name converties"
|
2024-11-03 12:32:08 +01:00
|
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
|
cd ..
|
|
|
|
|
cd ..
|
2024-11-08 18:05:08 +01:00
|
|
|
|
# cd ..
|
2024-11-03 12:32:08 +01:00
|
|
|
|
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-08 18:16:36 +01:00
|
|
|
|
mv index_$website_name.gmi gemini-capsules/$website_name/index.gmi
|
|
|
|
|
mv index_$website_name.html html-websites/$website_name/index.html
|
2024-11-08 17:40:06 +01:00
|
|
|
|
|
|
|
|
|
cp $style_file html-websites/$website_name/style.css
|
|
|
|
|
# --------------------------------------------------------------------------------------------------
|
|
|
|
|
# convertir les fichiers org
|
2024-11-08 18:05:08 +01:00
|
|
|
|
echo " ------------ enrich html --------"
|
2024-11-08 17:40:06 +01:00
|
|
|
|
python3 enrich_html.py html-websites/$website_name -t $website_name --style $style_file
|
|
|
|
|
|
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-08 17:40:06 +01:00
|
|
|
|
|
|
|
|
|
destination_gemini="gemini-capsules/$website_name/"
|
|
|
|
|
|
|
|
|
|
echo "génération des fichiers gemini"
|
|
|
|
|
echo "destination des fichiers gemini: $destination_gemini"
|
|
|
|
|
# # faire les fichiers gemini à partir du markdown
|
|
|
|
|
for fichier in output/*$website_name*.md ; do
|
|
|
|
|
if [ -f "$fichier" ]; then
|
|
|
|
|
echo "convert markdown $fichier"
|
|
|
|
|
md2gemini "$fichier" -w -d $destination_gemini
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
echo "génération des fichiers gemini faite."
|
|
|
|
|
|
2024-11-08 18:05:08 +01:00
|
|
|
|
# echo "fichiers gmi présents:"
|
|
|
|
|
# ls -l output/*.gmi |wc -l
|
2024-11-04 11:52:45 +01:00
|
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
|
done
|