From 466ce50e3ce252afc4628a6b748ddefed7605808 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Mon, 29 May 2023 18:35:10 -0700 Subject: [PATCH] Add home page with source list --- intake/app.py | 15 ++++++++++- intake/templates/home.jinja2 | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 intake/templates/home.jinja2 diff --git a/intake/app.py b/intake/app.py index eb2944e..12ee40f 100644 --- a/intake/app.py +++ b/intake/app.py @@ -35,7 +35,20 @@ def datetimeformat(value): @app.route("/") 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/") diff --git a/intake/templates/home.jinja2 b/intake/templates/home.jinja2 new file mode 100644 index 0000000..297c60f --- /dev/null +++ b/intake/templates/home.jinja2 @@ -0,0 +1,50 @@ + + + +Intake + + + + +
+
+
+Sources +{% if not sources %} +

No sources found.

+{% else %} +{% for source in sources %} +

{{ source.source_name|safe }}

+{% endfor %} +{% endif %} +
+
+
+ +