mirror of
https://github.com/ae-utbm/sith.git
synced 2025-02-26 01:17:13 +00:00
Use real images with lazy loading in sas albums and user pictures
This commit is contained in:
parent
e8db68b960
commit
f7ff77b88f
@ -39,6 +39,8 @@ class PictureSchema(ModelSchema):
|
|||||||
compressed_url: str
|
compressed_url: str
|
||||||
thumb_url: str
|
thumb_url: str
|
||||||
album: str
|
album: str
|
||||||
|
report_url: str
|
||||||
|
edit_url: str
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_sas_url(obj: Picture) -> str:
|
def resolve_sas_url(obj: Picture) -> str:
|
||||||
@ -56,6 +58,14 @@ class PictureSchema(ModelSchema):
|
|||||||
def resolve_thumb_url(obj: Picture) -> str:
|
def resolve_thumb_url(obj: Picture) -> str:
|
||||||
return obj.get_download_thumb_url()
|
return obj.get_download_thumb_url()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_report_url(obj: Picture) -> str:
|
||||||
|
return reverse("sas:picture_ask_removal", kwargs={"picture_id": obj.id})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def resolve_edit_url(obj: Picture) -> str:
|
||||||
|
return reverse("sas:picture_edit", kwargs={"picture_id": obj.id})
|
||||||
|
|
||||||
|
|
||||||
class PictureRelationCreationSchema(Schema):
|
class PictureRelationCreationSchema(Schema):
|
||||||
picture: NonNegativeInt
|
picture: NonNegativeInt
|
||||||
|
@ -20,8 +20,8 @@ main {
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
|
||||||
> a,
|
>a,
|
||||||
> input {
|
>input {
|
||||||
padding: 0.4em;
|
padding: 0.4em;
|
||||||
margin: 0.1em;
|
margin: 0.1em;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
@ -46,14 +46,14 @@ main {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
> .inputs {
|
>.inputs {
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
|
||||||
> p {
|
>p {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -62,7 +62,7 @@ main {
|
|||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
> input {
|
>input {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -72,8 +72,8 @@ main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> div > input,
|
>div>input,
|
||||||
> input {
|
>input {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -84,12 +84,12 @@ main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> div {
|
>div {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
> input[type=submit]:hover {
|
>input[type=submit]:hover {
|
||||||
background-color: #287fb8;
|
background-color: #287fb8;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
@ -100,27 +100,27 @@ main {
|
|||||||
.clipboard {
|
.clipboard {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: rgba(0,0,0,.1);
|
background-color: rgba(0, 0, 0, .1);
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.photos,
|
.photos,
|
||||||
.albums {
|
.albums {
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
min-height: 50px; // To contain the aria-busy loading wheel, even if empty
|
min-height: 50px; // To contain the aria-busy loading wheel, even if empty
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
|
||||||
> div {
|
>div {
|
||||||
background: rgba(0, 0, 0, .5);
|
background: rgba(0, 0, 0, .5);
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
> div,
|
>div,
|
||||||
> a {
|
>a {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 128px;
|
height: 128px;
|
||||||
@ -138,7 +138,7 @@ main {
|
|||||||
background: rgba(0, 0, 0, .5);
|
background: rgba(0, 0, 0, .5);
|
||||||
}
|
}
|
||||||
|
|
||||||
> input[type=checkbox] {
|
>input[type=checkbox] {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
@ -149,8 +149,8 @@ main {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .photo,
|
>.photo,
|
||||||
> .album {
|
>.album {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: #333333;
|
background-color: #333333;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
@ -166,25 +166,32 @@ main {
|
|||||||
|
|
||||||
border: 1px solid rgba(0, 0, 0, .3);
|
border: 1px solid rgba(0, 0, 0, .3);
|
||||||
|
|
||||||
|
>img {
|
||||||
|
object-position: top bottom;
|
||||||
|
object-fit: contain;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 500px) {
|
@media (max-width: 500px) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover > .text {
|
&:hover>.text {
|
||||||
background-color: rgba(0, 0, 0, .5);
|
background-color: rgba(0, 0, 0, .5);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover > .overlay {
|
&:hover>.overlay {
|
||||||
-webkit-backdrop-filter: blur(2px);
|
-webkit-backdrop-filter: blur(2px);
|
||||||
backdrop-filter: blur(2px);
|
backdrop-filter: blur(2px);
|
||||||
|
|
||||||
~ .text {
|
~.text {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .text {
|
>.text {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -201,7 +208,7 @@ main {
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .overlay {
|
>.overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -227,14 +234,14 @@ main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .album > div {
|
>.album>div {
|
||||||
background: rgba(0, 0, 0, .5);
|
background: rgba(0, 0, 0, .5);
|
||||||
background: linear-gradient(0deg, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, 0) 100%);
|
background: linear-gradient(0deg, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, 0) 100%);
|
||||||
text-align: left;
|
text-align: left;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .photo > .text {
|
>.photo>.text {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-bottom: 30px;
|
padding-bottom: 30px;
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@
|
|||||||
<div
|
<div
|
||||||
class="photo"
|
class="photo"
|
||||||
:class="{not_moderated: !picture.is_moderated}"
|
:class="{not_moderated: !picture.is_moderated}"
|
||||||
:style="`background-image: url(${picture.thumb_url})`"
|
|
||||||
>
|
>
|
||||||
|
<img :src="picture.thumb_url" :alt="picture.name" loading="lazy" />
|
||||||
<template x-if="!picture.is_moderated">
|
<template x-if="!picture.is_moderated">
|
||||||
<div class="overlay"> </div>
|
<div class="overlay"> </div>
|
||||||
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
||||||
|
@ -2,15 +2,19 @@
|
|||||||
<a href="{{ url('sas:album', album_id=a.id) }}">
|
<a href="{{ url('sas:album', album_id=a.id) }}">
|
||||||
{% if a.file %}
|
{% if a.file %}
|
||||||
{% set img = a.get_download_url() %}
|
{% set img = a.get_download_url() %}
|
||||||
|
{% set src = a.name %}
|
||||||
{% elif a.children.filter(is_folder=False, is_moderated=True).exists() %}
|
{% elif a.children.filter(is_folder=False, is_moderated=True).exists() %}
|
||||||
{% set img = a.children.filter(is_folder=False).first().as_picture.get_download_thumb_url() %}
|
{% set picture = a.children.filter(is_folder=False).first().as_picture %}
|
||||||
|
{% set img = picture.get_download_thumb_url() %}
|
||||||
|
{% set src = picture.name %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set img = static('core/img/sas.jpg') %}
|
{% set img = static('core/img/sas.jpg') %}
|
||||||
|
{% set src = "sas.jpg" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div
|
<div
|
||||||
class="album{% if not a.is_moderated %} not_moderated{% endif %}"
|
class="album{% if not a.is_moderated %} not_moderated{% endif %}"
|
||||||
style="background-image: url('{{ img }}');"
|
|
||||||
>
|
>
|
||||||
|
<img src="{{ img }}" alt="{{ src }}" loading="lazy" />
|
||||||
{% if not a.is_moderated %}
|
{% if not a.is_moderated %}
|
||||||
<div class="overlay"> </div>
|
<div class="overlay"> </div>
|
||||||
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
||||||
|
@ -114,12 +114,12 @@
|
|||||||
{% trans %}HD version{% endtrans %}
|
{% trans %}HD version{% endtrans %}
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
<a class="text danger" :href="`/sas/picture/${currentPicture.id}/report`">
|
<a class="text danger" :href="currentPicture.report_url">
|
||||||
{% trans %}Ask for removal{% endtrans %}
|
{% trans %}Ask for removal{% endtrans %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<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="currentPicture.edit_url"><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_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>
|
<a class="button" href="?rotate_right"><i class="fa-solid fa-rotate-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
<div
|
<div
|
||||||
class="photo"
|
class="photo"
|
||||||
:class="{not_moderated: !picture.is_moderated}"
|
:class="{not_moderated: !picture.is_moderated}"
|
||||||
:style="`background-image: url(${picture.thumb_url})`"
|
|
||||||
>
|
>
|
||||||
|
<img :src="picture.thumb_url" :alt="picture.name" loading="lazy" />
|
||||||
<template x-if="!picture.is_moderated">
|
<template x-if="!picture.is_moderated">
|
||||||
<div class="overlay"> </div>
|
<div class="overlay"> </div>
|
||||||
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
<div class="text">{% trans %}To be moderated{% endtrans %}</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user