python-gallery/gallery/templates/index.html

56 lines
2.1 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="/image/{{ 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>
<img alt="{{ image.post_alt }}" data-src="{{ image.file_name }}" onload="imgFade(this)" style="opacity:0;" id="lazy-load"/>
</a>
{% endfor %}
</div>
{% else %}
<div class="big-text">
<h1>*crickets chirping*</h1>
</div>
{% endif %}
{% endblock %}
{% block script %}
2022-12-01 18:48:31 +00:00
<script>
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);
}
2022-12-14 19:55:40 +00:00
}
2022-12-01 18:48:31 +00:00
</script>
{% endblock %}