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