Sith/sas/templates/sas/picture.jinja

211 lines
7.9 KiB
Django/Jinja
Raw Normal View History

2016-10-26 17:21:19 +00:00
{% extends "core/base.jinja" %}
{%- block additional_css -%}
<link defer rel="stylesheet" href="{{ static('bundled/core/components/ajax-select-index.css') }}">
<link defer rel="stylesheet" href="{{ static('core/components/ajax-select.scss') }}">
<link defer rel="stylesheet" href="{{ static('sas/css/picture.scss') }}">
{%- endblock -%}
{%- block additional_js -%}
<script type="module" src="{{ static('bundled/core/components/ajax-select-index.ts') }}"></script>
<script type="module" src="{{ static("bundled/sas/viewer-index.ts") }}"></script>
{%- endblock -%}
2016-10-26 17:21:19 +00:00
{% block title %}
{% trans %}SAS{% endtrans %}
2016-10-26 17:21:19 +00:00
{% endblock %}
2024-08-08 15:51:33 +00:00
{% from "sas/macros.jinja" import print_path %}
2016-10-26 17:21:19 +00:00
{% block content %}
2024-09-03 18:15:37 +00:00
<main x-data="picture_viewer">
<code>
2024-10-08 15:14:22 +00:00
<a href="{{ url('sas:main') }}">SAS</a> / {{ print_path(album) }} <span x-text="currentPicture.name"></span>
2024-09-03 18:15:37 +00:00
</code>
2024-09-03 18:15:37 +00:00
<br>
2024-09-03 18:15:37 +00:00
<div class="title">
2024-10-08 15:14:22 +00:00
<h3 x-text="currentPicture.name"></h3>
<h4 x-text="`${pictures.indexOf(currentPicture) + 1 } / ${pictures.length}`"></h4>
2024-09-03 18:15:37 +00:00
</div>
<br>
2024-10-08 15:14:22 +00:00
<template x-if="!currentPicture.is_moderated">
<div class="alert alert-red" @click="console.log(currentPicture)">
2024-09-03 18:15:37 +00:00
<div class="alert-main">
<template x-if="currentPicture.asked_for_removal">
<h3 class="alert-title">{% trans %}Asked for removal{% endtrans %}</h3>
2024-09-03 18:15:37 +00:00
</template>
<p>
{% trans trimmed %}
This picture can be viewed only by root users and by SAS admins.
It will be hidden to other users until it has been moderated.
{% endtrans %}
</p>
<template x-if="currentPicture.asked_for_removal">
<div>
<h5 @click="console.log(currentPicture.moderationRequests)">
{% trans %}The following issues have been raised:{% endtrans %}
</h5>
<template x-for="req in (currentPicture.moderationRequests ?? [])" :key="req.id">
<div>
<h6
x-text="`${req.author.first_name} ${req.author.last_name}`"
></h6>
<i x-text="Intl.DateTimeFormat(
'{{ LANGUAGE_CODE }}',
{dateStyle: 'long', timeStyle: 'short'}
).format(new Date(req.created_at))"></i>
<blockquote x-text="`> ${req.reason}`"></blockquote>
</div>
</template>
</div>
</template>
2024-09-03 18:15:37 +00:00
</div>
<div class="alert-aside">
<button class="btn btn-blue" @click="moderatePicture()">
{% trans %}Moderate{% endtrans %}
</button>
<button class="btn btn-red" @click.prevent="deletePicture()">
{% trans %}Delete{% endtrans %}
</button>
2024-10-08 15:14:22 +00:00
<p x-show="!!moderationError" x-text="moderationError"></p>
2024-09-03 18:15:37 +00:00
</div>
</div>
2024-09-03 18:15:37 +00:00
</template>
2024-09-03 18:15:37 +00:00
<div class="container" id="pict">
<div class="main">
2024-10-08 15:14:22 +00:00
<div class="photo" :aria-busy="currentPicture.imageLoading">
2024-09-16 16:14:37 +00:00
<img
2024-10-08 15:14:22 +00:00
:src="currentPicture.compressed_url"
:alt="currentPicture.name"
2024-09-16 16:14:37 +00:00
id="main-picture"
2024-10-08 15:14:22 +00:00
x-ref="mainPicture"
2024-09-16 16:14:37 +00:00
/>
2024-09-03 18:15:37 +00:00
</div>
2024-09-03 18:15:37 +00:00
<div class="general">
<div class="infos">
<h5>{% trans %}Infos{% endtrans %}</h5>
<div>
<div>
2024-09-03 18:15:37 +00:00
<span>{% trans %}Date: {% endtrans %}</span>
<span
x-text="Intl.DateTimeFormat(
'{{ LANGUAGE_CODE }}', {dateStyle: 'long'}
2024-10-08 15:14:22 +00:00
).format(new Date(currentPicture.date))"
2024-09-03 18:15:37 +00:00
>
</span>
</div>
<div>
<span>{% trans %}Owner: {% endtrans %}</span>
2024-10-08 15:14:22 +00:00
<a :href="currentPicture.owner.profile_url" x-text="currentPicture.owner.display_name"></a>
</div>
2024-09-03 18:15:37 +00:00
</div>
</div>
2024-09-03 18:15:37 +00:00
<div class="tools">
<h5>{% trans %}Tools{% endtrans %}</h5>
<div>
2024-09-03 18:15:37 +00:00
<div>
2024-10-08 15:14:22 +00:00
<a class="text" :href="currentPicture.full_size_url">
2024-09-03 18:15:37 +00:00
{% trans %}HD version{% endtrans %}
</a>
<br>
2024-10-10 16:53:49 +00:00
<a class="text danger" :href="`/sas/picture/${currentPicture.id}/report`">
{% trans %}Ask for removal{% endtrans %}
</a>
2024-09-03 18:15:37 +00:00
</div>
<div class="buttons">
2024-10-08 15:14:22 +00:00
<a class="button" :href="`/sas/picture/${currentPicture.id}/edit/`"><i class="fa-regular fa-pen-to-square edit-action"></i></a>
<a class="button" href="?rotate_left"><i class="fa-solid fa-rotate-left"></i></a>
<a class="button" href="?rotate_right"><i class="fa-solid fa-rotate-right"></i></a>
2024-09-03 18:15:37 +00:00
</div>
</div>
</div>
</div>
</div>
2024-09-03 18:15:37 +00:00
<div class="subsection">
<div class="navigation">
<div id="prev" class="clickable">
2024-10-08 15:14:22 +00:00
<template x-if="previousPicture">
2024-09-03 18:15:37 +00:00
<div
2024-10-08 15:14:22 +00:00
@keyup.left.window="currentPicture = previousPicture"
@click="currentPicture = previousPicture"
2024-09-03 18:15:37 +00:00
>
2024-10-08 15:14:22 +00:00
<img :src="previousPicture.thumb_url" alt="{% trans %}Previous picture{% endtrans %}"/>
2024-09-03 18:15:37 +00:00
<div class="overlay">←</div>
</div>
</template>
</div>
<div id="next" class="clickable">
2024-10-08 15:14:22 +00:00
<template x-if="nextPicture">
2024-09-03 18:15:37 +00:00
<div
2024-10-08 15:14:22 +00:00
@keyup.right.window="currentPicture = nextPicture"
@click="currentPicture = nextPicture"
2024-09-03 18:15:37 +00:00
>
2024-10-08 15:14:22 +00:00
<img :src="nextPicture.thumb_url" alt="{% trans %}Previous picture{% endtrans %}"/>
2024-09-03 18:15:37 +00:00
<div class="overlay">→</div>
</div>
</template>
</div>
</div>
2024-09-03 18:15:37 +00:00
<div class="tags">
<h5>{% trans %}People{% endtrans %}</h5>
{% if user.was_subscribed %}
2024-10-08 15:14:22 +00:00
<form @submit.prevent="submitIdentification" x-show="!!selector">
2024-10-18 21:26:04 +00:00
<user-ajax-select
x-ref="search"
multiple
2024-10-18 21:26:04 +00:00
delay="300"
placeholder="{%- trans -%}Identify users on pictures{%- endtrans -%}"
></user-ajax-select>
2024-09-03 18:15:37 +00:00
<input type="submit" value="{% trans %}Go{% endtrans %}"/>
</form>
{% endif %}
2024-09-03 18:15:37 +00:00
<ul>
2024-09-16 16:14:37 +00:00
<template
2024-10-08 15:14:22 +00:00
x-for="identification in (currentPicture.identifications || [])"
2024-09-16 16:14:37 +00:00
:key="identification.id"
>
2024-09-03 18:15:37 +00:00
<li>
<a class="user" :href="identification.user.profile_url">
<img class="profile-pic" :src="identification.user.profile_pict" alt="image de profil"/>
<span x-text="identification.user.display_name"></span>
</a>
2024-10-08 15:14:22 +00:00
<template x-if="canBeRemoved(identification)">
<a class="delete clickable" @click="removeIdentification(identification)"><i class="fa fa-times fa-xl delete-action"></i></a>
2024-09-03 18:15:37 +00:00
</template>
</li>
</template>
2024-10-08 15:14:22 +00:00
<template x-if="currentPicture.identificationsLoading">
2024-09-03 18:15:37 +00:00
{# shadow element that exists only to put the loading wheel below
the list of identified people #}
<li class="loader" aria-busy="true"></li>
</template>
</ul>
</div>
</div>
</div>
2024-09-03 18:15:37 +00:00
</main>
2016-10-26 17:21:19 +00:00
{% endblock %}
{% block script %}
{{ super() }}
<script>
window.addEventListener("DOMContentLoaded", () => {
loadViewer({
albumId: {{ album.id }} ,
albumUrl: "{{ album.get_absolute_url() }}",
firstPictureId: {{ picture.id }}, {# id of the first picture to show after page load #}
userId: {{ user.id }},
userIsSasAdmin: {{ (user.is_root or user.is_in_group(pk = settings.SITH_GROUP_SAS_ADMIN_ID))|tojson }}
});
})
</script>
{% endblock %}