auto detect tags and move pictures after resizing

This commit is contained in:
Tykayn 2024-11-15 15:58:19 +01:00 committed by tykayn
parent 9c72473913
commit 618c029c62
8 changed files with 165 additions and 154 deletions

View file

@ -22,7 +22,7 @@ static_page_path = f"{source_blog}/templates/html/static.html"
enable_header=True
# print('---------- blog name ', blog_name)
mylog('---------- blog name ', blog_name)
template_content = configs_sites[blog_name]
after_article = ''
@ -51,7 +51,7 @@ def enrich_one_file(html_content: str, partials: dict = {"header_page": "", "foo
if inline_the_css is True:
print(' ----------- enrich_html: include css inline in each html page')
mylog(' ----------- enrich_html: include css inline in each html page')
with open(os.path.join(root_path, file), "r") as f:
css_content = f.read()
css_content = "<style type='text/css'>{css_content}</style>"
@ -144,6 +144,7 @@ def enrich_one_file(html_content: str, partials: dict = {"header_page": "", "foo
</div>
<nav class="footer-nav">
{template_content['NAVIGATION']}
<a href="/tags/">Tags</a>
</nav>
</div>
</div>
@ -169,8 +170,9 @@ def ouvrir_fichier(chemin_fichier):
raise FileNotFoundError(f"Le fichier {chemin_fichier} n'existe pas.")
liste_fichiers_du_blog_convertis = os.walk(html_pages)
print('fichiers à enrichir:', liste_fichiers_du_blog_convertis)
mylog('fichiers à enrichir:', liste_fichiers_du_blog_convertis)
count_articles=0
# Parcourir tous les fichiers HTML dans le dossier du blog donné
for root_path, dirs, files in liste_fichiers_du_blog_convertis :
@ -185,14 +187,14 @@ for root_path, dirs, files in liste_fichiers_du_blog_convertis :
partials["footer_content"] = ouvrir_fichier(os.path.join('sources',blog_name, 'templates', 'footer_page.org'))
for file in files:
print(file)
if file is "index.html":
template_content['no_header']
# mylog(file)
# if file == "index.html":
# template_content['no_header']=True
if file.endswith(".html"):
print(' ----------- enrich_html: file:', os.path.join(root_path, file))
print(' ----------- enrich_html: CSS inline: ', inline_the_css)
# mylog(' ----------- enrich_html: file:'+ os.path.join(root_path, file))
count_articles+=1
mylog(' ----------- enrich_html: CSS inline: ', inline_the_css)
# Ouvrir le fichier HTML en mode lecture
with open(os.path.join(root_path, file), "r") as f:
@ -200,8 +202,10 @@ for root_path, dirs, files in liste_fichiers_du_blog_convertis :
html_content = enrich_one_file(html_content, partials)
html_path_enriched = os.path.join(root_path, file)
print(' ----------- enrich_html: html_path_enriched ============> ', html_path_enriched)
mylog(' ----------- enrich_html: html_path_enriched ============> ', html_path_enriched)
# Écrire le contenu modifié dans le fichier HTML
with open(html_path_enriched, "w") as f:
f.write(html_content)
print('\n ----------- enrich_html: html écrit ', html_path_enriched)
mylog('\n ----------- enrich_html: html écrit ', html_path_enriched)
print('articles listés :',count_articles)