picture.html
HTML document, ASCII text
1
{% extends "default.html" %}
2
{% import "small-annotation-display.html" as annotation_display %}
3
4
{% block nav_title %}{{ resource.title }}{% endblock %}
5
{% block title %}Picture {{ resource.title }} | {{ site_name }}{% endblock %}
6
{% macro shape_label(x, y, text) %}
7
{% if text %}
8
<a class="shape-label" style="left: {{ x * 100 }}%; top: {{ y * 100 }}%" href="/object/{{ text | urlencode }}">
9
{{ text }}
10
</a>
11
{% endif %}
12
{% endmacro %}
13
{% block content %}
14
<div id="picture-view">
15
<x-frame id="picture-actions">
16
<menu class="action-list">
17
<li><a href="/raw/picture/{{ resource.id }}" download="GigadataPicture_{{ resource.id }}{{ file_extension }}">
18
<iconify-icon icon="mdi:download"></iconify-icon>Download
19
</a></li>
20
<li><a href="/picture/{{ resource.id }}/get-annotations">
21
<iconify-icon icon="ic:baseline-account-tree"></iconify-icon>JSON annotations
22
</a></li>
23
<li><a href="/raw/picture/{{ resource.id }}" target="_blank">
24
<iconify-icon icon="mdi:image"></iconify-icon>View separately
25
</a></li>
26
{% if have_permission %}
27
<li><a href="/picture/{{ resource.id }}/annotate">
28
<iconify-icon icon="mdi:vector-point-select"></iconify-icon>Annotate
29
</a></li>
30
{% endif %}
31
{% if resource.origin_url %}
32
<li><a href="{{ resource.origin_url }}">
33
<iconify-icon icon="mdi:web"></iconify-icon>Original source
34
</a></li>
35
{% endif %}
36
{% if resource.replaced_by %}
37
<li><a href="/picture/{{ resource.replaced_by.id }}">
38
<iconify-icon icon="mdi:new-releases"></iconify-icon>Replacement
39
</a></li>
40
{% endif %}
41
{% if resource.replaces %}
42
<li><a href="/picture/{{ resource.replaces.id }}">
43
<iconify-icon icon="mdi:archive"></iconify-icon>Old version
44
</a></li>
45
{% endif %}
46
{% if current_user %}
47
<li><a href="/picture/{{ resource.id }}/copy">
48
<iconify-icon icon="mdi:content-copy"></iconify-icon>Copy
49
</a></li>
50
{% endif %}
51
{% if have_permission %}
52
<li><a href="/picture/{{ resource.id }}/put-annotations-form">
53
<iconify-icon icon="mdi:file-edit"></iconify-icon>Submit JSON annotations
54
</a></li>
55
<li><a href="/picture/{{ resource.id }}/edit-metadata">
56
<iconify-icon icon="mdi:edit"></iconify-icon>Edit metadata
57
</a></li>
58
{% endif %}
59
{% if have_permission %}
60
<li><details>
61
<summary>
62
<iconify-icon icon="mdi:delete"></iconify-icon>Delete
63
</summary>
64
<x-buttonbox>
65
<a href="/picture/{{ resource.id }}/delete" class="button button-danger">Confirm deletion</a>
66
</x-buttonbox>
67
</details></li>
68
{% endif %}
69
</menu>
70
</x-frame>
71
<x-frame style="--width: 768px">
72
<h1>{{ resource.title }}</h1>
73
<p>by <a href="/profile/{{ resource.author.username }}">{{ resource.author.formatted_name }}</a></p>
74
<p>{{ resource.description }}</p>
75
{% if resource.replaced_by %}
76
<div class="warning">
77
<h2>Obsolete</h2>
78
<p>
79
This picture has been replaced by <a href="/picture/{{ resource.replaced_by.id }}">{{ resource.replaced_by.title }}</a>.
80
</p>
81
{% if have_permission %}
82
<form method="POST" action="/picture/{{ resource.id }}/remove-replacement">
83
<button class="button-flat button-neutral" type="submit">Remove replacement</button>
84
</form>
85
{% endif %}
86
</div>
87
{% endif %}
88
<x-vbox>
89
<div id="annotation-zone">
90
<img id="annotation-image" src="/raw/picture/{{ resource.id }}" alt="{{ resource.title }}">
91
{% for region in resource.regions %}
92
{% if region.json.type == "bbox" %}
93
<svg class="shape-container-viewonly" viewBox="0 0 1 1" preserveAspectRatio="none">
94
<rect x="{{ region.json.shape.x }}"
95
y="{{ region.json.shape.y }}"
96
width="{{ region.json.shape.w }}"
97
height="{{ region.json.shape.h }}"
98
fill="none" class="shape-bbox shape"
99
></rect>
100
{% set centre_x = region.json.shape.x + region.json.shape.w / 2 %}
101
{% set centre_y = region.json.shape.y + region.json.shape.h / 2 %}
102
</svg>
103
{% elif region.json.type == "polygon" %}
104
<svg class="shape-container-viewonly" viewBox="0 0 1 1" preserveAspectRatio="none">
105
<polygon points="{% for point in region.json.shape %}{{ point.x }},{{ point.y }} {% endfor %}" fill="none" class="shape-polygon shape"></polygon>
106
{% set top = region.json.shape | sort(attribute='y') | last %}
107
{% set left = region.json.shape | sort(attribute='x') | first %}
108
{% set bottom = region.json.shape | sort(attribute='y') | first %}
109
{% set right = region.json.shape | sort(attribute='x') | last %}
110
{% set centre_x = (left.x + right.x) / 2 %}
111
{% set centre_y = (top.y + bottom.y) / 2 %}
112
</svg>
113
{% elif region.json.type == "polyline" %}
114
<svg class="shape-container-viewonly" viewBox="0 0 1 1" preserveAspectRatio="none">
115
<polyline points="{% for point in region.json.shape %}{{ point.x }},{{ point.y }} {% endfor %}" fill="none" class="shape-polyline shape"></polyline>
116
{# Median point #}
117
{% set centre_x = region.json.shape | map(attribute="x") | median %}
118
{% set centre_y = region.json.shape | map(attribute="y") | median %}
119
</svg>
120
{% elif region.json.type == "point" %}
121
<svg class="shape-container-viewonly" viewBox="0 0 1 1" preserveAspectRatio="none">
122
<circle cx="{{ region.json.shape.x }}" cy="{{ region.json.shape.y }}" r="0" fill="none" class="shape-point shape"></circle>
123
{% set centre_x = region.json.shape.x %}
124
{% set centre_y = region.json.shape.y %}
125
</svg>
126
{% endif %}
127
{{ shape_label(centre_x, centre_y, region.object_id) }}
128
{% endfor %}
129
</div>
130
<x-buttonbox id="annotation-view-controls">
131
<label>
132
<input type="checkbox" id="show-shapes" checked>
133
Show shapes
134
</label>
135
<label>
136
<input type="checkbox" id="show-objects" checked>
137
Show objects
138
</label>
139
</x-buttonbox>
140
{% set licences = resource.licences | map(attribute="licence") | list %}
141
{% set contains = resource.regions | map(attribute="object_id") | set | select | sort | list %}
142
<h2>Ratings ({{ resource.rating_totals.values() | sum }})</h2>
143
<x-hbox>
144
<x-vbox>
145
{% if resource.average_rating %}
146
<div class="rating-bar">
147
{% for i in range(1, 6) %}
148
<div class="rating-bar-segment">
149
<div class="rating-bar-filling" style="width: {{ resource.stars[i-1] }}%"></div>
150
</div>
151
{% endfor %}
152
</div>
153
<p>
154
<span>Average rating:</span>
155
<span>{{ resource.average_rating | round(2) }}</span>
156
from {{ resource.rating_totals.values() | sum }} ratings
157
</p>
158
{% endif %}
159
{% if current_user %}
160
<h3>Your rating</h3>
161
<form id="rating-form" method="POST" action="/picture/{{ resource.id }}/rate">
162
<label>
163
<input name="rating" type="radio" value="0" {% if not own_rating.rating %}checked{% endif %}>
164
Clear rating
165
</label>
166
<div class="star-rating-container">
167
<input type="radio" id="stars-5" name="rating" value="5" title="Perfect" {% if own_rating.rating == 5 %}checked{% endif %}>
168
<label for="stars-5" tabindex="0"><iconify-icon icon="mdi:star" class="star">5 stars</iconify-icon></label>
169
<input type="radio" id="stars-4" name="rating" value="4" title="Good" {% if own_rating.rating == 4 %}checked{% endif %}>
170
<label for="stars-4" tabindex="0"><iconify-icon icon="mdi:star" class="star">4 stars</iconify-icon></label>
171
<input type="radio" id="stars-3" name="rating" value="3" title="OK" {% if own_rating.rating == 3 %}checked{% endif %}>
172
<label for="stars-3" tabindex="0"><iconify-icon icon="mdi:star" class="star">3 stars</iconify-icon></label>
173
<input type="radio" id="stars-2" name="rating" value="2" title="Poor" {% if own_rating.rating == 2 %}checked{% endif %}>
174
<label for="stars-2" tabindex="0"><iconify-icon icon="mdi:star" class="star">2 stars</iconify-icon></label>
175
<input type="radio" id="stars-1" name="rating" value="1" title="Awful" {% if own_rating.rating == 1 %}checked{% endif %}>
176
<label for="stars-1" tabindex="0"><iconify-icon icon="mdi:star" class="star">1 star</iconify-icon></label>
177
</div>
178
<button type="submit">Rate</button>
179
</form>
180
{% endif %}
181
</x-vbox>
182
{% if resource.average_rating %}
183
<ul class="rating-list flexible-space">
184
{% for i in range(5, 0, -1) %}
185
<li style="grid-column-end: {{ resource.rating_totals[i] + 2 }}; background: var(--{{ i }}-star);">
186
<span>{{ i }}:</span>
187
<span>{{ resource.rating_totals[i] }}</span>
188
</li>
189
{% endfor %}
190
</ul>
191
{% else %}
192
<p>No ratings yet.</p>
193
{% endif %}
194
</x-hbox>
195
<h2>Details</h2>
196
<div class="icon-explainer">
197
<span>Type</span>
198
<span>{{ resource.nature.id }}</span>
199
<span>File format</span>
200
<span>{{ resource.file_format }}</span>
201
<span>Size</span>
202
<span>{{ size[0] }}×{{ size[1] }}</span>
203
<span>Number of regions</span>
204
<span>{{ resource.regions | length }}</span>
205
<span>Number of labelled regions</span>
206
<span>{{ resource.regions | selectattr("object_id") | list | length }}</span>
207
<span>Date uploaded</span>
208
<span>{{ resource.timestamp }}</span>
209
</div>
210
{% if contains %}
211
<p>
212
Contains objects: {% for object_id in contains %}
213
<a href="/object/{{ object_id | urlencode }}">{{ object_id }}</a>{% if not loop.last %}, {% endif %}{% endfor %}
214
</p>
215
{% else %}
216
<p>No labelled regions.</p>
217
{% endif %}
218
<h2>Licensing</h2>
219
<x-hbox style="justify-content: space-between">
220
<small class="picture-licensing-info">
221
Available under:
222
{% for licence in licences %}
223
<a href="{{ licence.info_url }}" target="_blank">
224
{{ licence.title }}
225
</a>
226
{% if not loop.last %}, {% endif %}
227
{% endfor %}
228
</small>
229
<x-vbox class="picture-licence-logos">
230
{% for licence in licences[:6] %}
231
{% if licence.logo_url %}
232
{% if licence.info_url %}
233
<a href="{{ licence.info_url }}" target="_blank" tabindex="-1">
234
{# An equivalent link already exists, only one is focusable #}
235
<img src="{{ licence.logo_url }}" alt="{{ licence.title }}" class="licence-logo">
236
</a>
237
{% else %}
238
<img src="{{ licence.logo_url }}" alt="{{ licence.title }}" class="licence-logo">
239
{% endif %}
240
{% endif %}
241
{% endfor %}
242
{% if licences | length > 6 %}
243
<details>
244
<summary>More</summary>
245
<x-vbox>
246
{% for licence in licences[6:] %}
247
{% if licence.logo_url %}
248
{% if licence.info_url %}
249
<a href="{{ licence.info_url }}" target="_blank" tabindex="-1">
250
{# An equivalent link already exists, only one is focusable #}
251
<img src="{{ licence.logo_url }}" alt="{{ licence.title }}" class="licence-logo">
252
</a>
253
{% else %}
254
<img src="{{ licence.logo_url }}" alt="{{ licence.title }}" class="licence-logo">
255
{% endif %}
256
{% endif %}
257
{% endfor %}
258
</x-vbox>
259
</details>
260
{% endif %}
261
</x-vbox>
262
</x-hbox>
263
<h2>Copies</h2>
264
{% if resource.copies %}
265
<ul class="thumbnail-list">
266
{% for copy in resource.copies %}
267
<li>
268
<a href="/picture/{{ copy.id }}">
269
{{ annotation_display.annotation_display(copy) }}
270
<div class="list-detail">
271
{{ copy.title }}
272
</div>
273
</a>
274
<div class="list-more">
275
<span class="picture-author">by <a href="/profile/{{ copy.author.username }}">{{ copy.author.formatted_name }}</a></span>
276
<form method="POST" action="/picture/{{ copy.id }}/mark-replacement">
277
<button type="submit">Designate replacement</button>
278
</form>
279
</div>
280
</li>
281
{% endfor %}
282
</ul>
283
{% else %}
284
<p>This picture hasn't got any copies.</p>
285
{% endif %}
286
287
<h2>Galleries</h2>
288
{% if resource.galleries %}
289
<ul class="thumbnail-list">
290
{% for gallery in resource.galleries %}
291
<li>
292
<a href="/gallery/{{ gallery.gallery.id }}">
293
<div class="list-detail">
294
{{ gallery.gallery.title }}
295
</div>
296
</a>
297
</li>
298
{% endfor %}
299
</ul>
300
{% else %}
301
<p>This picture isn't in any galleries.</p>
302
{% endif %}
303
</x-vbox>
304
</x-frame>
305
</div>
306
<svg width="0" height="0">
307
<defs>
308
<clipPath id="star-clip">
309
<path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.62L12 2L9.19 8.62L2 9.24l5.45 4.73L5.82 21z"></path>
310
</clipPath>
311
</defs>
312
</svg>
313
{% endblock %}