Skip to content

Commit 6705a7c

Browse files
Merge pull request #35 from developmentseed/update-collection-page
Update collection page
2 parents 7e004e7 + 777ae2c commit 6705a7c

File tree

4 files changed

+63
-29
lines changed

4 files changed

+63
-29
lines changed
Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
{% include "header.html" %}
1+
{% extends "base.html" %}
22
{% if params %}
33
{% set urlq = url + '?' + params + '&' %}
44
{% else %}
55
{% set urlq = url + '?' %}
66
{% endif %}
77

8+
{% block content %}
89
<nav aria-label="breadcrumb">
910
<ol class="breadcrumb bg-light">
1011
{% for crumb in crumbs %} {% if not loop.last %}
@@ -21,18 +22,24 @@
2122
</ol>
2223
</nav>
2324

24-
<h1>Collection: {{ response.title or response.id }}</h1>
25+
<h1 class="my-4">
26+
<span class="d-block text-uppercase text-muted h6 mb-0">Collection:</span>
27+
{{ response.title or response.id }}
28+
</h1>
2529

2630
<div class="row">
27-
<div class="col-sm">
28-
<p>{{ response.description or response.title or response.id }}</p>
29-
{% if "keywords" in response and length(response.keywords) > 0 %}
30-
<div id="keywords">
31-
<p>
31+
<div class="col-md-7">
32+
{% if response.description %}
33+
<p>{{ response.description }}</p>
34+
{% endif %}
35+
{% if "keywords" in response and response.keywords|length > 0 %}
36+
<div class="d-flex align-items-center mb-4">
37+
{% include "icons/tag.html" %}
38+
<ul class="mb-0 pl-2">
3239
{% for keyword in response.keywords %}
33-
<span class="badge badge-secondary">{{ keyword }}</span>
40+
<li class="badge badge-secondary">{{ keyword }}</li>
3441
{% endfor %}
35-
</p>
42+
</lul>
3643
</div>
3744
{% endif %}
3845

@@ -43,40 +50,64 @@ <h2>Links</h2>
4350
{% endfor %}
4451
</ul>
4552
</div>
46-
<div class="col-sm">
53+
<div class="col-md-5">
54+
{% if response.license %}
55+
<div class="d-flex align-items-center mb-2">
56+
{% include "icons/license.html" %}
57+
<p class="mb-0 pl-2">{{ response.license }}</p>
58+
</div>
59+
{% endif %}
60+
{% if response.extent and response.extent.temporal %}
61+
<div class="d-flex align-items-center mb-2">
62+
{% include "icons/clock.html" %}
63+
<p class="mb-0 pl-2">{{ response.extent.temporal.interval.0.0 or "..." }} — {{ response.extent.temporal.interval.0.1 or "..." }}</p>
64+
</div>
65+
{% endif %}
66+
{% if response.extent and response.extent.spatial %}
4767
<div id="map" class="rounded" style="width: 100%; height: 400px">
4868
Loading...
4969
</div>
70+
{% endif %}
5071
</div>
5172
</div>
5273

74+
{% if response.extent and response.extent.spatial %}
5375
<script>
54-
$(function() {
55-
var collection = {{ response|tojson }};
56-
if (collection.extent && collection.extent.spatial){
57-
var bbox = collection.extent.spatial.bbox[0]
58-
var bbox_polygon = L.polygon([
76+
window.addEventListener("load", function() {
77+
const collection = {{ response|tojson }};
78+
var map = L.map('map').setView([0, 0], 1);
79+
map.addLayer(new L.TileLayer(
80+
'https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
81+
maxZoom: 18,
82+
attribution: 'Map data &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
83+
}
84+
));
85+
86+
for (let i = 0, len = collection.extent.spatial.bbox.length; i < len; i++) {
87+
const options = i === 0 ? {
88+
fill: false,
89+
weight: 2
90+
} : {
91+
color: "red",
92+
fill: false,
93+
dashArray: 2,
94+
weight: 1
95+
};
96+
const bbox = collection.extent.spatial.bbox[i];
97+
const bbox_polygon = L.polygon([
5998
[bbox[1], bbox[0]],
6099
[bbox[1], bbox[2]],
61100
[bbox[3], bbox[2]],
62101
[bbox[3], bbox[0]]
63-
]);
102+
], options);
64103

65-
var map = L.map('map').setView([0, 0], 1);
66-
map.addLayer(new L.TileLayer(
67-
'https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
68-
maxZoom: 18,
69-
attribution: 'Map data &copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
70-
}
71-
));
72104

73105
map.addLayer(bbox_polygon);
74-
map.fitBounds(bbox_polygon.getBounds());
75-
} else {
76-
document.getElementById("map").style.display = "none";
106+
if (i === 0) {
107+
map.fitBounds(bbox_polygon.getBounds());
108+
}
77109
}
78-
79110
});
80111
</script>
81-
82-
{% include "footer.html" %}
112+
{% endif %}
113+
{% endblock %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 -960 960 960" width="18px" fill="#1f1f1f"><path d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"/></svg>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 -960 960 960" width="18px" fill="#1f1f1f"><path d="M480-80q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 85-29 163.5T688-214L560-342q-18 11-38.5 16.5T480-320q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 22-5.5 42.5T618-398l60 60q20-41 31-86t11-92v-189l-240-90-240 90v189q0 121 68 220t172 132q26-8 49.5-20.5T576-214l56 56q-33 27-71.5 47T480-80Zm0-320q33 0 56.5-23.5T560-480q0-33-23.5-56.5T480-560q-33 0-56.5 23.5T400-480q0 33 23.5 56.5T480-400Zm8-77Z"/></svg>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 -960 960 960" width="18px" fill="#1f1f1f"><path d="M856-390 570-104q-12 12-27 18t-30 6q-15 0-30-6t-27-18L103-457q-11-11-17-25.5T80-513v-287q0-33 23.5-56.5T160-880h287q16 0 31 6.5t26 17.5l352 353q12 12 17.5 27t5.5 30q0 15-5.5 29.5T856-390ZM513-160l286-286-353-354H160v286l353 354ZM260-640q25 0 42.5-17.5T320-700q0-25-17.5-42.5T260-760q-25 0-42.5 17.5T200-700q0 25 17.5 42.5T260-640Zm220 160Z"/></svg>

0 commit comments

Comments
 (0)