Add home page with source list

This commit is contained in:
Tim Van Baak 2023-05-29 18:35:10 -07:00
parent bb1bdee4c9
commit 466ce50e3c
2 changed files with 64 additions and 1 deletions

View File

@ -35,7 +35,20 @@ def datetimeformat(value):
@app.route("/") @app.route("/")
def root(): def root():
return "hello, world" """
Navigation home page.
"""
data_path = intake_data_dir()
sources = []
for child in data_path.iterdir():
if (child / "intake.json").exists():
sources.append(LocalSource(data_path, child.name))
sources.sort(key=lambda s: s.source_name)
return render_template(
"home.jinja2",
sources=sources,
)
@app.route("/source/<string:source_name>") @app.route("/source/<string:source_name>")

View File

@ -0,0 +1,50 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Intake</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS41ZEdYUgAAAGFJREFUOE+lkFEKwDAIxXrzXXB3ckMm9EnAV/YRCxFCcUXEL3Jc77NDjpDA/VGL3RFWYEICfeGC8oQc9IPuCAnQDcoRVmBCAn3hgvKEHPSD7ggJ0A3KEVZgQgJ94YLSJ9YDUzNGDXGZ/JEAAAAASUVORK5CYII=">
<style>
div#wrapper {
max-width: 700px;
margin: 0 auto;
}
.readable-item {
border: 1px solid black; border-radius: 6px;
padding: 5px;
margin-bottom: 20px;
word-break: break-word;
}
.item-title {
font-size: 1.4em;
}
.readable-item img {
max-width: 100%;
}
button, summary {
cursor: pointer;
}
summary {
display: block;
}
summary:focus {
outline: 1px dotted gray;
}
</style>
</head>
<body>
<div id="wrapper">
<div class="readable-item">
<details open>
<summary><span class="item-title">Sources</span></summary>
{% if not sources %}
<p>No sources found.</p>
{% else %}
{% for source in sources %}
<p><a href="{{ url_for('source_feed', source_name=source.source_name) }}">{{ source.source_name|safe }}</a></p>
{% endfor %}
{% endif %}
</details>
</div>
</div>
</body>
</html>