Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Canonical URLs and template tweaks

Russ Garrett0f98a2070ba1
diff --git a/main.py b/main.py
index 0948f85..2807977 100644
--- a/main.py
+++ b/main.py
@@ -108,7 +108,8 @@ async def country(request, country):
"country": country["union"],
"plant_stats": plant_stats,
"plant_source_stats": plant_source_stats,
- "power_lines": power_lines
+ "power_lines": power_lines,
+ "canonical": request.url_for("country", country=country['union'])
},
)
@@ -147,6 +148,8 @@ async def plants_country(request, country):
"plants": plants,
"country": country["union"],
"source": source,
+ # Canonical URL for all plants without the source filter, to avoid confusing Google.
+ "canonical": request.url_for("plants_country", country=country['union'])
},
)
diff --git a/templates/_base.html b/templates/_base.html
index 24a32ab..04c1936 100644
--- a/templates/_base.html
+++ b/templates/_base.html
@@ -4,31 +4,34 @@
<meta charset="utf-8">
<title>{% block title %}{% endblock %}{% if self.title() %} - {% endif %}Open Infrastructure Map</title>
<link rel="stylesheet" href="/static/main.css">
-{% if self.description() %}
+{%- if self.description() %}
<meta name="description" content="{% block description %}{% endblock %}">
<meta property="og:description" content="{{self.description()}}">
-{% endif %}
- <meta name="twitter:card" content="summary" />
- <meta name="twitter:site" content="@openinframap" />
- <meta name="twitter:creator" content="@russss" />
- <meta property="og:title" content="Open Infrastructure Map" />
+{%- endif %}
+ <meta name="twitter:card" content="summary">
+ <meta name="twitter:site" content="@openinframap">
+ <meta name="twitter:creator" content="@russss">
+ <meta property="og:title" content="Open Infrastructure Map">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+{%- if canonical %}
+ <link rel="canonical" href="{{canonical}}">
+{%- endif %}
</head>
<body>
<header>
<h1><a href="{{url_for('main')}}">OpenInfraMap</a>
- {% if breadcrumbs %}
+ {%- if breadcrumbs -%}
<h2>
- {% for name, url in breadcrumbs %}
- &rang;
- {% if url %}
+ {%- for name, url in breadcrumbs -%}
+ &nbsp;&rang;&nbsp;
+ {%- if url -%}
<a href="{{url}}">{{name}}</a>
- {% else %}
+ {%- else -%}
{{name}}
- {% endif %}
- {% endfor %}
+ {%- endif -%}
+ {%- endfor -%}
</h2>
- {% endif %}
+ {%- endif %}
</header>
<div id="content">
{% block content %}{% endblock %}
diff --git a/templates/country.html b/templates/country.html
index 7a49bcf..c76b3ec 100644
--- a/templates/country.html
+++ b/templates/country.html
@@ -7,10 +7,10 @@ Statistics on the electricity network in {{country|country_name}} from OpenStree
{%- endblock %}
{% block content -%}
<p><strong>{{country|country_name(true)}}</strong> has
- {{plant_stats.count}} power plant{%if plant_stats.count != 1 %}s{% endif %}
- {% if plant_stats.output %}
+ {{plant_stats.count}} power plant{%if plant_stats.count != 1 %}s{% endif -%}
+ {%- if plant_stats.output %}
totalling {{plant_stats.output|power}}
- {% endif %}
+ {%- endif %}
and {{power_lines.total|distance}} of power lines mapped on OpenStreetMap.</p>
<div class="table-wrapper">