variabilize blog params

This commit is contained in:
Tykayn 2024-11-12 00:55:21 +01:00 committed by tykayn
parent 2a1891dc2a
commit 9267636687
59 changed files with 1537 additions and 1665 deletions

View file

@ -2,6 +2,7 @@
import os
import argparse
import re
from website_config import configs_sites
parser = argparse.ArgumentParser(description="Générer un site Web à partir de fichiers HTML.")
parser.add_argument("blog_name", help="Le chemin vers le dossier contenant les fichiers HTML.")
@ -12,13 +13,16 @@ args = parser.parse_args()
# Style CSS minimaliste
style_file = args.style
blog_name = args.blog_name
blog_name = args.blog_name.replace('html-websites/','')
source_blog = f"sources/{blog_name}"
header_content_path = f"{source_blog}/templates/converted/header_page.html"
footer_content_path = f"{source_blog}/templates/converted/footer_page.html"
static_page_path = f"{source_blog}/templates/html/static.html"
print('---------- blog name ', blog_name)
template_content = configs_sites[blog_name]
footer_content=''
after_article=''
# TODO add footer on every article
@ -27,33 +31,6 @@ after_article=''
# TODO make these variables overrided by configuration of a source website
# variables du template de page
BANNIERE_ENTETE=''
BLOG_TITLE='Cipher Bliss'
BLOG_SUBTITLE='Code, nouvelles technologies et entrepreneurariat par B. Lemoine'
TITLE=''
AUTHOR=''
PAGE_TITLE=''
LOCALE='fr_FR'
DESCRIPTION=''
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>
"""
BANNIERE_ENTETE='https://www.cipherbliss.com/wp-content/uploads/2016/11/bg.jpg'
BANNIERE_ENTETE_ALT='bannière du site'
ARTICLE=''
FOOTER=''
def extract_body_content(html_content):
pattern = r'<body[^>]*?>(.*?)</body>'
@ -119,40 +96,40 @@ def enrich_one_file(file, root_path):
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<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="{NDD}">
<meta property="og:site_name" content="Cipher Bliss">
<link rel="alternate" type="application/rss+xml" title="Cipher Bliss » Flux" href="{NDD}/feed/">
<meta property="og:image" content="{template_content['SITE_ICON']}">
<meta property="og:locale" content="{template_content['LOCALE']}">
<meta property="og:description" content="{template_content['BLOG_SUBTITLE']}">
<meta property="og:url" content="{template_content['NDD']}">
<meta property="og:site_name" content="{template_content['TITLE']}">
<link rel="alternate" type="application/rss+xml" title="Cipher Bliss » Flux" href="{template_content['NDD']}/feed/">
<link href="/style.css" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{TITLE}</title>
<meta name="author" content="{AUTHOR}">
<link rel="alternate" type="application/rss+xml" title="{BLOG_TITLE} » Flux"
href="{NDD}/feed/">
<meta property="og:title" content="{PAGE_TITLE}">
<meta property="og:locale" content="{LOCALE}">
<title>{template_content['TITLE']}</title>
<meta name="author" content="{template_content['AUTHOR']}">
<link rel="alternate" type="application/rss+xml" title="{template_content['BLOG_TITLE']} » Flux"
href="{template_content['NDD']}/feed/">
<meta property="og:title" content="{template_content['PAGE_TITLE']}">
<meta property="og:locale" content="{template_content['LOCALE']}">
<!-- Description de la page -->
<meta name="description" content="{PAGE_TITLE}">
<meta name="reply-to" content="{EMAIL}">
<link rel="icon" type="{SITE_ICON_TYPE}" href="{SITE_ICON}">
<meta name="description" content="{template_content['PAGE_TITLE']}">
<meta name="reply-to" content="{template_content['EMAIL']}">
<link rel="icon" type="{template_content['SITE_ICON_TYPE']}" href="{template_content['SITE_ICON']}">
</head>
<body>
<div id="page">
<header id="masthead" class="site-header">
<div class="header-image" style="background: url({BANNIERE_ENTETE})">
<div class="header-image" style="background: url({template_content['BANNIERE_ENTETE']})">
<a href="/">
<img src="{SITE_ICON}" class="site-icon img">
<img src="{template_content['SITE_ICON']}" class="site-icon img">
</a>
<h1 class="blog-title">{BLOG_TITLE}</h1>
<p class="blog-subtitle">{BLOG_SUBTITLE}</p>
<h1 class="blog-title">{template_content['BLOG_TITLE']}</h1>
<p class="blog-subtitle">{template_content['BLOG_SUBTITLE']}</p>
</div>
<nav class="navbar is-fixed-top is-dark" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="{NDD}">
<a class="navbar-item" href="{template_content['NDD']}">
</a>
@ -160,11 +137,11 @@ def enrich_one_file(file, root_path):
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="{NDD}">
<img src="{SITE_ICON}"
<a class="navbar-item" href="{template_content['NDD']}">
<img src="{template_content['SITE_ICON']}"
class="img-fluid">
</a>
{NAVIGATION}
{template_content['NAVIGATION']}
</div>
<div class="navbar-end">
<div class="navbar-item">
@ -194,7 +171,7 @@ def enrich_one_file(file, root_path):
{NAVIGATION}
{template_content['NAVIGATION']}
</div>
</div>