Added templating system with Python Generator
This commit is contained in:
parent
c6c4883fc9
commit
c279c449df
7 changed files with 78 additions and 45 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
dist
|
45
generate.py
Normal file
45
generate.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
from pprint import pp
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
|
||||||
|
src = Path('src')
|
||||||
|
views = src.joinpath('views')
|
||||||
|
template = views.joinpath('template')
|
||||||
|
module = views.joinpath('module')
|
||||||
|
|
||||||
|
static = Path('src', 'static')
|
||||||
|
|
||||||
|
dist = Path('dist')
|
||||||
|
dist.mkdir(exist_ok=True)
|
||||||
|
|
||||||
|
for x in dist.rglob('*'):
|
||||||
|
if x.is_file() or x.is_symlink(): x.unlink()
|
||||||
|
for x in dist.rglob('*/'): x.rmdir()
|
||||||
|
|
||||||
|
def read(file_path):
|
||||||
|
with file_path.open() as html_file:
|
||||||
|
return (file_path.stem, html_file.read())
|
||||||
|
|
||||||
|
templates = dict(map(read, template.glob('*.html')))
|
||||||
|
modules = dict(map(read, module.glob('*.html')))
|
||||||
|
|
||||||
|
def format(item, modules):
|
||||||
|
name, content = item
|
||||||
|
|
||||||
|
return (name, re.sub('\n\s*', '', content.format(**modules)))
|
||||||
|
|
||||||
|
dist_html = dict(map(lambda item: format(item, modules), templates.items()))
|
||||||
|
|
||||||
|
def mk_dist(dist, item):
|
||||||
|
key, content = item
|
||||||
|
path = dist
|
||||||
|
if key != 'index':
|
||||||
|
path = dist.joinpath(key)
|
||||||
|
path.mkdir(exist_ok=True)
|
||||||
|
with path.joinpath('index.html').open('w') as index:
|
||||||
|
index.write(content)
|
||||||
|
|
||||||
|
for item in dist_html.items():
|
||||||
|
mk_dist(dist, item)
|
||||||
|
|
||||||
|
dist.joinpath('static').symlink_to(static.resolve(strict=True), target_is_directory=True)
|
5
src/views/module/footer.html
Normal file
5
src/views/module/footer.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<footer>
|
||||||
|
<p>Website by edpibu - 2021</p>
|
||||||
|
<p>Inspired by IBM Carbon Design System</p>
|
||||||
|
<p>Icons and Pictograms from IBM Carbon Design System</p>
|
||||||
|
</footer>
|
6
src/views/module/h1.html
Normal file
6
src/views/module/h1.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<h1>
|
||||||
|
<img src="/static/svg/logo-inv.svg"
|
||||||
|
alt="Logo : goéland avec un bec vert" />
|
||||||
|
Edgar P.
|
||||||
|
<strong>Burkhart</strong>
|
||||||
|
</h1>
|
13
src/views/module/meta.html
Normal file
13
src/views/module/meta.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||||
|
|
||||||
|
<meta name="author" content="edpibu" />
|
||||||
|
<meta name="theme-color" content="#8ac149" />
|
||||||
|
<meta name="color-scheme" content="dark light" />
|
||||||
|
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/static/svg/logo.svg" />
|
||||||
|
<link rel="mask-icon" href="/static/svg/logo.svg" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="/static/css/main.css" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="/static/css/mobile.css"
|
||||||
|
media="screen and (max-width: 42rem)" />
|
|
@ -1,29 +1,14 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
|
||||||
|
|
||||||
<title>CV - Edgar P. Burkhart</title>
|
<title>CV - Edgar P. Burkhart</title>
|
||||||
<meta name="description" content="Edgar P. Burkhart, étudiant en génie côtier à l'UPPA. Normalien-élève de l'ENS Paris-Saclay." />
|
<meta name="description" content="Edgar P. Burkhart, étudiant en génie côtier à l'UPPA. Normalien-élève de l'ENS Paris-Saclay." />
|
||||||
<meta name="author" content="edpibu" />
|
|
||||||
<meta name="theme-color" content="#8ac149" />
|
|
||||||
<meta name="color-scheme" content="dark light" />
|
|
||||||
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/static/svg/logo.svg" />
|
{meta}
|
||||||
<link rel="mask-icon" href="/static/svg/logo.svg" />
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/main.css" />
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/mobile.css"
|
|
||||||
media="screen and (max-width: 42rem)" />
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>
|
{h1}
|
||||||
<img src="/static/svg/logo-inv.svg"
|
|
||||||
alt="Logo : goéland avec un bec vert" />
|
|
||||||
Edgar P.
|
|
||||||
<strong>Burkhart</strong>
|
|
||||||
</h1>
|
|
||||||
<nav>
|
<nav>
|
||||||
<a href="/">
|
<a href="/">
|
||||||
edgarpierre.fr
|
edgarpierre.fr
|
||||||
|
@ -117,10 +102,6 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer>
|
{footer}
|
||||||
<p>Website by edpibu - 2021</p>
|
|
||||||
<p>Inspired by IBM Carbon Design System</p>
|
|
||||||
<p>Icons and Pictograms from IBM Carbon Design System</p>
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,33 +1,19 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="fr">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
|
||||||
|
|
||||||
<title>Edgar P. Burkhart</title>
|
<title>Edgar P. Burkhart</title>
|
||||||
<meta name="description"
|
<meta name="description"
|
||||||
content="Edgar P. Burkhart, étudiant en génie côtier à l'UPPA.
|
content="Edgar P. Burkhart, étudiant en génie côtier à l'UPPA.
|
||||||
Normalien-élève de l'ENS Paris-Saclay.
|
Normalien-élève de l'ENS Paris-Saclay.
|
||||||
Agrégé de Sciences Industrielles de l'Ingénieur." />
|
Agrégé de Sciences Industrielles de l'Ingénieur." />
|
||||||
<meta name="author" content="edpibu" />
|
|
||||||
<meta name="theme-color" content="#8ac149" />
|
|
||||||
<meta name="color-scheme" content="dark light" />
|
|
||||||
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/static/svg/logo.svg" />
|
{meta}
|
||||||
<link rel="mask-icon" href="/static/svg/logo.svg" />
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/main.css" />
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/index.css" />
|
<link rel="stylesheet" type="text/css" href="/static/css/index.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/mobile.css"
|
|
||||||
media="screen and (max-width: 42rem)" />
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>
|
{h1}
|
||||||
<img src="/static/svg/logo-inv.svg"
|
|
||||||
alt="Logo : goéland avec un bec vert" />
|
|
||||||
Edgar P.
|
|
||||||
<strong>Burkhart</strong>
|
|
||||||
</h1>
|
|
||||||
<div class="biglinks">
|
<div class="biglinks">
|
||||||
<a href="/cv/">
|
<a href="/cv/">
|
||||||
<img class="svg" src="/static/picto/rich--text--format.svg" alt="" />
|
<img class="svg" src="/static/picto/rich--text--format.svg" alt="" />
|
||||||
|
@ -69,10 +55,6 @@
|
||||||
</a>
|
</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<footer>
|
{footer}
|
||||||
<p>Website by edpibu - 2021</p>
|
|
||||||
<p>Inspired by IBM Carbon Design System</p>
|
|
||||||
<p>Icons and Pictograms from IBM Carbon Design System</p>
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Reference in a new issue