Open Infrastructure Map, a view of infrastructure data in OpenStreetMap
Improve stats display on mobile
Russ Garrett9ac9ae56131c
diff --git a/web-backend/data.py b/web-backend/data.pyindex 015f281..6c7c4c9 100644--- a/web-backend/data.py+++ b/web-backend/data.py@@ -21,7 +21,7 @@ async def get_countries():async def get_plant(plant_id, country_gid):res = await database.fetch_one(- """SELECT osm_id, ST_GeometryType(geometry) AS geom_type, name, source,+ """SELECT osm_id, ST_GeometryType(geometry) AS geom_type, name, tags->'name:en' AS name_en, source,convert_power(tags->'plant:output:electricity') AS output,hstore_to_json(tags) AS tagsFROM power_plant, countries.country_eezdiff --git a/web-backend/static/main.css b/web-backend/static/main.cssindex a261b60..67a0eda 100644--- a/web-backend/static/main.css+++ b/web-backend/static/main.css@@ -1,4 +1,5 @@-html, body {+html,+body {margin: 0;padding: 0;border: 0;@@ -7,13 +8,14 @@ html, body {}body {- font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;color: #333;display: flex;flex-direction: column;}-a, a:visited {+a,+a:visited {color: #333;}@@ -24,13 +26,15 @@ header {flex: 0 0 auto;}-h1, h2 {+h1,+h2 {display: inline;margin: 0;font-size: 20px;}-h1 a, h2 a {+h1 a,+h2 a {text-decoration: none;color: inherit;}@@ -54,7 +58,9 @@ footer {background-color: #fafafa;}-footer, footer a, footer a:visited {+footer,+footer a,+footer a:visited {color: #666;}@@ -96,6 +102,7 @@ caption {font-weight: bold;font-size: 1.1em;padding-bottom: 3px;+ width: 100%;}thead {@@ -111,7 +118,8 @@ tfoot tr {font-weight: bold;}-th, td {+th,+td {padding: 4px;}@@ -126,10 +134,67 @@ figcaption {padding: 2px 5px;}-figcaption a, figcaption a:visited {+figcaption a,+figcaption a:visited {color: #666;}figure.plant_image {- float:right;+ float: right;+}++/* Responsive tables on small screens */++@media only screen and (max-width: 760px),+ (min-device-width: 768px) and (max-device-width: 1024px) {+ table.responsive,+ table.responsive thead,+ table.responsive tbody,+ table.responsive th,+ table.responsive td,+ table.responsive tr,+ table.responsive caption {+ display: block;+ clear: both;+ }++ table.responsive tr {+ padding-bottom: 1em;+ }++ table.responsive td.row-name {+ text-align: center;+ font-weight: bold;+ }++ table.responsive td.row-subhead {+ text-align: center;+ }++ table.responsive thead tr {+ position: absolute;+ top: -9999px;+ left: -9999px;+ }++ table.responsive td {+ clear: both;+ }++ table.responsive td:empty {+ display: none;+ }++ table.responsive td::before {+ content: attr(data-label);+ float: left;+ font-weight: bold;+ padding-right: 10px;+ }++ figure {+ float: none !important;+ display: inline-block;+ margin: auto;+ }}diff --git a/web-backend/templates/plant_detail.html b/web-backend/templates/plant_detail.htmlindex 507ce7f..8dc5758 100644--- a/web-backend/templates/plant_detail.html+++ b/web-backend/templates/plant_detail.html@@ -14,7 +14,11 @@{% block description -%}{%- endblock %}{% block content -%}- <p><strong>{{name}}</strong> is a {{plant['source'].split(';')|join(' and ')}}+ <p><strong>{{name}}</strong>+ {% if plant['name_en'] %}+ ({{plant['name_en']}})+ {% endif %}+ is a {{plant['source'].split(';')|join(' and ')}}power plant in {{country|country_name()}}{%- if plant['output']%} with a total output of {{plant['output']|power}}{% endif %}.</p>diff --git a/web-backend/templates/plants_country.html b/web-backend/templates/plants_country.htmlindex 2b93e1e..ae3af5f 100644--- a/web-backend/templates/plants_country.html+++ b/web-backend/templates/plants_country.html@@ -22,7 +22,7 @@mapped in {{country|country_name}} on OpenStreetMap.</p>{% else %}- <table class="plants-table table-full-width">+ <table class="plants-table table-full-width responsive"><caption>All {{plants|length}} {% if pretty_source %}{{pretty_source}} {% endif %}power plants{% if min_output %}with output greater than {{min_output|power}}{% endif %}@@ -49,21 +49,21 @@<tbody>{% for plant in plants -%}<tr>- <td><a href="{{url_for('plant_detail', country=country, id=plant.osm_id)}}">+ <td class="row-name"><a href="{{url_for('plant_detail', country=country, id=plant.osm_id)}}">{{plant.name or '[unnamed]'}}</a></td>{% if english_name %}- <td>{{plant.name_en or ''}}</td>+ <td class="row-subhead">{{plant.name_en or ''}}</td>{% endif -%}- <td>{{plant.operator or ''}}</td>- <td>{{plant.output|power}}</td>+ <td data-label="Operator">{{plant.operator or ''}}</td>+ <td data-label="Power">{{plant.output|power}}</td>{%- if not pretty_source %}- <td>{{plant.source}}</td>+ <td data-label="Source">{{plant.source}}</td>{% endif -%}- <td>{{plant.method or ''}}</td>+ <td data-label="Method">{{plant.method or ''}}</td>{%- if construction %}- <td>{{plant.start_date or ''}}</td>+ <td data-label="Start date">{{plant.start_date or ''}}</td>{% endif -%}- <td>+ <td data-label="Wikidata">{%- if plant.wikidata -%}<a href="https://www.wikidata.org/wiki/{{plant.wikidata}}" target="_blank">{{plant.wikidata}}</a>{%- endif -%}