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 23:19:39 +01:00
|
|
|
style_file="templates/styles/style_general.css"
|
2024-11-10 18:03:31 +01:00
|
|
|
destination_gemini="gemini-capsules/$website_name/"
|
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
|
2024-11-09 00:19:43 +01:00
|
|
|
echo "----------- La liste des noms de blogs est :"
|
2024-11-04 14:14:28 +01:00
|
|
|
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-10 15:58:11 +01:00
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
source_file_extension="org"
|
|
|
|
|
|
|
|
templates_path=$1
|
2024-11-10 18:03:31 +01:00
|
|
|
echo "----------- convert_sources : convertir les fichiers orgmode vers gemini et html dans le dossier source/nom_du_blog/ racine, lang_fr et lang_en"
|
|
|
|
echo "----------- convert_sources : $templates_path"
|
2024-11-03 12:32:08 +01:00
|
|
|
|
|
|
|
mkdir -p converted
|
2024-11-03 11:18:48 +01:00
|
|
|
|
2024-11-10 15:58:11 +01:00
|
|
|
pwd
|
|
|
|
ls -l *.${source_file_extension} |wc -l
|
2024-11-03 11:18:48 +01:00
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
for i in *.${source_file_extension} ; do
|
2024-11-09 00:19:43 +01:00
|
|
|
echo "----------- $i"
|
2024-11-05 11:17:52 +01:00
|
|
|
|
2024-11-11 00:02:50 +01:00
|
|
|
# Transformer en html et en markdown
|
2024-11-10 18:03:31 +01:00
|
|
|
echo "----------- convert_sources : conversion vers converted/${i%.${source_file_extension}}.html"
|
2024-11-09 00:19:43 +01:00
|
|
|
|
2024-11-10 15:58:11 +01:00
|
|
|
pandoc --from "${source_file_extension}" --to html -s "${i}" -o "converted/${i%.${source_file_extension}}.html" --metadata title="$website_name"
|
2024-11-11 00:02:50 +01:00
|
|
|
|
|
|
|
pandoc --from "${source_file_extension}" --to markdown -s "${i}" -o "converted/${i%.${source_file_extension}}.md" --metadata title="$website_name"
|
2024-11-10 15:58:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
done
|
2024-11-10 15:58:11 +01:00
|
|
|
|
|
|
|
|
2024-11-03 11:18:48 +01:00
|
|
|
}
|
|
|
|
|
2024-11-10 15:58:11 +01:00
|
|
|
|
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
# Définition de la fonction generate_website
|
|
|
|
generate_website() {
|
2024-11-10 18:03:31 +01:00
|
|
|
echo "----------- convert_sources :Génération du site $1..."
|
2024-11-03 11:06:34 +01:00
|
|
|
|
2024-11-03 11:18:48 +01:00
|
|
|
|
2024-11-03 11:42:44 +01:00
|
|
|
|
2024-11-10 00:01:15 +01:00
|
|
|
if [ ! -d "sources/$website_name" ]; then
|
|
|
|
mkdir -p sources/$website_name/img
|
|
|
|
mkdir -p sources/$website_name/lang_fr
|
|
|
|
mkdir -p sources/$website_name/lang_en
|
2024-11-10 15:58:11 +01:00
|
|
|
mkdir -p sources/$website_name/templates
|
|
|
|
|
|
|
|
cp templates/$website_name/$source_file_extension/* sources/$website_name/templates
|
2024-11-10 00:01:15 +01:00
|
|
|
fi
|
2024-11-03 11:06:34 +01:00
|
|
|
|
2024-11-10 15:58:11 +01:00
|
|
|
|
|
|
|
mkdir -p html-websites/$website_name
|
2024-11-18 11:18:50 +01:00
|
|
|
mkdir -p html-websites/$website_name/feed
|
|
|
|
|
2024-11-10 15:58:11 +01:00
|
|
|
rm -rf html-websites/$website_name/*
|
2024-11-11 00:02:50 +01:00
|
|
|
rm -rf sources/$website_name/converted/*
|
|
|
|
rm -rf sources/$website_name/lang_fr/converted/*
|
|
|
|
rm -rf sources/$website_name/lang_en/converted/*
|
|
|
|
mkdir -p html-websites/$website_name/lang_fr
|
2024-11-10 15:58:11 +01:00
|
|
|
mkdir -p html-websites/$website_name/lang_fr
|
|
|
|
|
2024-11-10 18:03:31 +01:00
|
|
|
echo "----------- convert_sources :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-10 00:01:15 +01:00
|
|
|
|
2024-11-11 00:58:44 +01:00
|
|
|
cd templates
|
|
|
|
convert_sources ../
|
2024-11-14 13:32:56 +01:00
|
|
|
# echo "----------- convert_sources : pages template $website_name converties"
|
2024-11-11 00:58:44 +01:00
|
|
|
cd ..
|
2024-11-03 12:32:08 +01:00
|
|
|
|
|
|
|
# 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-14 13:32:56 +01:00
|
|
|
# echo "----------- convert_sources :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-09 00:19:43 +01:00
|
|
|
cd lang_en
|
|
|
|
convert_sources ../
|
|
|
|
# echo "----------- pages en anglais du site web $website_name converties"
|
2024-11-03 12:32:08 +01:00
|
|
|
cd ..
|
2024-11-11 00:58:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-03 12:32:08 +01:00
|
|
|
cd ..
|
2024-11-09 00:19:43 +01:00
|
|
|
cd ..
|
2024-11-03 12:32:08 +01:00
|
|
|
pwd
|
2024-11-11 00:02:50 +01:00
|
|
|
|
2024-11-08 23:19:39 +01:00
|
|
|
|
|
|
|
cp $style_file html-websites/$website_name/style.css
|
2024-11-09 00:19:43 +01:00
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
|
|
|
|
}
|
2024-11-10 15:58:11 +01:00
|
|
|
|
|
|
|
convert_markdown_to_gmi() {
|
2024-11-10 18:03:31 +01:00
|
|
|
|
2024-11-11 00:02:50 +01:00
|
|
|
destination_gemini="gemini-capsules/$website_name"
|
2024-11-10 18:03:31 +01:00
|
|
|
echo "----------- convert_sources : convert_markdown_to_gmi : $website_name"
|
2024-11-10 15:58:11 +01:00
|
|
|
|
2024-11-11 01:25:10 +01:00
|
|
|
# rm -rf gemini-capsules/$website_name/*
|
2024-11-11 00:02:50 +01:00
|
|
|
mkdir -p gemini-capsules/$website_name
|
2024-11-10 15:58:11 +01:00
|
|
|
mkdir -p gemini-capsules/$website_name/lang_fr
|
|
|
|
mkdir -p gemini-capsules/$website_name/lang_en
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-14 13:32:56 +01:00
|
|
|
# echo "----------- convert_markdown_to_gmi : $PWD"
|
|
|
|
# echo "----------- convert_markdown_to_gmi : destination: $destination_gemini"
|
2024-11-10 18:03:31 +01:00
|
|
|
|
2024-11-14 13:32:56 +01:00
|
|
|
# echo "----------- convert_markdown_to_gmi : fichiers markdown présents dans le dossier de base: "
|
2024-11-10 18:03:31 +01:00
|
|
|
|
|
|
|
ls -l sources/$website_name/converted/*.md |wc
|
|
|
|
|
2024-11-10 15:58:11 +01:00
|
|
|
# # faire les fichiers gemini à partir du markdown
|
2024-11-10 18:03:31 +01:00
|
|
|
# pages de base
|
|
|
|
# pages fr
|
|
|
|
# pages en
|
|
|
|
for fichier in sources/$website_name/converted/*.md ; do
|
2024-11-10 15:58:11 +01:00
|
|
|
if [ -f "$fichier" ]; then
|
2024-11-15 15:58:19 +01:00
|
|
|
echo "----------- convert_markdown_to_gmi : md2gemini : $destination_gemini : $fichier"
|
2024-11-11 00:02:50 +01:00
|
|
|
md2gemini "$fichier" -w -d $destination_gemini/
|
2024-11-10 15:58:11 +01:00
|
|
|
fi
|
|
|
|
done
|
2024-11-11 00:02:50 +01:00
|
|
|
cp sources/$website_name/converted/*.gmi "$destination_gemini/lang_fr"
|
|
|
|
|
2024-11-10 18:03:31 +01:00
|
|
|
for fichier in sources/$website_name/lang_fr/converted/*.md ; do
|
|
|
|
if [ -f "$fichier" ]; then
|
2024-11-15 15:58:19 +01:00
|
|
|
echo "----------- convert_markdown_to_gmi : md2gemini : $fichier"
|
2024-11-10 18:03:31 +01:00
|
|
|
md2gemini "$fichier" -w -d sources/$website_name/lang_fr/converted/
|
|
|
|
fi
|
|
|
|
done
|
2024-11-11 00:02:50 +01:00
|
|
|
cp sources/$website_name/lang_fr/converted/*.gmi "$destination_gemini/lang_fr"
|
|
|
|
|
2024-11-10 18:03:31 +01:00
|
|
|
for fichier in sources/$website_name/lang_en/converted/*.md ; do
|
|
|
|
if [ -f "$fichier" ]; then
|
2024-11-15 15:58:19 +01:00
|
|
|
echo "----------- convert_markdown_to_gmi : md2gemini : $fichier"
|
2024-11-10 18:03:31 +01:00
|
|
|
md2gemini "$fichier" -w -d sources/$website_name/lang_fr/converted/
|
|
|
|
fi
|
|
|
|
done
|
2024-11-11 00:02:50 +01:00
|
|
|
cp sources/$website_name/lang_en/converted/*.gmi "$destination_gemini/lang_en"
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-10 15:58:11 +01:00
|
|
|
|
|
|
|
echo "----------- génération des fichiers gemini faite."
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-10 18:03:31 +01:00
|
|
|
# echo "fichiers gmi présents:"
|
|
|
|
# ls -l $destination_gemini*.gmi |wc -l
|
2024-11-10 15:58:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
# regrouper les types de fichiers générés
|
|
|
|
|
2024-11-10 15:58:11 +01:00
|
|
|
bash sass_styles.sh
|
2024-11-08 23:19:39 +01:00
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
# Boucle à travers la liste des sites Web
|
2024-11-03 11:42:44 +01:00
|
|
|
for website_name in "${blogs_folders[@]}"; do
|
2024-11-10 15:58:11 +01:00
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
generate_website $website_name
|
2024-11-11 01:25:10 +01:00
|
|
|
|
2024-11-10 22:35:03 +01:00
|
|
|
convert_markdown_to_gmi $website_name
|
2024-11-10 15:58:11 +01:00
|
|
|
|
2024-11-14 13:32:56 +01:00
|
|
|
# création de l'index listant les articles pour le html et la capsule gemini:
|
2024-11-10 18:03:31 +01:00
|
|
|
# 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-14 13:32:56 +01:00
|
|
|
python3 build_indexes.py $website_name
|
2024-11-10 18:03:31 +01:00
|
|
|
|
2024-11-15 15:58:19 +01:00
|
|
|
# créer les pages de tags
|
|
|
|
python3 gather_tags_in_json.py $website_name
|
|
|
|
|
2024-11-10 18:03:31 +01:00
|
|
|
# déplacer les fichiers générés en html dans le dossier statique
|
2024-11-14 13:32:56 +01:00
|
|
|
mv sources/$website_name/converted/*.html html-websites/$website_name/
|
2024-11-10 18:03:31 +01:00
|
|
|
|
2024-11-14 13:32:56 +01:00
|
|
|
python3 enrich_html.py html-websites/$website_name --style $style_file
|
2024-11-10 18:03:31 +01:00
|
|
|
|
2024-11-14 13:32:56 +01:00
|
|
|
# copier le style dans le dossier html
|
2024-11-10 18:03:31 +01:00
|
|
|
cp $style_file html-websites/$website_name/style.css
|
2024-11-16 00:44:19 +01:00
|
|
|
# copier le script permettant la recherche
|
|
|
|
cp templates/js/main_script.js html-websites/$website_name/main_script.js
|
2024-11-08 17:40:06 +01:00
|
|
|
|
2024-11-15 15:58:19 +01:00
|
|
|
# traiter les réductions d'images dans l'inbox
|
|
|
|
python3 pictures_resize.py
|
2024-11-18 11:18:50 +01:00
|
|
|
python3 atom_generate.py $website_name
|
|
|
|
mv "index_$website_name.xml" "html-websites/$website_name/feed/index.xml"
|
2024-11-15 15:58:19 +01:00
|
|
|
|
2024-11-03 11:06:34 +01:00
|
|
|
done
|