mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
more complex template html
This commit is contained in:
parent
22b713fb4a
commit
f016f842c9
844 changed files with 8190 additions and 10977 deletions
143
enrich_html.py
143
enrich_html.py
|
@ -16,7 +16,7 @@ style_file = args.style
|
|||
blog_name = args.blog_name
|
||||
source_blog = f"sources/{blog_name}"
|
||||
header_content_path = f"{source_blog}/templates/header_page.org"
|
||||
footer_content_path = f"{source_blog}/templates/header_page.org"
|
||||
footer_content_path = f"{source_blog}/templates/footer_page.org"
|
||||
static_page_path = f"{source_blog}/templates/html/static.html"
|
||||
|
||||
# variables du template de page
|
||||
|
@ -26,17 +26,37 @@ BLOG_SUBTITLE='Code, nouvelles technologies et entrepreneurariat par B. Lemoine'
|
|||
TITLE=''
|
||||
AUTHOR=''
|
||||
PAGE_TITLE=''
|
||||
LOCALE=''
|
||||
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='image/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>'
|
||||
match = re.search(pattern, html_content, re.DOTALL)
|
||||
if match:
|
||||
return match.group(1)
|
||||
else:
|
||||
return None
|
||||
def remove_before_body(text):
|
||||
pattern = r"<!DOCTYPE>.+?<body>"
|
||||
replacement = "<body>"
|
||||
return re.sub(pattern, replacement, text, flags=re.DOTALL)
|
||||
|
||||
def remove_after_body(text):
|
||||
pattern = r"</body>.+?</html>"
|
||||
replacement = "</body>"
|
||||
return re.sub(pattern, replacement, text, flags=re.DOTALL)
|
||||
|
||||
|
||||
def remove_properties_section(text):
|
||||
pattern = r"<h1 id=\"article\">Article</h1>.+?</ul>"
|
||||
replacement = ""
|
||||
|
@ -46,7 +66,7 @@ def remove_article_head_properties_orgmode(text):
|
|||
pattern = r":PROPERTIES:.+?:END:"
|
||||
replacement = ""
|
||||
return re.sub(pattern, replacement, text, flags=re.DOTALL)
|
||||
|
||||
|
||||
def remove_hint_html(text):
|
||||
pattern = r"<p>ceci<sub>estduhtml</sub></p>"
|
||||
replacement = ""
|
||||
|
@ -72,6 +92,9 @@ 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)
|
||||
|
@ -83,32 +106,96 @@ def enrich_one_file(file, root_path):
|
|||
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
|
||||
html_content = f"""<!DOCTYPE html>
|
||||
<!-- généré avec orgmode-to-gemini-blog par Tykayn -->
|
||||
<html lang=\"fr\">
|
||||
<head>
|
||||
<meta charset=\"UTF-8\">
|
||||
<title>{BLOG_TITLE}</title>
|
||||
{css_content}
|
||||
<link rel=\"stylesheet\" href=\"/style.css\"></link>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
html_content = f"""
|
||||
|
||||
<h1>{BLOG_TITLE}</h1>
|
||||
<p>{BLOG_SUBTITLE}</p>
|
||||
{NAVIGATION}
|
||||
</header>
|
||||
<hr/>
|
||||
<main>
|
||||
{html_content}
|
||||
</main>
|
||||
<hr/>
|
||||
<footer>
|
||||
{NAVIGATION}
|
||||
</footer>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<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="https://portfolio.cipherbliss.com/">
|
||||
<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/">
|
||||
<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}">
|
||||
<!-- 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}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="page">
|
||||
<header id="masthead" class="site-header">
|
||||
<div class="header-image">
|
||||
{BANNIERE_ENTETE}
|
||||
</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}">
|
||||
<img src="{SITE_ICON}"
|
||||
class="img-fluid">
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="navbarBasicExample" class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
<a class="navbar-item" href="{NDD}">
|
||||
<img src="{SITE_ICON}"
|
||||
class="img-fluid">
|
||||
</a>
|
||||
{NAVIGATION}
|
||||
</div>
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<form role="search" method="get" class="search-form" action="/">
|
||||
<label>
|
||||
<input class="search-field" placeholder="Recherche" value="" name="s"
|
||||
type="search">
|
||||
</label>
|
||||
<input class="is-hidden search-submit" value="Rechercher" type="submit">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<main class="body-wrap boxed-container">
|
||||
<article class="content">
|
||||
{html_content}
|
||||
</article>
|
||||
</main>
|
||||
<footer class="site-footer has-top-divider">
|
||||
<div class="container">
|
||||
<div class="site-footer-inner">
|
||||
|
||||
{BLOG_TITLE}
|
||||
{BLOG_SUBTITLE}
|
||||
{NAVIGATION}
|
||||
{css_content}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<!-- généré avec orgmode-to-gemini-blog par Tykayn -->
|
||||
</html>
|
||||
|
||||
"""
|
||||
|
||||
html_path_enriched=os.path.join(root_path, file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue