Merge pull request 'Allow optional large image display with captions for galleries' (#317) from redmt/teddit:large_gallery_images_with_caption into main

Reviewed-on: https://codeberg.org/teddit/teddit/pulls/317
This commit is contained in:
teddit
2022-06-11 21:11:12 +02:00
5 changed files with 57 additions and 5 deletions
+1
View File
@@ -278,6 +278,7 @@ async function processJsonPost(json, parsed, user_preferences) {
post.media_metadata[id].p.length - 1 post.media_metadata[id].p.length - 1
].u ].u
), ),
caption: post.gallery_data.items[i].caption || false,
}; };
} }
obj.gallery_items.push(item); obj.gallery_items.push(item);
+8
View File
@@ -17,6 +17,7 @@ function resetPreferences(res) {
res.clearCookie('domain_instagram'); res.clearCookie('domain_instagram');
res.clearCookie('videos_muted'); res.clearCookie('videos_muted');
res.clearCookie('prefer_frontpage'); res.clearCookie('prefer_frontpage');
res.clearCookie('show_large_gallery_images');
} }
preferenceRoutes.get('/preferences', (req, res, next) => { preferenceRoutes.get('/preferences', (req, res, next) => {
@@ -91,6 +92,7 @@ preferenceRoutes.post('/saveprefs', (req, res, next) => {
let domain_instagram = req.body.domain_instagram; let domain_instagram = req.body.domain_instagram;
let videos_muted = req.body.videos_muted; let videos_muted = req.body.videos_muted;
let prefer_frontpage = req.body.prefer_frontpage; let prefer_frontpage = req.body.prefer_frontpage;
let show_large_gallery_images = req.body.show_large_gallery_images;
res.cookie('theme', theme, { res.cookie('theme', theme, {
maxAge: 365 * 24 * 60 * 60 * 1000, maxAge: 365 * 24 * 60 * 60 * 1000,
@@ -174,6 +176,12 @@ preferenceRoutes.post('/saveprefs', (req, res, next) => {
httpOnly: true, httpOnly: true,
}); });
if (show_large_gallery_images === 'on') show_large_gallery_images = 'true';
res.cookie('show_large_gallery_images', show_large_gallery_images, {
maxAge: 365 * 24 * 60 * 60 * 1000,
httpOnly: true,
});
return res.redirect('/preferences'); return res.redirect('/preferences');
}); });
+30
View File
@@ -1647,6 +1647,36 @@ body.homepage.clean .sublinks a {
} }
} }
/* Large gallery items */
.gallery .item.large {
display: flex;
flex-direction: column;
margin-bottom: 1rem;
position: relative;
margin-right: 0.3rem;
}
.gallery .item.large img {
max-height: 90vh;
position: relative;
}
.gallery .item.large .caption {
position: absolute;
width: calc(100% - 0.6rem);
color: white;
background: rgba(0, 0, 0, 0.7);
padding: 0.3rem;
bottom: 0;
}
@media only screen and (max-width: 768px) {
.gallery .item.large img {
max-height: unset;
max-width: 100%;
}
}
/* Fix spoiler texts not showing without JS */ /* Fix spoiler texts not showing without JS */
.md .md-spoiler-text:not(.revealed):active,.md .md-spoiler-text:not(.revealed):focus,.md .md-spoiler-text:not(.revealed):hover { .md .md-spoiler-text:not(.revealed):active,.md .md-spoiler-text:not(.revealed):focus,.md .md-spoiler-text:not(.revealed):hover {
color: black; color: black;
+12 -5
View File
@@ -137,12 +137,19 @@ html
if post.gallery if post.gallery
.gallery .gallery
each item in post.gallery_items each item in post.gallery_items
.item if user_preferences.show_large_gallery_images == 'true'
div .item.large
a(href="" + item.large + "", target="_blank") a(href="" + item.large + "", target="_blank")
img(src=""+ item.thumbnail +"", alt="") img(src="" + item.large + "", title="" + item.caption + "")
a(href="" + item.source + "", target="_blank", class="source-link") if item.caption
small source span.caption !{item.caption}
else
.item
div
a(href="" + item.large + "", target="_blank")
img(src=""+ item.thumbnail +"", alt="")
a(href="" + item.source + "", target="_blank", class="source-link")
small source
if post.images if post.images
.image .image
a(href="" + post.images.source + "") a(href="" + post.images.source + "")
+6
View File
@@ -126,6 +126,12 @@ html
input(type="checkbox", name="videos_muted", id="videos_muted", checked="checked") input(type="checkbox", name="videos_muted", id="videos_muted", checked="checked")
else else
input(type="checkbox", name="videos_muted", id="videos_muted") input(type="checkbox", name="videos_muted", id="videos_muted")
.setting
label(for="show_large_gallery_images") Show large gallery images with captions:
if (user_preferences.show_large_gallery_images == 'true')
input(type="checkbox", name="show_large_gallery_images", id="show_large_gallery_images", checked="checked")
else
input(type="checkbox", name="show_large_gallery_images", id="show_large_gallery_images")
small(class="notice") Preferences are stored client-side using cookies without any personal information. small(class="notice") Preferences are stored client-side using cookies without any personal information.
br br
input(type="submit", value="Save preferences") input(type="submit", value="Save preferences")