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