add a page header

This commit is contained in:
Nick Pegg 2024-08-04 09:34:16 -07:00
parent 35d5884591
commit 2875805444
4 changed files with 27 additions and 9 deletions

View file

@ -156,15 +156,15 @@ def generate_html(config: Config, root_dir: ImageDirectory) -> None:
for album_dir in root_dir.walk():
html_path = album_dir.path / "index.html"
static_path = root_dir.path.relative_to(
root_path = root_dir.path.relative_to(
html_path.parent, walk_up=True
) / "static"
)
logger.debug(f"Rendering {html_path}")
with html_path.open("w") as f:
f.write(
album_tmpl.render(
static_dir=static_path,
root_path=root_path,
album_dir=album_dir,
)
)
@ -173,9 +173,9 @@ def generate_html(config: Config, root_dir: ImageDirectory) -> None:
# TODO: If a file with a matching name but .txt or .md, add that as the
# description for the image
html_path = image_path.html_path()
static_path = root_dir.path.relative_to(
root_path = root_dir.path.relative_to(
html_path.parent, walk_up=True
) / "static"
)
html_path.parent.mkdir(exist_ok=True)
prev_image = None
@ -189,7 +189,7 @@ def generate_html(config: Config, root_dir: ImageDirectory) -> None:
with html_path.open("w") as f:
f.write(
photo_tmpl.render(
static_dir=static_path,
root_path=root_path,
image_path=image_path,
prev_image=prev_image,
next_image=next_image,

View file

@ -10,7 +10,6 @@
{% endif %}
{% if album_dir.children %}
<h1>Albums</h1>
<ul id="album-children">
{% for child in album_dir.children %}
<li class="album">
@ -23,7 +22,6 @@
{% endif %}
{% if album_dir.images %}
<h1>Photos</h1>
<div id="album-photos">
{% for image in album_dir.images %}
<div class="thumbnail">

View file

@ -4,9 +4,14 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Photos</title>
<link rel="stylesheet" href="{{ static_dir }}/index.css" type="text/css">
<link rel="stylesheet" href="{{ root_path }}/static/index.css" type="text/css">
</head>
<body>
<div id="header">
<a href="{{ root_path }}">
<h1>My Photos</h1>
</a>
</div>
<div id="content">
{% block content %}
{% endblock %}

View file

@ -1,4 +1,19 @@
body {
margin: 0;
}
#header {
background-color: #eee;
}
#header * {
margin-top: 0;
text-decoration: inherit;
color: inherit;
}
#header h1 {
padding: 0.5em;
}
#content {