up displayed pages

This commit is contained in:
Tykayn 2024-11-11 01:25:10 +01:00 committed by tykayn
parent 83dd9f7472
commit a58b0efcad
319 changed files with 9426 additions and 212 deletions

View file

@ -26,27 +26,14 @@ regex_orgroam = r"^(\d{14})_([a-zA-Z0-9_-]+)\.gmi$"
use_article_file_for_name=False
website_name = args.source
def extract_body_content(html_content):
pattern = r'<body>.+?</body>'
match = re.search(pattern, html_content, re.DOTALL)
if match:
return match.group(1)
else:
return None
def extract_body_content(html_content):
pattern = r'<body[^>]*?>(.*?)</body>'
match = re.search(pattern, html_content, re.DOTALL)
if match:
return match.group(1)
else:
return None
def trouver_nom_article(fichier_org, format="html"):
print('fichier_org, ',fichier_org)
with open(fichier_org, 'r') as file:
lignes = file.readlines()
nom_article = None
nom_article = ''
# Expressions régulières pour trouver les titres de niveau 1 et 2
if format == 'html':
@ -64,7 +51,7 @@ def trouver_nom_article(fichier_org, format="html"):
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":
if titre_niveau_1_texte.lower() != "article" and titre_niveau_1_texte.lower() != "liens" :
nom_article = titre_niveau_1_texte
break
else:
@ -75,7 +62,7 @@ def trouver_nom_article(fichier_org, format="html"):
break
print(f"Nom de l'article : {nom_article}")
return nom_article
return nom_article.replace(args.source+'_', '').replace('_', ' ')
def find_year_and_slug(fichier):
@ -155,22 +142,22 @@ def get_files_list_of_folder(folder_path):
def empty_folder_content(path):
print("empty ", path)
# parcours tous les fichiers et sous-dossiers du dossier
for filename in os.listdir(path):
file_path = os.path.join(path, filename)
# for filename in os.listdir(path):
# file_path = os.path.join(path, filename)
# supprime le fichier ou le sous-dossier
if os.path.isfile(file_path):
os.remove(file_path)
else:
shutil.rmtree(file_path)
# # supprime le fichier ou le sous-dossier
# if os.path.isfile(file_path):
# os.remove(file_path)
# else:
# shutil.rmtree(file_path)
def generer_index(dossier_source, fichier_index, titre_index):
# Chemin absolu du dossier parent (pour sauver le fichier d'index)
dossier_parent = os.path.dirname(os.path.abspath(__file__))
empty_folder_content(dossier_parent+'/html-websites/'+args.source+'/')
empty_folder_content(dossier_parent+'/gemini-capsules/'+args.source+'/')
empty_folder_content(dossier_parent+'/html-websites/'+args.source+'/')
# Chemin complet du dossier contenant les Markdown
chemin_dossier_source = os.path.join(dossier_parent, dossier_source)