Show more detail on space launch page
This commit is contained in:
parent
e475f98dd6
commit
e16e04ab51
|
@ -22,12 +22,21 @@ def format_list_with_ampersand(items: list[str]) -> str:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
ESA = "AUT,BEL,CZE,DNK,FIN,FRA,DEU,GRC,IRE,ITA,LUZ,NLD,NOR,POL,PRT,ROU,ESP,SWE,CHE,GBR"
|
||||||
|
|
||||||
|
|
||||||
def get_country(alpha_2: str) -> pycountry.db.Country | None:
|
def get_country(alpha_2: str) -> pycountry.db.Country | None:
|
||||||
"""Lookup country by alpha-2 country code."""
|
"""Lookup country by alpha-2 country code."""
|
||||||
|
if alpha_2 == ESA:
|
||||||
|
return pycountry.db.Country(flag="🇪🇺", name="ESA")
|
||||||
if not alpha_2:
|
if not alpha_2:
|
||||||
return None
|
return None
|
||||||
if alpha_2 == "xk":
|
if alpha_2 == "xk":
|
||||||
return pycountry.db.Country(flag="\U0001F1FD\U0001F1F0", name="Kosovo")
|
return pycountry.db.Country(flag="\U0001F1FD\U0001F1F0", name="Kosovo")
|
||||||
|
|
||||||
country: pycountry.db.Country = pycountry.countries.get(alpha_2=alpha_2.upper())
|
country: pycountry.db.Country
|
||||||
|
if len(alpha_2) == 2:
|
||||||
|
country = pycountry.countries.get(alpha_2=alpha_2.upper())
|
||||||
|
elif len(alpha_2) == 3:
|
||||||
|
country = pycountry.countries.get(alpha_3=alpha_2.upper())
|
||||||
return country
|
return country
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<h1>Space launches</h1>
|
<h1>Space launches</h1>
|
||||||
|
|
||||||
{% for launch in rockets %}
|
{% for launch in rockets %}
|
||||||
|
{% set country = get_country(launch.country_code) %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-1 text-nowrap text-md-end">{{ launch.t0_date }}
|
<div class="col-md-1 text-nowrap text-md-end">{{ launch.t0_date }}
|
||||||
|
|
||||||
|
@ -17,7 +18,10 @@
|
||||||
<span class="d-md-none">launch status:</span>
|
<span class="d-md-none">launch status:</span>
|
||||||
<abbr title="{{ launch.status.name }}">{{ launch.status.abbrev }}</abbr>
|
<abbr title="{{ launch.status.name }}">{{ launch.status.abbrev }}</abbr>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">{{ launch.rocket }}
|
<div class="col">
|
||||||
|
<div>
|
||||||
|
{{ country.flag }}
|
||||||
|
{{ launch.rocket }}
|
||||||
–
|
–
|
||||||
<strong>{{launch.mission.name }}</strong>
|
<strong>{{launch.mission.name }}</strong>
|
||||||
–
|
–
|
||||||
|
@ -30,14 +34,29 @@
|
||||||
({{ launch.launch_provider_type }})
|
({{ launch.launch_provider_type }})
|
||||||
—
|
—
|
||||||
{{ launch.orbit.name }} ({{ launch.orbit.abbrev }})
|
{{ launch.orbit.name }} ({{ launch.orbit.abbrev }})
|
||||||
<br/>
|
—
|
||||||
{% if launch.pad_wikipedia_url %}
|
{{ launch.mission.type }}
|
||||||
<a href="{{ launch.pad_wikipedia_url }}">{{ launch.pad_name }}</a>
|
</div>
|
||||||
{% else %}
|
<div>
|
||||||
{{ launch.pad_name }} {% if launch.pad_name != "Unknown Pad" %}(no Wikipedia article){% endif %}
|
{% 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 %}
|
||||||
|
— {{ launch.location }}
|
||||||
|
</div>
|
||||||
|
{% if launch.mission.agencies | count %}
|
||||||
|
<div>
|
||||||
|
agencies:
|
||||||
|
{% for agency in launch.mission.agencies %}
|
||||||
|
{%- if not loop.first %}, {% endif %}
|
||||||
|
<a href="{{ agency.wiki_url }}">{{agency.name }}</a>
|
||||||
|
{{ get_country(agency.country_code).flag }}
|
||||||
|
({{ agency.type }}) {# <img src="{{ agency.logo_url }}"/> #}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
— {{ launch.location }}<br/>
|
<div>
|
||||||
|
|
||||||
{% if launch.mission %}
|
{% if launch.mission %}
|
||||||
{% for line in launch.mission.description.splitlines() %}
|
{% for line in launch.mission.description.splitlines() %}
|
||||||
<p>{{ line }}</p>
|
<p>{{ line }}</p>
|
||||||
|
@ -45,7 +64,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No description.</p>
|
<p>No description.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -74,7 +74,9 @@ async def launch_list() -> str:
|
||||||
rocket_dir = os.path.join(data_dir, "thespacedevs")
|
rocket_dir = os.path.join(data_dir, "thespacedevs")
|
||||||
rockets = await agenda.thespacedevs.get_launches(rocket_dir, limit=100)
|
rockets = await agenda.thespacedevs.get_launches(rocket_dir, limit=100)
|
||||||
|
|
||||||
return flask.render_template("launches.html", rockets=rockets, now=now)
|
return flask.render_template(
|
||||||
|
"launches.html", rockets=rockets, now=now, get_country=agenda.get_country
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/gaps")
|
@app.route("/gaps")
|
||||||
|
|
Loading…
Reference in a new issue