try finding article name from content

This commit is contained in:
Tykayn 2024-11-11 00:02:50 +01:00 committed by tykayn
parent 9cd8d6d92e
commit 7e9e8f2436
31 changed files with 124 additions and 426 deletions

View file

@ -32,7 +32,15 @@ NDD='https://www.cipherbliss.com'
EMAIL='contact@cipherbliss.com'
SITE_ICON='https://www.cipherbliss.com/wp-content/uploads/2016/12/rond.png'
SITE_ICON_TYPE='image/png'
NAVIGATION='<nav><a href="/">Accueil</a><a href="https://portfolio.cipherbliss.com">Portfolio</a><a href="/feed">Flux RSS</a><a href="/contact">Contact</a><a href="/ressources-de-café-vie-privée">Ressources</a></nav>'
NAVIGATION="""
<nav>
<a href="/">Accueil</a>
<a href="https://portfolio.cipherbliss.com">Portfolio</a>
<a href="/feed">Flux RSS</a>
<a href="/contact">Contact</a>
<a href="/ressources-de-café-vie-privée">Ressources</a>
</nav>
"""
BANNIERE_ENTETE='https://www.cipherbliss.com/wp-content/uploads/2016/11/bg.jpg'
BANNIERE_ENTETE_ALT='bannière du site'
ARTICLE=''
@ -92,12 +100,10 @@ def enrich_one_file(file, root_path):
with open(os.path.join(root_path, file), "r") as f:
html_content = f.read()
# html_content = extract_body_content(html_content)
# html_content = remove_before_body(html_content)
# html_content = remove_after_body(html_content)
html_content = remove_properties_section(html_content)
html_content = remove_article_head_properties_orgmode(html_content)
html_content = remove_hint_html(html_content)
# remove some parts
# html_content = remove_properties_section(html_content)
# html_content = remove_article_head_properties_orgmode(html_content)
# html_content = remove_hint_html(html_content)
if inline_the_css == True:
print(' ----------- include css inline in each html page')
@ -105,7 +111,7 @@ def enrich_one_file(file, root_path):
css_content = f.read()
css_content = "<style type='text/css'>{css_content}</style>"
# Ajouter la déclaration de charset UTF-8, le doctype HTML et le titre du site Web
# remplir le template
html_content = f"""
<!DOCTYPE html>
@ -116,10 +122,10 @@ def enrich_one_file(file, root_path):
<meta property="og:image" content="{SITE_ICON}">
<meta property="og:locale" content="{LOCALE}">
<meta property="og:description" content="{BLOG_SUBTITLE}">
<meta property="og:url" content="https://portfolio.cipherbliss.com/">
<meta property="og:url" content="{NDD}">
<meta property="og:site_name" content="Cipher Bliss">
<link rel="alternate" type="application/rss+xml" title="Cipher Bliss » Flux"
href="https://www.cipherbliss.com/feed/">
href="{NDD}/feed/">
<link href="/style.css" rel="stylesheet">
<meta charset="utf-8">
@ -188,7 +194,6 @@ def enrich_one_file(file, root_path):
{NAVIGATION}
{css_content}
</div>
</div>
@ -201,6 +206,7 @@ def enrich_one_file(file, root_path):
"""
html_path_enriched=os.path.join(root_path, file)
print(' 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)