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