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