From 98000302016e5cd11ab348233599c8b78bc57a1c Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 3 Jan 2024 09:13:58 +0000 Subject: [PATCH] Split space launches into separate page Closes: #93 --- templates/index.html | 46 ----------------------------------- templates/launches.html | 53 +++++++++++++++++++++++++++++++++++++++++ templates/navbar.html | 1 + web_view.py | 12 ++++++++++ 4 files changed, 66 insertions(+), 46 deletions(-) create mode 100644 templates/launches.html diff --git a/templates/index.html b/templates/index.html index fd66154..5dcf8c3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -188,52 +188,6 @@ {% endif %} {% endfor %} -

Space launches

- {% for launch in rockets %} -
-
{{ launch.t0_date }} - -
- {% if launch.t0_time %} - {{ launch.t0_time }}{% endif %} - {{ launch.net_precision }} -
-
- launch status: - {{ launch.status.abbrev }} -
-
{{ launch.rocket }} - – - {{launch.mission.name }} - – - - {% if launch.launch_provider_abbrev %} - {{ launch.launch_provider_abbrev }} - {% else %} - {{ launch.launch_provider }} - {% endif %} - ({{ launch.launch_provider_type }}) - — - {{ launch.orbit.name }} ({{ launch.orbit.abbrev }}) -
- {% if launch.pad_wikipedia_url %} - {{ launch.pad_name }} - {% else %} - {{ launch.pad_name }} {% if launch.pad_name != "Unknown Pad" %}(no Wikipedia article){% endif %} - {% endif %} - — {{ launch.location }}
- - {% if launch.mission %} - {% for line in launch.mission.description.splitlines() %} -

{{ line }}

- {% endfor %} - {% else %} -

No description.

- {% endif %} - -
-
- {% endfor %} diff --git a/templates/launches.html b/templates/launches.html new file mode 100644 index 0000000..c048d5e --- /dev/null +++ b/templates/launches.html @@ -0,0 +1,53 @@ +{% extends "base.html" %} + +{% block content %} +
+

Space launches

+ + {% for launch in rockets %} +
+
{{ launch.t0_date }} + +
+ {% if launch.t0_time %} + {{ launch.t0_time }}{% endif %} + {{ launch.net_precision }} +
+
+ launch status: + {{ launch.status.abbrev }} +
+
{{ launch.rocket }} + – + {{launch.mission.name }} + – + + {% if launch.launch_provider_abbrev %} + {{ launch.launch_provider_abbrev }} + {% else %} + {{ launch.launch_provider }} + {% endif %} + ({{ launch.launch_provider_type }}) + — + {{ launch.orbit.name }} ({{ launch.orbit.abbrev }}) +
+ {% if launch.pad_wikipedia_url %} + {{ launch.pad_name }} + {% else %} + {{ launch.pad_name }} {% if launch.pad_name != "Unknown Pad" %}(no Wikipedia article){% endif %} + {% endif %} + — {{ launch.location }}
+ + {% if launch.mission %} + {% for line in launch.mission.description.splitlines() %} +

{{ line }}

+ {% endfor %} + {% else %} +

No description.

+ {% endif %} + +
+
+ {% endfor %} +
+{% endblock %} diff --git a/templates/navbar.html b/templates/navbar.html index 2f7c4b9..444fa14 100644 --- a/templates/navbar.html +++ b/templates/navbar.html @@ -6,6 +6,7 @@ {"endpoint": "travel_list", "label": "Travel" }, {"endpoint": "accommodation_list", "label": "Accommodation" }, {"endpoint": "gaps_page", "label": "Gaps" }, + {"endpoint": "launch_list", "label": "Space launches" }, ] %} diff --git a/web_view.py b/web_view.py index 86db0a2..0a31d2e 100755 --- a/web_view.py +++ b/web_view.py @@ -16,6 +16,7 @@ import yaml import agenda.data import agenda.error_mail +import agenda.thespacedevs import agenda.travel app = flask.Flask(__name__) @@ -61,6 +62,17 @@ async def index() -> str: return flask.render_template("index.html", today=now.date(), **data) +@app.route("/launches") +async def launch_list() -> str: + """Web page showing List of space launches.""" + now = datetime.now() + data_dir = app.config["DATA_DIR"] + rocket_dir = os.path.join(data_dir, "thespacedevs") + rockets = await agenda.thespacedevs.get_launches(rocket_dir, limit=100) + + return flask.render_template("launches.html", rockets=rockets, now=now) + + @app.route("/gaps") async def gaps_page() -> str: """List of available gaps."""