python-gallery/gallery/templates/index.html

53 lines
2.3 KiB
HTML
Raw Normal View History

2022-12-01 18:48:31 +00:00
{% extends 'layout.html' %}
2023-03-25 16:22:32 +00:00
{% block nav_home %}selected{% endblock %}
{% block content %}
<div class="banner small">
<div class="banner-content">
<h1>{{ config.WEBSITE.name }}</h1>
{% if images|length == 0 %}
<p>0 images :<</p>
{% elif images|length == 69 %}
<p>{{ images|length }} images, nice</p>
{% else %}
<p>{{ images|length }} images</p>
{% endif %}
</div>
</div>
{% if images %}
<div class="gallery-grid">
{% for image in images %}
<a id="image-{{ image.id }}" class="gallery-item" href="{{ url_for('gallery.image', image_id=image.id) }}" style="background-color: rgb({{ image.image_colours.0.0 }}, {{ image.image_colours.0.1 }}, {{ image.image_colours.0.2 }})">
<div class="image-filter">
<p class="image-subtitle"></p>
<p class="image-title"><span class="time">{{ image.created_at }}</span></p>
</div>
2023-04-04 14:21:16 +00:00
<img fetchpriority="low" alt="{{ image.post_alt }}" data-src="{{ url_for('api.file', file_name=image.file_name) }}?r=thumb" onload="this.classList.add('loaded');" id="lazy-load"/>
</a>
{% endfor %}
</div>
{% else %}
<div class="big-text">
<h1>*crickets chirping*</h1>
<p>There are no images here yet, upload some!</p>
</div>
{% endif %}
{% endblock %}
{% block script %}
<script type="text/javascript">
if (document.referrer.includes('image')) {
try {
let referrerId = document.referrer.split('/').pop();
let imgOffset = document.getElementById('image-' + referrerId).offsetTop;
let imgHeight = document.getElementById('image-' + referrerId).offsetHeight;
let windowHeight = window.innerHeight;
document.querySelector('html').style.scrollBehavior = 'auto';
window.scrollTo(0, imgOffset + (imgHeight / 2) - (windowHeight / 2));
document.querySelector('html').style.scrollBehavior = 'smooth';
} catch (e) {
console.log(e);
}
}
</script>
{% endblock %}