Browse Source

Merge branch 'pr/535'

pull/543/head
Simon Conseil 5 months ago
parent
commit
297ee48c4b
  1. 8
      src/sigal/gallery.py
  2. 86
      src/sigal/themes/photoswipe/templates/album.html
  3. 39
      src/sigal/themes/photoswipe/templates/album_items.html
  4. 5
      src/sigal/themes/photoswipe/templates/album_list.html
  5. 49
      src/sigal/themes/photoswipe/templates/base.html
  6. BIN
      tests/sample/pictures/dir1/22.jpg

8
src/sigal/gallery.py

@ -918,14 +918,6 @@ class Gallery:
) as albums:
for album in albums:
if album.albums:
if album.medias:
self.logger.warning(
"Album '%s' contains sub-albums and images. "
"Please move images to their own sub-album. "
"Images in album %s will not be visible.",
album.title,
album.title,
)
album_list_writer.write(album)
else:
album_writer.write(album)

86
src/sigal/themes/photoswipe/templates/album.html

@ -1,92 +1,8 @@
{% from 'description.html' import img_description %}
{% extends "base.html" %}
{% block extra_head %}
<link rel="stylesheet" href="{{ theme.url }}/photoswipe.css">
<script type="module">
import PhotoSwipeLightbox from '{{ theme.url }}/photoswipe-lightbox.esm.min.js';
import PhotoSwipe from '{{ theme.url }}/photoswipe.esm.min.js';
import PhotoSwipeDynamicCaption from '{{ theme.url }}/photoswipe-dynamic-caption-plugin.esm.min.js';
import PhotoSwipeFullscreen from '{{ theme.url }}/photoswipe-fullscreen.esm.min.js';
import PhotoSwipeVideoPlugin from '{{ theme.url }}/photoswipe-video-plugin.esm.min.js';
const lightbox = new PhotoSwipeLightbox({
gallery: '.gallery',
children: '.thumbnail',
pswpModule: PhotoSwipe
});
const captionPlugin = new PhotoSwipeDynamicCaption(lightbox, {type: 'auto'});
const fullscreenPlugin = new PhotoSwipeFullscreen(lightbox);
const videoPlugin = new PhotoSwipeVideoPlugin(lightbox, {autoplay: true});
lightbox.on('uiRegister', function() {
lightbox.pswp.ui.registerElement({
name: 'download-button',
order: 8,
isButton: true,
tagName: 'a',
html: {
isCustomSVG: true,
inner: '<path d="M20.5 14.3 17.1 18V10h-2.2v7.9l-3.4-3.6L10 16l6 6.1 6-6.1ZM23 23H9v2h14Z" id="pswp__icn-download"/>',
outlineID: 'pswp__icn-download'
},
onInit: (el, pswp) => {
el.setAttribute('download', '');
el.setAttribute('target', '_blank');
el.setAttribute('rel', 'noopener');
pswp.on('change', () => {
if (pswp.currSlide.data.element.children[0].dataset.big) {
el.href = pswp.currSlide.data.element.children[0].dataset.big;
} else {
el.href = pswp.currSlide.data.src;
}
});
}
});
});
lightbox.init();
</script>
{% endblock extra_head %}
{% block content %}
{% include 'download_zip.html' %}
{% include 'map.html' %}
<div class="gallery">
{% for media in album.medias %}
{% if media.type == "image" %}
<figure class="gallery__img--{{ "main" if loop.first else "secondary" }} thumbnail">
<a href="{{ media.url }}"
data-pswp-width="{{media.size.width}}"
data-pswp-height="{{media.size.height}}"
{%- if media.big -%}
data-big="{{ media.big_url }}"
{%- endif -%}
>
<img src="{{ media.thumbnail }}" alt="{{ media.url }}" />
</a>
<div class="pswp-caption-content">
{{ img_description(media, with_big=False) }}
</div>
<figcaption>{{ media.title }} - {{ media.exif.datetime }}</figcaption>
</figure>
{% endif %}
{% if media.type == "video" %}
<figure class="gallery__img--secondary thumbnail" >
<a href="{{ media.url }}"
data-pswp-type="video"
data-pswp-width="800"
data-pswp-height="600">
<img src="{{ media.thumbnail }}" alt="{{ media.url }}" />
</a>
<div class="pswp-caption-content">
{{ img_description(media, with_big=False) }}
</div>
<figcaption>{{ media_title }}</figcaption>
</figure>
{% endif %}
{% endfor %}
</div>
{% include "album_items.html" %}
{% endblock %}
{% block extra_footer %}

