mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
up utils and global conf
This commit is contained in:
parent
ed322fbad4
commit
9c72473913
17 changed files with 170 additions and 155 deletions
23
WIP/export_html_dragonfeu_blog.sh
Normal file
23
WIP/export_html_dragonfeu_blog.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
# export:
|
||||
# format gemini
|
||||
pandoc --template templates/pandoc/template_gemini.lua -f html -t templates/pandoc/gmi.lua -o 2024-08-l-aventure-superphenix.gmi html/L’aventure\ Superphénix🔥.\ Superphénix…\ s’il\ est\ un\ réacteur…\ _\ by\ Dragonfeu\ _\ Medium.html
|
||||
|
||||
pandoc --template templates/pandoc/template_gemini.lua -f html -t templates/pandoc/gmi.lua -o 2024-03-recapitulatif-de-mon-contenu-twitter.gmi html/Récapitulatif\ de\ mon\ contenu\ twitter\ -\ Dragonfeu\ -\ Medium.html
|
||||
|
||||
pandoc --template templates/pandoc/template_gemini.lua -f html -t templates/pandoc/gmi.lua -o 2024-02-strategie-mitigation-accident-nucleaire.gmi html/Stratégie\ de\ mitigation\ de\ l’accident\ de\ fusion\ du\ cœur\ sur\ l’EPR.\ _\ by\ Dragonfeu\ _\ Sep,\ 2024\ _\ Medium.html
|
||||
|
||||
pandoc --template templates/pandoc/template_gemini.lua -f html -t templates/pandoc/gmi.lua -o 2024-01-recapitulatif-centrale-nucleaire-zaporijia.gmi html/Point\ de\ situation\ sur\ la\ centrale\ nucléaire\ de\ Zaporijia\ _\ by\ Dragonfeu\ _\ Medium.html
|
||||
|
||||
# format markdown
|
||||
|
||||
pandoc --template templates/pandoc/template_gemini.lua -f html -t markdown -o 2024-08-l-aventure-superphenix.md html/L’aventure\ Superphénix🔥.\ Superphénix…\ s’il\ est\ un\ réacteur…\ _\ by\ Dragonfeu\ _\ Medium.html
|
||||
|
||||
|
||||
pandoc --template templates/pandoc/template_gemini.lua -f html -t markdown -o 2024-03-recapitulatif-de-mon-contenu-twitter.md html/Récapitulatif\ de\ mon\ contenu\ twitter\ -\ Dragonfeu\ -\ Medium.html
|
||||
|
||||
pandoc --template templates/pandoc/template_gemini.lua -f html -t markdown -o 2024-02-strategie-mitigation-accident-nucleaire.md html/Stratégie\ de\ mitigation\ de\ l’accident\ de\ fusion\ du\ cœur\ sur\ l’EPR.\ _\ by\ Dragonfeu\ _\ Sep,\ 2024\ _\ Medium.html
|
||||
|
||||
pandoc --template templates/pandoc/template_gemini.lua -f html -t markdown -o 2024-01-recapitulatif-centrale-nucleaire-zaporijia.md html/Point\ de\ situation\ sur\ la\ centrale\ nucléaire\ de\ Zaporijia\ _\ by\ Dragonfeu\ _\ Medium.html
|
||||
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
import os
|
||||
import argparse
|
||||
import re
|
||||
import datetime
|
||||
import shutil
|
||||
|
||||
|
||||
def enlever_premier_tiret_ou_underscore(chaîne):
|
||||
if chaîne.startswith('-') or chaîne.startswith('_'):
|
||||
chaîne = chaîne[1:]
|
||||
return chaîne
|
||||
|
||||
# Expression régulière pour extraire la date et le slug du nom de fichier org
|
||||
regex = r"^(\d{4}(-?\d{2}){2}|\d{8})(-[a-zA-Z0-9_-]+)\.gmi$"
|
||||
regex_orgroam = r"^(\d{14})_([a-zA-Z0-9_-]+)\.gmi$"
|
||||
|
||||
def find_year_and_slug(nom_de_fichier):
|
||||
nom_de_fichier = nom_de_fichier.replace('..','.')
|
||||
annee = ''
|
||||
annee_presumed = nom_de_fichier[:4]
|
||||
print(f"///////////////// /////////////////")
|
||||
print(f"nom_de_fichier: {nom_de_fichier}")
|
||||
if int(annee_presumed) >1970 and len(annee_presumed) == 4:
|
||||
annee = str(annee_presumed)
|
||||
print(f"année: {annee}")
|
||||
match = re.match(regex_orgroam, nom_de_fichier)
|
||||
if match:
|
||||
date_str = match.group(1)
|
||||
# annee = date_str[:4]
|
||||
slug = match.group(2)
|
||||
|
||||
match = re.match(regex, nom_de_fichier)
|
||||
if match:
|
||||
date_str = match.group(1)
|
||||
# Convertir la date en objet datetime
|
||||
if "-" in date_str:
|
||||
date = datetime.datetime.strptime(date_str, "%Y-%m-%d")
|
||||
else:
|
||||
date = datetime.datetime.strptime(date_str, "%Y%m%d%H%M%S")
|
||||
date_string_replaced = str(date).replace(' 00:00:00','')
|
||||
slug = nom_de_fichier.replace('.gmi','')
|
||||
slug = slug.replace(date_string_replaced,'')
|
||||
slug = enlever_premier_tiret_ou_underscore(slug)
|
||||
|
||||
annee = str(date.year).replace(' 00:00:00','')
|
||||
else:
|
||||
print('find_year_and_slug : ERREUR aucun slug trouvé')
|
||||
return [None,annee,None]
|
||||
|
||||
|
||||
print(f"str(date): {str(date)}")
|
||||
print(f"slug: {slug}")
|
||||
print(f"chemin: {annee}/{slug}/")
|
||||
return [date_str, annee,slug]
|
||||
|
||||
def test_find_year_and_slug_short_date():
|
||||
date_string, année, slug = find_year_and_slug("2024-10-12-machin_truc-chose.gmi")
|
||||
assert slug == "machin_truc-chose"
|
||||
assert année == "2024"
|
||||
assert date_string == "2024-10-12"
|
||||
|
||||
def test_find_year_and_slug_orgroam_date():
|
||||
date_string, année, slug = find_year_and_slug("20060925105123_tkblog_879_by-the-wall-intersubkey.gmi")
|
||||
# assert slug == "by-the-wall-intersubkey"
|
||||
assert année == "2006"
|
||||
# assert date_string == "20060925"
|
||||
|
||||
|
||||
test_find_year_and_slug_short_date()
|
||||
test_find_year_and_slug_orgroam_date()
|
|
@ -1,42 +0,0 @@
|
|||
import re
|
||||
import os
|
||||
def trouver_nom_article(fichier_org):
|
||||
print('fichier_org, ',fichier_org)
|
||||
with open(fichier_org, 'r') as file:
|
||||
lignes = file.readlines()
|
||||
|
||||
# Expressions régulières pour trouver les titres de niveau 1 et 2
|
||||
titre_niveau_1 = r'^\*+ (.+)$'
|
||||
titre_niveau_2 = r'^\*\*+ (.+)$'
|
||||
|
||||
nom_article = None
|
||||
|
||||
# Itérer sur les lignes du fichier
|
||||
for ligne in lignes:
|
||||
# Rechercher un titre de niveau 1
|
||||
titre_niveau_1_match = re.match(titre_niveau_1, ligne)
|
||||
if titre_niveau_1_match:
|
||||
titre_niveau_1_texte = titre_niveau_1_match.group(1)
|
||||
if titre_niveau_1_texte.lower() != "article":
|
||||
nom_article = titre_niveau_1_texte
|
||||
break
|
||||
else:
|
||||
# Si le premier titre de niveau 1 est "Article", rechercher le premier titre de niveau 2
|
||||
titre_niveau_2_match = re.match(titre_niveau_2, ligne)
|
||||
if titre_niveau_2_match:
|
||||
nom_article = titre_niveau_2_match.group(1)
|
||||
break
|
||||
print(f"Nom de l'article : {nom_article}")
|
||||
|
||||
return nom_article
|
||||
|
||||
|
||||
# Chemin absolu du dossier parent (pour sauver le fichier d'index)
|
||||
dossier_parent = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
nom = trouver_nom_article(dossier_parent+'/sources/cipherbliss_blog/contact.org')
|
||||
print('nom ',nom)
|
||||
|
||||
nom = trouver_nom_article(dossier_parent+'/sources/cipherbliss_blog/lang_fr/20210927092238_cipherbliss_blog_238_des-sauvegardes-qui-durent-mille-ans.org')
|
||||
|
||||
print('nom ',nom)
|
Loading…
Add table
Add a link
Reference in a new issue