Split space launches into separate page

Closes: #93
This commit is contained in:
Edward Betts 2024-01-03 09:13:58 +00:00
parent 2b3e4f8d72
commit 9800030201
4 changed files with 66 additions and 46 deletions

View file

@ -188,52 +188,6 @@
{% endif %}
{% endfor %}
<h3>Space launches</h3>
{% for launch in rockets %}
<div class="row">
<div class="col-md-1 text-nowrap text-md-end">{{ launch.t0_date }}
<br class="d-none d-md-block"/>
{% if launch.t0_time %}
{{ launch.t0_time }}{% endif %}
{{ launch.net_precision }}
</div>
<div class="col-md-1 text-md-nowrap">
<span class="d-md-none">launch status:</span>
<abbr title="{{ launch.status.name }}">{{ launch.status.abbrev }}</abbr>
</div>
<div class="col">{{ launch.rocket }}
&ndash;
<strong>{{launch.mission.name }}</strong>
&ndash;
{% if launch.launch_provider_abbrev %}
<abbr title="{{ launch.launch_provider }}">{{ launch.launch_provider_abbrev }}</abbr>
{% else %}
{{ launch.launch_provider }}
{% endif %}
({{ launch.launch_provider_type }})
&mdash;
{{ launch.orbit.name }} ({{ launch.orbit.abbrev }})
<br/>
{% if launch.pad_wikipedia_url %}
<a href="{{ launch.pad_wikipedia_url }}">{{ launch.pad_name }}</a>
{% else %}
{{ launch.pad_name }} {% if launch.pad_name != "Unknown Pad" %}(no Wikipedia article){% endif %}
{% endif %}
&mdash; {{ launch.location }}<br/>
{% if launch.mission %}
{% for line in launch.mission.description.splitlines() %}
<p>{{ line }}</p>
{% endfor %}
{% else %}
<p>No description.</p>
{% endif %}
</div>
</div>
{% endfor %}
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</body>

53
templates/launches.html Normal file
View file

@ -0,0 +1,53 @@
{% extends "base.html" %}
{% block content %}
<div class="container-fluid mt-2">
<h1>Space launches</h1>
{% for launch in rockets %}
<div class="row">
<div class="col-md-1 text-nowrap text-md-end">{{ launch.t0_date }}
<br class="d-none d-md-block"/>
{% if launch.t0_time %}
{{ launch.t0_time }}{% endif %}
{{ launch.net_precision }}
</div>
<div class="col-md-1 text-md-nowrap">
<span class="d-md-none">launch status:</span>
<abbr title="{{ launch.status.name }}">{{ launch.status.abbrev }}</abbr>
</div>
<div class="col">{{ launch.rocket }}
&ndash;
<strong>{{launch.mission.name }}</strong>
&ndash;
{% if launch.launch_provider_abbrev %}
<abbr title="{{ launch.launch_provider }}">{{ launch.launch_provider_abbrev }}</abbr>
{% else %}
{{ launch.launch_provider }}
{% endif %}
({{ launch.launch_provider_type }})
&mdash;
{{ launch.orbit.name }} ({{ launch.orbit.abbrev }})
<br/>
{% if launch.pad_wikipedia_url %}
<a href="{{ launch.pad_wikipedia_url }}">{{ launch.pad_name }}</a>
{% else %}
{{ launch.pad_name }} {% if launch.pad_name != "Unknown Pad" %}(no Wikipedia article){% endif %}
{% endif %}
&mdash; {{ launch.location }}<br/>
{% if launch.mission %}
{% for line in launch.mission.description.splitlines() %}
<p>{{ line }}</p>
{% endfor %}
{% else %}
<p>No description.</p>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endblock %}

View file

@ -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" },
] %}

View file

@ -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."""