39
src/sigal/themes/photoswipe/templates/album_items.html

@ -0,0 +1,39 @@
{% from 'description.html' import img_description %}
{% include 'download_zip.html' %}
{% include 'map.html' %}
<div class="gallery">
{% for media in album.medias %}
{% if media.type == "image" %}
<figure class="gallery__img--{{ "main" if loop.first else "secondary" }} thumbnail">
<a href="{{ media.url }}"
data-pswp-width="{{media.size.width}}"
data-pswp-height="{{media.size.height}}"
{% if media.big %}
data-big="{{ media.big_url }}"
{%- endif -%}
>
<img src="{{ media.thumbnail }}" alt="{{ media.url }}" />
</a>
<div class="pswp-caption-content">
{{ img_description(media, with_big=False) }}
</div>
<figcaption>{{ media.title }} - {{ media.exif.datetime }}</figcaption>
</figure>
{% endif %}
{% if media.type == "video" %}
<figure class="gallery__img--secondary thumbnail" >
<a href="{{ media.url }}"
data-pswp-type="video"
data-pswp-width="800"
data-pswp-height="600">
<img src="{{ media.thumbnail }}" alt="{{ media.url }}" />
</a>
<div class="pswp-caption-content">
{{ img_description(media, with_big=False) }}
</div>
<figcaption>{{ media_title }}</figcaption>
</figure>
{% endif %}
{% endfor %}
</div>

5
src/sigal/themes/photoswipe/templates/album_list.html

@ -1,4 +1,5 @@
{% extends "base.html" %}
{% block content %}
<div class="album-list">
{% for alb in album.albums %}
@ -10,4 +11,8 @@
</div>
{% endfor %}
</div>
{% if album.medias %}
{% include "album_items.html" %}
{% endif %}
{% endblock %}

49
src/sigal/themes/photoswipe/templates/base.html

@ -9,6 +9,55 @@
<meta name="author" content="{{ album.author }}">
<meta name="viewport" content="width=device-width">
{% include 'default_head.html' %}
{% if album.medias %}
<link rel="stylesheet" href="{{ theme.url }}/photoswipe.css">
<script type="module">
import PhotoSwipeLightbox from '{{ theme.url }}/photoswipe-lightbox.esm.min.js';
import PhotoSwipe from '{{ theme.url }}/photoswipe.esm.min.js';
import PhotoSwipeDynamicCaption from '{{ theme.url }}/photoswipe-dynamic-caption-plugin.esm.min.js';
import PhotoSwipeFullscreen from '{{ theme.url }}/photoswipe-fullscreen.esm.min.js';
import PhotoSwipeVideoPlugin from '{{ theme.url }}/photoswipe-video-plugin.esm.min.js';
const lightbox = new PhotoSwipeLightbox({
gallery: '.gallery',
children: '.thumbnail',
pswpModule: PhotoSwipe
});
const captionPlugin = new PhotoSwipeDynamicCaption(lightbox, {type: 'auto'});
const fullscreenPlugin = new PhotoSwipeFullscreen(lightbox);
const videoPlugin = new PhotoSwipeVideoPlugin(lightbox, {autoplay: true});
lightbox.on('uiRegister', function() {
lightbox.pswp.ui.registerElement({
name: 'download-button',
order: 8,
isButton: true,
tagName: 'a',
html: {
isCustomSVG: true,
inner: '<path d="M20.5 14.3 17.1 18V10h-2.2v7.9l-3.4-3.6L10 16l6 6.1 6-6.1ZM23 23H9v2h14Z" id="pswp__icn-download"/>',
outlineID: 'pswp__icn-download'
},
onInit: (el, pswp) => {
el.setAttribute('download', '');
el.setAttribute('target', '_blank');
el.setAttribute('rel', 'noopener');
pswp.on('change', () => {
if (pswp.currSlide.data.element.children[0].dataset.big) {
el.href = pswp.currSlide.data.element.children[0].dataset.big;
} else {
el.href = pswp.currSlide.data.src;
}
});
}
});
});
lightbox.init();
</script>
{% endif %}
{% block extra_head %}{% endblock extra_head %}
<link rel="stylesheet" href="{{ theme.url }}/styles.css">
{% if user_css %}

BIN
tests/sample/pictures/dir1/22.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Loading…
Cancel
Save