Compare commits

...
18 changed files with 1319 additions and 31 deletions

No files matched your search

+3 -19
View File
@@ -67,14 +67,14 @@ type scopedSourcePath struct {
// @Tags Tools
// @Accept json
// @Produce json
// @Param query query string false "Filter prefix or full search text (required when no terms are supplied)"
// @Param query query string false "Filter prefix or full search text; no minimum length is enforced (clients enforce minSearchLength)"
// @Param terms query []string false "Repeated: one literal search term per parameter; combined with OR unless termJoin=and"
// @Param sources query string false "Comma-separated source names when not using repeated scope=source:path"
// @Param scope query []string false "Repeated: 'sourceName:relativePath' per source"
// @Param olderThan query int false "Unix seconds; only results modified strictly before this time"
// @Param newerThan query int false "Unix seconds; only results modified on or after this time"
// @Param useWildcard query bool false "When true, match indexed file names with SQLite GLOB (wildcard patterns)"
// @Param limit query int false "Requested advanced search limit, capped by server.searchResultsLimit (default 1000); omitted for quick search (100)"
// @Param limit query int false "Requested advanced search limit, capped by server.searchResultsLimit (default 1000) and a hard max of 5000; omitted for quick search (100)"
// @Param termJoin query string false "Optional: 'and' to require all repeated 'terms' match; default is OR"
// @Success 200 {array} indexing.SearchResult "List of search results with source field populated"
// @Failure 400 {object} map[string]string "Bad Request"
@@ -93,10 +93,7 @@ func searchHandler(w http.ResponseWriter, r *http.Request, d *Context) (int, err
if err != nil || requested < 1 {
return http.StatusBadRequest, fmt.Errorf("limit must be a positive integer")
}
searchSize = requested
if searchSize > settings.Config.Server.SearchResultsLimit {
searchSize = settings.Config.Server.SearchResultsLimit
}
searchSize = min(requested, settings.Config.Server.SearchResultsLimit, indexing.MaxSearchResultsLimit)
}
ctx, cancel := context.WithTimeout(r.Context(), searchTimeout)
@@ -211,19 +208,6 @@ func prepSearchOptions(r *http.Request, d *Context) (*searchOptions, error) {
parsed := iteminfo.BuildSearchOptionsFromQuery(query, normalizedTerms, matchAllTerms)
minLen := settings.Config.Server.MinSearchLength
if !largest {
if len(normalizedTerms) > 0 {
for _, t := range normalizedTerms {
if len(t) < minLen {
return nil, fmt.Errorf("each term is too short, minimum length is %d", minLen)
}
}
} else if len(strings.TrimSpace(query)) < minLen {
return nil, fmt.Errorf("query is too short, minimum length is %d", minLen)
}
}
var sources []string
combinedPathMap := make(map[string]string)
var searchScopeOut string
+26
View File
@@ -16,6 +16,10 @@ var SearchResultsCache = cache.NewCache[[]string](15 * time.Second)
var DefaultSearchResults = 100
// MaxSearchResultsLimit is the hard upper bound for a requested search limit,
// regardless of server.searchResultsLimit.
const MaxSearchResultsLimit = 5000
type SearchResult struct {
Path string `json:"path"`
Type string `json:"type"`
@@ -145,6 +149,10 @@ func itemMatchesSearchFilters(item iteminfo.ItemInfo, isDir bool, searchOptions
if nameFiltered {
return item.MatchesSearchAuxiliaryFilters(searchOptions)
}
// A type-only query (for example "type:image") has no name terms. Match it on the type conditions alone.
if !hasNonEmptySearchTerm(searchOptions.Terms) && hasTypeCondition(searchOptions) {
return item.MatchesSearchAuxiliaryFilters(searchOptions)
}
if searchOptions.MatchAllTerms {
sawNonempty := false
for _, searchTerm := range searchOptions.Terms {
@@ -169,6 +177,24 @@ func itemMatchesSearchFilters(item iteminfo.ItemInfo, isDir bool, searchOptions
return false
}
func hasNonEmptySearchTerm(terms []string) bool {
for _, t := range terms {
if t != "" {
return true
}
}
return false
}
func hasTypeCondition(opts iteminfo.SearchOptions) bool {
for k, v := range opts.Conditions {
if k != "exact" && v {
return true
}
}
return false
}
func searchDateMatches(modUnix int64, opts iteminfo.SearchOptions) bool {
if opts.ModifiedNewerThan > 0 && modUnix < opts.ModifiedNewerThan {
return false
@@ -0,0 +1,25 @@
package indexing
import (
"testing"
"time"
"github.com/gtsteffaniak/filebrowser/backend/pkg/indexing/iteminfo"
)
func TestItemMatchesSearchFiltersTypeOnly(t *testing.T) {
image := iteminfo.ItemInfo{Name: "photo.jpg", Type: "image/jpeg", ModTime: time.Now()}
text := iteminfo.ItemInfo{Name: "notes.txt", Type: "text/plain", ModTime: time.Now()}
opts := iteminfo.SearchOptions{
Conditions: map[string]bool{"image": true},
Terms: []string{},
}
if !itemMatchesSearchFilters(image, false, opts, false, false) {
t.Fatal("type:image should match an image with no name terms")
}
if itemMatchesSearchFilters(text, false, opts, false, false) {
t.Fatal("type:image should not match a text file")
}
}
+1 -1
View File
@@ -70,7 +70,7 @@ type Environment struct {
}
type Server struct {
SearchResultsLimit int `json:"searchResultsLimit" yaml:"searchResultsLimit" validate:"gte=1"` // maximum requested search results across all sources (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200
SearchResultsLimit int `json:"searchResultsLimit" yaml:"searchResultsLimit" validate:"gte=1,lte=5000"` // maximum requested search results across all sources, hard max 5000 (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200
MinSearchLength int `json:"minSearchLength" yaml:"minSearchLength"` // minimum length of search query to begin searching (default: 3)
DisableUpdateCheck bool `json:"disableUpdateCheck"` // disables backend update check service
NumImageProcessors int `json:"numImageProcessors"` // number of concurrent image processing jobs used to create previews, default is 4.
+3 -2
View File
@@ -3855,7 +3855,7 @@ const docTemplate = `{
},
{
"type": "integer",
"description": "Requested advanced search limit, capped by server.searchResultsLimit (default 1000); omitted for quick search (100)",
"description": "Requested advanced search limit, capped by server.searchResultsLimit (default 1000) and a hard max of 5000; omitted for quick search (100)",
"name": "limit",
"in": "query"
},
@@ -6999,8 +6999,9 @@ const docTemplate = `{
"type": "integer"
},
"searchResultsLimit": {
"description": "maximum requested search results across all sources (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200",
"description": "maximum requested search results across all sources, hard max 5000 (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200",
"type": "integer",
"maximum": 5000,
"minimum": 1
},
"sources": {
+3 -2
View File
@@ -3844,7 +3844,7 @@
},
{
"type": "integer",
"description": "Requested advanced search limit, capped by server.searchResultsLimit (default 1000); omitted for quick search (100)",
"description": "Requested advanced search limit, capped by server.searchResultsLimit (default 1000) and a hard max of 5000; omitted for quick search (100)",
"name": "limit",
"in": "query"
},
@@ -6988,8 +6988,9 @@
"type": "integer"
},
"searchResultsLimit": {
"description": "maximum requested search results across all sources (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200",
"description": "maximum requested search results across all sources, hard max 5000 (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200",
"type": "integer",
"maximum": 5000,
"minimum": 1
},
"sources": {
+5 -4
View File
@@ -1042,9 +1042,10 @@ definitions:
default is 4.
type: integer
searchResultsLimit:
description: 'maximum requested search results across all sources (default:
1000); quick search defaults to 100, advanced search to 500; size viewer
remains limited to 200'
description: 'maximum requested search results across all sources, hard max
5000 (default: 1000); quick search defaults to 100, advanced search to 500;
size viewer remains limited to 200'
maximum: 5000
minimum: 1
type: integer
sources:
@@ -5196,7 +5197,7 @@ paths:
name: useWildcard
type: boolean
- description: Requested advanced search limit, capped by server.searchResultsLimit
(default 1000); omitted for quick search (100)
(default 1000) and a hard max of 5000; omitted for quick search (100)
in: query
name: limit
type: integer
+1 -1
View File
@@ -1,5 +1,5 @@
server:
searchResultsLimit: 1000 # maximum requested search results across all sources (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200 validate:gte=1
searchResultsLimit: 1000 # maximum requested search results across all sources, hard max 5000 (default: 1000); quick search defaults to 100, advanced search to 500; size viewer remains limited to 200 validate:gte=1,lte=5000
minSearchLength: 3 # minimum length of search query to begin searching (default: 3)
disableUpdateCheck: false # disables backend update check service
numImageProcessors: 4 # number of concurrent image processing jobs used to create previews, default is 4.
@@ -110,6 +110,7 @@ import Access from "./Access.vue";
import Password from "./Password.vue";
import PlaybackQueue from "./PlaybackQueue.vue";
import VisualizerSettings from "./VisualizerSettings.vue";
import SlideshowOptions from "./SlideshowOptions.vue";
import EditorSettings from "./EditorSettings.vue";
import SharePicker from "./SharePicker.vue";
import PathPicker from "./PathPicker.vue";
@@ -171,6 +172,7 @@ export default {
Password,
PlaybackQueue,
VisualizerSettings,
SlideshowOptions,
EditorSettings,
PathPicker,
EntityPicker,
@@ -424,6 +426,8 @@ export default {
return this.$t("player.QueuePlayback");
case "visualizersettings":
return this.$t("player.visualizer.settings");
case "slideshowoptions":
return this.$t("slideshow.title");
case "editorsettings":
return this.$t("editor.settings.title");
case "pathpicker":
@@ -0,0 +1,165 @@
<template>
<div class="card-content slideshow-options-content settings-items">
<div class="settings-number-input item">
<div class="no-padding">
<label for="slideshow-duration">{{ $t("slideshow.duration") }}</label>
<HelpTooltipIcon :text="$t('slideshow.durationDescription')" />
</div>
<div class="no-padding">
<input
id="slideshow-duration"
v-model.number="form.duration"
class="sizeInput input"
type="number"
min="1"
max="3600"
:placeholder="$t('general.number')"
/>
</div>
</div>
<ToggleSwitch class="item" v-model="form.fade" :name="$t('slideshow.fadeTransition')" />
<ToggleSwitch class="item" v-model="form.fitToScreen" :name="$t('slideshow.fitToScreen')"
:description="$t('slideshow.fitToScreenDescription')" />
<ToggleSwitch class="item" v-model="form.enlargeToFill" :name="$t('slideshow.enlargeToFill')"
:description="$t('slideshow.enlargeToFillDescription')" />
<ToggleSwitch class="item" v-model="form.shuffle" :name="$t('slideshow.shuffle')" />
<ToggleSwitch class="item" v-model="form.loop" :name="$t('slideshow.loop')" />
<ToggleSwitch class="item" v-model="form.kenBurns" :name="$t('slideshow.kenBurns')" />
<ToggleSwitch class="item" v-model="form.includeVideos" :name="$t('slideshow.includeVideos')"
:description="$t('slideshow.includeVideosDescription')" />
<ToggleSwitch class="item" v-model="form.playVideosToEnd" :name="$t('slideshow.playVideosToEnd')" :description="$t('slideshow.playVideosToEndDescription')" />
<ToggleSwitch class="item" v-model="form.showFilename" :name="$t('slideshow.showFilename')" />
<ToggleSwitch class="item" v-model="form.startFullscreen" :name="$t('slideshow.startFullscreen')" />
<template v-if="!isShare">
<ToggleSwitch
class="item"
v-model="form.includeSubfolders"
:name="$t('slideshow.includeSubfolders')"
:description="$t('slideshow.includeSubfoldersDescription')"
/>
<div v-if="form.includeSubfolders" class="setting-row item">
<div class="setting-label">
<label for="slideshow-max-items">{{ $t("slideshow.maxItems") }}</label>
<HelpTooltipIcon :text="$t('slideshow.maxItemsHint', { max: maxItemsCap })" />
</div>
<div class="setting-control">
<input
id="slideshow-max-items"
type="number"
class="input"
v-model.number="form.maxItems"
min="1"
:max="maxItemsCap"
@blur="clampMaxItems"
/>
</div>
</div>
</template>
</div>
<div class="card-actions">
<button type="button" class="button button--flat" @click="startSlideshow"
:aria-label="$t('slideshow.startSlideshow')" :title="$t('slideshow.startSlideshow')">
{{ $t("slideshow.startSlideshow") }}
</button>
</div>
</template>
<script>
import { getters, mutations, state } from "@/store";
import { router } from "@/router/index.ts";
import { removeLastDir } from "@/utils/url.js";
import ToggleSwitch from "@/components/settings/ToggleSwitch.vue";
import HelpTooltipIcon from "@/components/HelpTooltipIcon.vue";
import {
slideshowConfig,
saveSlideshowConfig,
SLIDESHOW_DEFAULTS,
effectiveMaxItemsCap,
} from "@/utils/slideshowConfig.js";
import { globalVars } from "@/utils/constants";
export default {
name: "SlideshowOptions",
components: { ToggleSwitch, HelpTooltipIcon },
props: {
promptId: { type: [String, Number], default: undefined },
// Name of the image the user opened, so the slideshow starts there.
startName: { type: String, default: "" },
},
data() {
return {
form: { ...slideshowConfig },
};
},
computed: {
isShare() {
return getters.isShare();
},
maxItemsCap() {
return effectiveMaxItemsCap(globalVars.searchResultsLimit);
},
},
methods: {
clampMaxItems() {
const value = Number(this.form.maxItems);
if (!Number.isFinite(value) || value < 1) {
this.form.maxItems = SLIDESHOW_DEFAULTS.maxItems;
} else if (value > this.maxItemsCap) {
this.form.maxItems = this.maxItemsCap;
} else {
this.form.maxItems = Math.floor(value);
}
},
startSlideshow() {
this.clampMaxItems();
const duration = Number(this.form.duration);
saveSlideshowConfig({
...this.form,
duration: Number.isFinite(duration) ? Math.min(3600, Math.max(1, Math.round(duration))) : SLIDESHOW_DEFAULTS.duration,
includeSubfolders: this.isShare ? false : this.form.includeSubfolders,
});
const query = { slideshow: "1" };
if (this.startName) query.start = this.startName;
mutations.closeTopPrompt(this.promptId ?? undefined);
router.push({ path: removeLastDir(state.route.path), query });
},
},
};
</script>
<style scoped>
.slideshow-options-content {
min-width: 18em;
}
/* Two-column number row, matching the settings-number-input layout in FileLoading.vue. */
.settings-number-input {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 1em;
}
.settings-number-input > div {
display: flex;
align-items: center;
padding: 0.5em;
}
.no-padding {
padding: 0 !important;
}
.sizeInput {
width: 6em;
}
</style>
+39
View File
@@ -1260,5 +1260,44 @@
},
"pwa": {
"install": "Install app"
},
"slideshow": {
"title": "Slideshow options",
"start": "Start slideshow",
"startSlideshow": "Start slideshow",
"duration": "Seconds per slide",
"durationDescription": "How long each image stays on screen. Videos use this only when play to end is off.",
"shuffle": "Shuffle order",
"loop": "Loop when finished",
"kenBurns": "Pan and zoom",
"playVideosToEnd": "Play videos to the end",
"playVideosToEndDescription": "Advance after each video finishes instead of after the slide duration.",
"showFilename": "Show file name",
"startFullscreen": "Start in fullscreen",
"includeSubfolders": "Include subfolders",
"includeSubfoldersDescription": "Show images and videos from subfolders too.",
"maxItems": "Maximum items",
"maxItemsHint": "Up to {max} items, limited by the server search setting.",
"exit": "Exit",
"exitFullscreen": "Exit fullscreen",
"fullscreen": "Fullscreen",
"previous": "Previous",
"next": "Next",
"play": "Play",
"pause": "Pause",
"paused": "Paused",
"counter": "{current}/{total}",
"empty": "No images or videos to show in this folder.",
"allFailed": "None of the files could be shown.",
"searchFailed": "Could not search subfolders. Showing this folder only.",
"truncated": "Showing the first {max} items.",
"counterPaused": "{current}/{total} · Paused",
"fadeTransition": "Fade transition",
"fitToScreen": "Fit image to screen",
"fitToScreenDescription": "On: the whole image is visible, with black bars if needed. Off: the image fills the screen and parts of it may be cropped.",
"enlargeToFill": "Always enlarge to fill screen",
"enlargeToFillDescription": "On: small images are scaled up to fill the screen, which can look soft. Off: images never display larger than their actual size.",
"includeVideos": "Include videos",
"includeVideosDescription": "Show video files in the slideshow along with images. Videos play muted."
}
}
+8 -2
View File
@@ -363,7 +363,9 @@ export const getters = {
if (getters.currentPromptName() && !getters.isStickySidebar()) {
visible = false
}
if (previewViews.includes(cv) && !getters.previewPerms().disableHideSidebar) {
// The slideshow hides the sidebar like preview views do, unless the user chose "always show sidebar".
const hidesSidebar = previewViews.includes(cv) || cv === 'slideshow';
if (hidesSidebar && !getters.previewPerms().disableHideSidebar) {
visible = false
}
if (state.shareInfo?.singleFileShare) {
@@ -444,7 +446,11 @@ export const getters = {
const reqName = state.req.name ?? "";
const ext = `.${reqName.split(".").pop()?.toLowerCase() ?? ""}`;
if (state.user.disableViewingExt?.includes(ext)) return 'preview';
if (state.req.type === 'directory') return 'listingView';
if (state.req.type === 'directory') {
// ?slideshow=1 on a folder shows the fullscreen slideshow view.
const query = state.route?.query as Record<string, string | undefined> | undefined;
return query?.slideshow === '1' ? 'slideshow' : 'listingView';
}
if (getters.isWopiFile(reqName) && !getters.isShare()) return 'wopiEditor';
if (state.req.onlyOfficeId && !getters.officeViewingDisabled(reqName)) return 'onlyOfficeEditor';
if (getTypeInfo(state.req.type).simpleType === '3d-model') return 'threeJsViewer';
@@ -0,0 +1,97 @@
import { describe, it, expect, vi } from 'vitest';
vi.mock('@/api/tools.js', () => ({ search: vi.fn() }));
vi.mock('@/api', () => ({ resourcesApi: { getViewURL: vi.fn() } }));
vi.mock('@/store', () => ({
state: { req: {}, route: {}, shareInfo: null },
getters: { fileViewingDisabled: () => false, isShare: () => false },
mutations: {},
}));
import { effectiveMaxItemsCap, SLIDESHOW_MAX_ITEMS_HARD_CAP, saveSlideshowConfig, resetSlideshowConfig } from '@/utils/slideshowConfig.js';
import { slidesFromListing, shuffled, mediaInfo, countMediaInListing } from '@/utils/slideshow.js';
describe('effectiveMaxItemsCap', () => {
it('uses the server limit when it is below the hard cap', () => {
expect(effectiveMaxItemsCap(1000)).toBe(1000);
});
it('never exceeds the hard cap of 5000', () => {
expect(effectiveMaxItemsCap(20000)).toBe(SLIDESHOW_MAX_ITEMS_HARD_CAP);
expect(SLIDESHOW_MAX_ITEMS_HARD_CAP).toBe(5000);
});
it('falls back to the hard cap when the server limit is missing', () => {
expect(effectiveMaxItemsCap(undefined)).toBe(SLIDESHOW_MAX_ITEMS_HARD_CAP);
expect(effectiveMaxItemsCap(0)).toBe(SLIDESHOW_MAX_ITEMS_HARD_CAP);
});
});
describe('mediaInfo', () => {
it('classifies images and videos by extension when no mime type is given', () => {
expect(mediaInfo('photo.jpg', '')).toEqual({ kind: 'image', preview: null });
expect(mediaInfo('clip.mp4', '')).toEqual({ kind: 'video', preview: null });
});
it('shows RAW files through the server preview', () => {
expect(mediaInfo('shot.dng', '')).toEqual({ kind: 'image', preview: 'raw' });
expect(mediaInfo('shot.CR3', '')).toEqual({ kind: 'image', preview: 'raw' });
});
it('skips HEIC when neither Safari nor ffmpeg conversion is available', () => {
expect(mediaInfo('IMG_0001.HEIC', '')).toBeNull();
});
it('skips documents and other non-media files', () => {
expect(mediaInfo('notes.txt', '')).toBeNull();
expect(mediaInfo('archive.zip', '')).toBeNull();
});
});
describe('slidesFromListing', () => {
it('keeps images and videos, drops folders and other files, in listing order', () => {
const listing = [
{ name: 'a.jpg', path: '/pics/a.jpg', type: 'image/jpeg' },
{ name: 'sub', path: '/pics/sub', type: 'directory' },
{ name: 'notes.txt', path: '/pics/notes.txt', type: 'text/plain' },
{ name: 'b.mp4', path: '/pics/b.mp4', type: 'video/mp4' },
];
const slides = slidesFromListing(listing, 'files');
expect(slides.map((s: { name: string }) => s.name)).toEqual(['a.jpg']);
expect(slides[0].source).toBe('files');
});
it('includes videos only when include videos is on', () => {
saveSlideshowConfig({ includeVideos: true });
const listing = [
{ name: 'a.jpg', path: '/pics/a.jpg', type: 'image/jpeg' },
{ name: 'b.mp4', path: '/pics/b.mp4', type: 'video/mp4' },
];
const slides = slidesFromListing(listing, 'files');
expect(slides.map((s: { kind: string }) => s.kind)).toEqual(['image', 'video']);
resetSlideshowConfig();
});
it('keeps the preview flag for RAW items so their URL comes from the preview endpoint', () => {
const slides = slidesFromListing([{ name: 'shot.nef', path: '/x/shot.nef', type: '', modified: 'm' }], 'files');
expect(slides[0]).toMatchObject({ kind: 'image', preview: 'raw', modified: 'm' });
});
it('counts only viewable media for the entry button threshold', () => {
const listing = [
{ name: 'only.jpg', path: '/x/only.jpg', type: 'image/jpeg' },
{ name: 'folder', path: '/x/folder', type: 'directory' },
];
expect(countMediaInListing(listing)).toBe(1);
expect(countMediaInListing(null)).toBe(0);
});
});
describe('shuffled', () => {
it('returns a permutation without mutating the input', () => {
const input = [1, 2, 3, 4, 5];
const out = shuffled(input);
expect(input).toEqual([1, 2, 3, 4, 5]);
expect([...out].sort()).toEqual([1, 2, 3, 4, 5]);
});
});
+144
View File
@@ -0,0 +1,144 @@
import * as toolsApi from "@/api/tools.js";
import { resourcesApi } from "@/api";
import { getTypeInfo, getTypeInfoFromExt, isRawImageMimeType } from "@/utils/mimetype.js";
import { removeTrailingSlash } from "@/utils/url.js";
import { getters, state } from "@/store";
import { globalVars } from "@/utils/constants";
import { joinPath } from "@/utils/url.js";
import { slideshowConfig } from "@/utils/slideshowConfig.js";
const RAW_EXT = /\.(cr2|cr3|nef|nrw|arw|dng|orf|rw2|raf|pef|srw|raw)$/i;
const HEIC_EXT = /\.(heic|heif)$/i;
// Classifies a file for the slideshow. Returns { kind, preview } or null when it can't be shown.
// preview is "raw" or "heic" when the image must be fetched as a server-generated preview,
// matching how Preview.vue builds its URL. A preview that fails at load time is skipped.
export function mediaInfo(name, mimeType = "") {
if (!name) return null;
if (getters.fileViewingDisabled(name)) return null;
if (isRawImageMimeType(mimeType) || RAW_EXT.test(name)) {
return { kind: "image", preview: "raw" };
}
const isHeic = HEIC_EXT.test(name) || mimeType === "image/heic" || mimeType === "image/heif";
if (isHeic) {
if (state.isSafari) return { kind: "image", preview: null };
if (globalVars.ffmpegAvailable && globalVars.enableHeicConversion) {
return { kind: "image", preview: "heic" };
}
return null;
}
const simple = mimeType ? getTypeInfo(mimeType).simpleType : getTypeInfoFromExt(name).simpleType;
if (simple === "image") return { kind: "image", preview: null };
if (simple === "video") return { kind: "video", preview: null };
return null;
}
// Videos are only part of the slideshow when the user turns "include videos" on.
function isIncluded(info) {
return !!info && (info.kind === "image" || slideshowConfig.includeVideos);
}
export function countMediaInListing(listing) {
if (!Array.isArray(listing)) return 0;
return listing.filter((item) => item && item.type !== "directory" && isIncluded(mediaInfo(item.name, item.type))).length;
}
function nameFromPath(path) {
const parts = String(path || "").split("/").filter(Boolean);
return parts[parts.length - 1] || "";
}
// Builds slides for the current folder from the listing already in memory.
export function slidesFromListing(listing, source) {
return (listing || [])
.filter((item) => item && item.type !== "directory")
.map((item) => {
const info = mediaInfo(item.name, item.type);
if (!isIncluded(info)) return null;
return {
key: `${item.source || source}:${item.path}`,
source: item.source || source,
path: item.path,
name: item.name,
kind: info.kind,
preview: info.preview,
mime: item.type || "",
modified: item.modified || "",
};
})
.filter(Boolean);
}
// Recursively finds images and videos under a folder via the search API.
// Results are merged, sorted by path, and capped at maxItems.
export async function slidesFromSearch(source, dirPath, maxItems) {
const perSourceScopes = [{ source, path: dirPath }];
const queries = slideshowConfig.includeVideos ? ["type:image", "type:video"] : ["type:image"];
const responses = await Promise.all(
queries.map((query) =>
toolsApi.search(dirPath, [source], query, false, { limit: maxItems, perSourceScopes })
)
);
const seen = new Set();
const slides = [];
for (const results of responses) {
if (!Array.isArray(results)) continue;
for (const result of results) {
const src = result.source || source;
const name = nameFromPath(result.path);
const mime = String(result.type || "").includes("/") ? result.type : "";
const fullPath = joinPath(dirPath, result.path);
const key = `${src}:${fullPath}`;
if (seen.has(key)) continue;
seen.add(key);
const info = mediaInfo(name, mime);
if (!isIncluded(info)) continue;
// Result paths are relative to the scope that was searched, so join the scope back on.
slides.push({
key,
source: src,
path: fullPath,
name,
kind: info.kind,
preview: info.preview,
mime,
modified: result.modified || "",
});
}
}
slides.sort((a, b) => a.path.localeCompare(b.path, undefined, { numeric: true, sensitivity: "base" }));
const truncated = slides.length > maxItems;
return { slides: slides.slice(0, maxItems), truncated };
}
// Fisher–Yates shuffle, returns a new array.
export function shuffled(items) {
const out = items.slice();
for (let i = out.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[out[i], out[j]] = [out[j], out[i]];
}
return out;
}
// Resolves the URL for a slide. Mirrors the URL logic in Preview.vue's `raw`.
export function slideUrl(slide, viewToken) {
const isShare = getters.isShare();
if (slide.kind === "image" && slide.preview) {
if (isShare) {
if (!viewToken) return null;
return resourcesApi.getPreviewURLPublic(removeTrailingSlash(slide.path), "original", viewToken);
}
return `${resourcesApi.getPreviewURL(slide.source, slide.path, slide.modified)}&size=original`;
}
if (!viewToken) return null;
const shareInfo = isShare ? state.shareInfo : null;
return resourcesApi.getViewURL(slide.source, slide.path, viewToken, shareInfo, false, slide.mime || slide.name);
}
+56
View File
@@ -0,0 +1,56 @@
import { reactive } from 'vue';
const STORAGE_KEY = 'slideshowConfig';
export const SLIDESHOW_MAX_ITEMS_HARD_CAP = 5000;
export const SLIDESHOW_DEFAULTS = {
duration: 5,
fade: true,
fitToScreen: true,
enlargeToFill: true,
shuffle: true,
loop: true,
kenBurns: true,
includeVideos: false,
playVideosToEnd: true,
showFilename: true,
startFullscreen: true,
includeSubfolders: false,
maxItems: 100,
};
function load() {
try {
const stored = localStorage.getItem(STORAGE_KEY);
if (!stored) return { ...SLIDESHOW_DEFAULTS };
return { ...SLIDESHOW_DEFAULTS, ...JSON.parse(stored) };
} catch (_) {
return { ...SLIDESHOW_DEFAULTS };
}
}
function persist() {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(slideshowConfig));
} catch (_) { /* ignore */ }
}
export const slideshowConfig = reactive(load());
export function saveSlideshowConfig(partial) {
Object.assign(slideshowConfig, partial);
persist();
}
export function resetSlideshowConfig() {
Object.assign(slideshowConfig, SLIDESHOW_DEFAULTS);
persist();
}
// Effective upper bound for subfolder search: the lower of the server's
// configured search limit and the hard cap.
export function effectiveMaxItemsCap(serverLimit) {
const server = Number.isFinite(serverLimit) && serverLimit > 0 ? serverLimit : SLIDESHOW_MAX_ITEMS_HARD_CAP;
return Math.min(server, SLIDESHOW_MAX_ITEMS_HARD_CAP);
}
+1
View File
@@ -172,6 +172,7 @@ export default {
DocViewer: createAsyncComponent(() => import('@/views/files/DocViewer.vue')),
MarkdownViewer: createAsyncComponent(() => import('@/views/files/MarkdownViewer.vue')),
ThreeJsViewer: createAsyncComponent(() => import('@/views/files/ThreeJs.vue')),
Slideshow: createAsyncComponent(() => import('@/views/files/Slideshow.vue')),
},
data() {
return {
+21
View File
@@ -12,6 +12,14 @@
<ExtendedImage v-if="showImage && !isTransitioning" :src="raw" @navigate-previous="navigatePrevious"
@navigate-next="navigateNext" @close-preview="exitPreviewFromImageGesture" />
<FloatingActionButton
v-if="showSlideshowButton"
icon="slideshow"
position="top-right"
:label="$t('slideshow.start')"
@click="openSlideshowOptions"
/>
<!-- Media: load full metadata + album art from media API before mounting plyr so the correct view/art is stable. -->
<div v-else-if="previewType === 'audio' || (previewType === 'video' && showVideoPlayer)" class="av-preview-wrap">
<div v-if="avMetadataLoading" class="av-preview-loading">
@@ -123,6 +131,8 @@
</template>
<script>
import { createAsyncComponent } from "@/utils/asyncComponent.js";
import FloatingActionButton from "@/components/settings/FloatingActionButton.vue";
import { countMediaInListing } from "@/utils/slideshow.js";
import { resourcesApi, mediaApi } from "@/api";
import { ensureViewToken, requestViewIdentity } from "@/api/viewToken.js";
import { goToItem, removeTrailingSlash, removeLastDir } from "@/utils/url.js";
@@ -155,6 +165,7 @@ export default {
name: "preview",
components: {
LoadingSpinner,
FloatingActionButton,
ExtendedImage: createAsyncComponent(() => import('@/components/files/ExtendedImage.vue')),
plyrViewer: createAsyncComponent(() => import('@/views/files/plyrViewer.vue')),
},
@@ -182,6 +193,10 @@ export default {
};
},
computed: {
// Slideshow entry point: images only, and only when the folder has at least two images or videos.
showSlideshowButton() {
return this.previewType === 'image' && !this.isTransitioning && countMediaInListing(this.listing) >= 2;
},
permissions() {
return getters.sourcePermissions();
},
@@ -378,6 +393,12 @@ export default {
mutations.clearNavigation();
},
methods: {
openSlideshowOptions() {
mutations.showPrompt({
name: 'SlideshowOptions',
props: { startName: state.req.name },
});
},
async attachDirMediaMetadata(listing, dirPath) {
if (!listing?.length) return;
try {
+717
View File
@@ -0,0 +1,717 @@
<template>
<div
ref="root"
class="slideshow"
:class="{
'chrome-visible': chromeVisible,
'cursor-hidden': !chromeVisible && !paused,
'is-paused': paused,
'no-transition': !cfg.fade,
'fit-contain': cfg.fitToScreen,
'fit-cover': !cfg.fitToScreen,
'no-enlarge': !cfg.enlargeToFill,
'below-navbar': !isFullscreen,
}"
:style="{ left: moveWithSidebar ? `${sidebarWidth}em` : '0' }"
@mousemove="onPointerMove"
@touchstart.passive="onTouchStart"
@touchend="onTouchEnd"
@click="onStageClick"
>
<div class="slideshow-stage">
<div
v-for="(layer, i) in layers"
:key="i"
class="slide-layer"
:class="{ active: active === i }"
>
<template v-if="layer.url">
<img
v-if="layer.kind === 'image'"
:key="layer.key"
:src="layer.url"
:class="{ kb: cfg.kenBurns }"
:style="layer.style"
alt=""
@load="onMediaLoaded"
@error="onMediaError"
/>
<video
v-else
:key="layer.key"
:ref="(el) => setVideoRef(el, i)"
:src="layer.url"
muted
playsinline
preload="auto"
@ended="onVideoEnded"
@loadeddata="onMediaLoaded"
@error="onMediaError"
/>
</template>
</div>
</div>
<div v-if="cfg.showFilename && currentSlide" class="slideshow-filename">
{{ currentSlide.name }}
</div>
<div class="slideshow-chrome slideshow-top-left">
<button type="button" class="button button--flat slideshow-exit" :aria-label="$t('slideshow.exit')"
:title="$t('slideshow.exit')" @click.stop="exit">
<i class="material-symbols">{{ icons.close }}</i>
</button>
</div>
<div v-if="slides.length" class="slideshow-chrome slideshow-top-right">
{{ paused
? $t("slideshow.counterPaused", { current: index + 1, total: slides.length })
: $t("slideshow.counter", { current: index + 1, total: slides.length }) }}
</div>
<div v-if="slides.length" class="slideshow-chrome slideshow-controls" @click.stop>
<button type="button" class="button button--flat" :aria-label="$t('slideshow.previous')" @click="goPrev">
<i class="material-symbols">{{ icons.previous }}</i>
</button>
<button type="button" class="button button--flat" :aria-label="paused ? $t('slideshow.play') : $t('slideshow.pause')" @click="togglePause">
<i class="material-symbols">{{ paused ? icons.play : icons.pause }}</i>
</button>
<button type="button" class="button button--flat" :aria-label="$t('slideshow.next')" @click="goNext">
<i class="material-symbols">{{ icons.next }}</i>
</button>
<button type="button" class="button button--flat" :aria-label="isFullscreen ? $t('slideshow.exitFullscreen') : $t('slideshow.fullscreen')" @click="toggleFullscreen">
<i class="material-symbols">{{ isFullscreen ? icons.exitFullscreen : icons.fullscreen }}</i>
</button>
</div>
<div v-if="loading" class="slideshow-empty">
<LoadingSpinner size="medium" />
</div>
<div v-else-if="!slides.length" class="slideshow-empty">
<p>{{ loadError || $t("slideshow.empty") }}</p>
<button type="button" class="button" @click.stop="exit">{{ $t("slideshow.exit") }}</button>
</div>
</div>
</template>
<script>
import { state, getters } from "@/store";
import { router } from "@/router/index.ts";
import { ensureViewToken } from "@/api/viewToken.js";
import { buildItemUrl } from "@/utils/url.js";
import LoadingSpinner from "@/components/LoadingSpinner.vue";
import { notify } from "@/notify/index.ts";
import { slideshowConfig } from "@/utils/slideshowConfig.js";
import {
slidesFromListing,
slidesFromSearch,
shuffled,
slideUrl,
} from "@/utils/slideshow.js";
const CHROME_HIDE_MS = 3500;
const POINTER_THROTTLE_MS = 100;
const SWIPE_THRESHOLD_PX = 50;
const emptyLayer = () => ({ kind: null, url: null, key: 0, style: {} });
// Material Symbols ligature names. Kept out of the template so they aren't read as raw text.
const icons = {
close: "close",
previous: "skip_previous",
next: "skip_next",
play: "play_arrow",
pause: "pause",
fullscreen: "fullscreen",
exitFullscreen: "fullscreen_exit",
};
export default {
name: "SlideshowView",
components: { LoadingSpinner },
props: {
// The directory being shown, provided by Files.vue as `fbdata`.
fbdata: { type: Object, required: true },
},
data() {
return {
icons,
slides: [],
index: 0,
loading: true,
loadError: "",
token: null,
layers: [emptyLayer(), emptyLayer()],
active: 0,
layerKey: 0,
paused: false,
remaining: null,
chromeVisible: true,
isFullscreen: false,
failStreak: 0,
wakeLock: null,
touchX: null,
lastPointer: 0,
timerHandle: null,
timerStart: 0,
hideHandle: null,
advanceHandle: null,
videoEls: {},
keyHandler: null,
fullscreenHandler: null,
visibilityHandler: null,
};
},
computed: {
cfg() {
return slideshowConfig;
},
sidebarShowing() {
return getters.isSidebarVisible();
},
// Only a pinned (sticky) sidebar takes up layout room. A floating sidebar overlays the slideshow.
moveWithSidebar() {
return this.sidebarShowing && getters.isStickySidebar();
},
sidebarWidth() {
return state.sidebar?.width || 20;
},
currentSlide() {
return this.slides[this.index] || null;
},
},
async mounted() {
this.keyHandler = (e) => this.onKeyDown(e);
this.fullscreenHandler = () => {
this.isFullscreen = !!(document.fullscreenElement || document.webkitFullscreenElement);
};
this.visibilityHandler = () => {
if (document.visibilityState === "visible" && !this.paused) this.requestWakeLock();
};
window.addEventListener("keydown", this.keyHandler);
document.addEventListener("fullscreenchange", this.fullscreenHandler);
document.addEventListener("webkitfullscreenchange", this.fullscreenHandler);
document.addEventListener("visibilitychange", this.visibilityHandler);
await this.loadSlides();
if (this.slides.length) {
this.showSlide(this.index, false);
this.scheduleCurrent();
this.requestWakeLock();
if (this.cfg.startFullscreen) this.enterFullscreen();
this.scheduleHide();
}
},
beforeUnmount() {
window.removeEventListener("keydown", this.keyHandler);
document.removeEventListener("fullscreenchange", this.fullscreenHandler);
document.removeEventListener("webkitfullscreenchange", this.fullscreenHandler);
document.removeEventListener("visibilitychange", this.visibilityHandler);
this.clearTimer();
clearTimeout(this.hideHandle);
clearTimeout(this.advanceHandle);
this.releaseWakeLock();
if (document.fullscreenElement || document.webkitFullscreenElement) {
this.exitFullscreen();
}
},
methods: {
async loadSlides() {
this.loading = true;
const { source, path, items } = this.fbdata;
try {
this.token = await ensureViewToken(source);
} catch (_) {
this.token = null;
}
let slides = null;
if (this.cfg.includeSubfolders && !getters.isShare()) {
try {
const result = await slidesFromSearch(source, path, this.cfg.maxItems);
slides = result.slides;
if (result.truncated) {
notify.showSuccessToast(this.$t("slideshow.truncated", { max: this.cfg.maxItems }));
}
} catch (_) {
notify.showErrorToast(this.$t("slideshow.searchFailed"));
}
}
if (!slides) {
slides = slidesFromListing(items, source);
}
if (this.cfg.shuffle) slides = shuffled(slides);
const startName = this.$route?.query?.start ?? state.route?.query?.start ?? "";
let start = startName ? slides.findIndex((s) => s.name === startName) : -1;
if (this.cfg.shuffle && start > 0) {
const [first] = slides.splice(start, 1);
slides.unshift(first);
start = 0;
}
this.slides = slides;
this.index = Math.max(0, start);
this.loading = false;
if (!slides.length) {
this.loadError = this.$t("slideshow.empty");
}
},
setVideoRef(el, layerIndex) {
if (el) this.videoEls[layerIndex] = el;
},
randomKenBurns() {
const rand = (min, max) => min + Math.random() * (max - min);
return {
"--kb-x": `${rand(-5, 5).toFixed(2)}%`,
"--kb-y": `${rand(-5, 5).toFixed(2)}%`,
"--kb-scale": rand(1.05, 1.17).toFixed(3),
"--kb-duration": `${this.cfg.duration}s`,
};
},
showSlide(i, animate) {
this.index = i;
const slide = this.slides[i];
if (!slide) return;
const target = animate ? 1 - this.active : this.active;
this.layerKey += 1;
this.layers[target] = {
kind: slide.kind,
url: slideUrl(slide, this.token),
key: this.layerKey,
style: slide.kind === "image" && this.cfg.kenBurns ? this.randomKenBurns() : {},
};
this.active = target;
this.$nextTick(() => {
Object.entries(this.videoEls).forEach(([layer, el]) => {
if (el && Number(layer) !== this.active) el.pause();
});
const video = this.videoEls[this.active];
if (video) {
video.currentTime = 0;
if (!this.paused) video.play().catch(() => {});
}
});
this.preloadNext();
},
preloadNext() {
const nextIndex = this.index + 1 < this.slides.length ? this.index + 1 : this.cfg.loop ? 0 : -1;
const next = nextIndex >= 0 ? this.slides[nextIndex] : null;
if (next && next.kind === "image") {
const url = slideUrl(next, this.token);
if (url) new Image().src = url;
}
},
clearTimer() {
clearTimeout(this.timerHandle);
this.timerHandle = null;
},
startTimer(ms) {
this.clearTimer();
this.timerStart = Date.now();
this.timerHandle = setTimeout(() => this.advance(), ms);
},
// Videos play to their natural end when the option is on. Everything else uses the slide duration.
scheduleCurrent() {
this.clearTimer();
const slide = this.currentSlide;
if (!slide) return;
if (slide.kind === "video" && this.cfg.playVideosToEnd) {
this.remaining = null;
return;
}
this.remaining = this.cfg.duration * 1000;
if (!this.paused) this.startTimer(this.remaining);
},
activeVideo() {
return this.videoEls[this.active] || null;
},
advance() {
const last = this.slides.length - 1;
if (this.index < last) {
this.showSlide(this.index + 1, true);
} else if (this.cfg.loop) {
this.showSlide(0, true);
} else {
// Stop on the last slide when loop is off.
this.pause();
return;
}
this.scheduleCurrent();
},
goNext() {
if (!this.slides.length) return;
this.advance();
this.revealChrome();
},
goPrev() {
if (!this.slides.length) return;
const last = this.slides.length - 1;
if (this.index > 0) {
this.showSlide(this.index - 1, true);
} else if (this.cfg.loop) {
this.showSlide(last, true);
}
this.scheduleCurrent();
this.revealChrome();
},
togglePause() {
if (this.paused) this.resume();
else this.pause();
this.revealChrome();
},
pause() {
if (this.timerHandle) {
const elapsed = Date.now() - this.timerStart;
this.remaining = Math.max(0, (this.remaining ?? 0) - elapsed);
this.clearTimer();
}
this.paused = true;
this.activeVideo()?.pause();
this.releaseWakeLock();
this.revealChrome();
},
resume() {
this.paused = false;
const slide = this.currentSlide;
if (slide?.kind === "video" && this.cfg.playVideosToEnd) {
this.activeVideo()?.play().catch(() => {});
} else if (this.remaining !== null) {
this.startTimer(this.remaining);
}
this.requestWakeLock();
this.scheduleHide();
},
onVideoEnded() {
if (!this.paused && this.currentSlide?.kind === "video" && this.cfg.playVideosToEnd) {
this.advance();
}
},
onMediaLoaded() {
this.failStreak = 0;
},
// Skip media that fails to load. Stop once every slide has failed in a row.
onMediaError() {
this.failStreak += 1;
if (this.failStreak >= this.slides.length) {
this.loadError = this.$t("slideshow.allFailed");
this.slides = [];
this.pause();
return;
}
if (!this.paused) {
clearTimeout(this.advanceHandle);
this.advanceHandle = setTimeout(() => {
if (!this.paused) this.advance();
}, 1000);
}
},
onStageClick() {
this.togglePause();
},
revealChrome() {
this.chromeVisible = true;
this.scheduleHide();
},
scheduleHide() {
clearTimeout(this.hideHandle);
if (this.paused) return;
this.hideHandle = setTimeout(() => {
this.chromeVisible = false;
}, CHROME_HIDE_MS);
},
onPointerMove() {
const now = Date.now();
if (now - this.lastPointer < POINTER_THROTTLE_MS) return;
this.lastPointer = now;
this.revealChrome();
},
onTouchStart(e) {
this.touchX = e.touches[0]?.clientX ?? null;
this.revealChrome();
},
onTouchEnd(e) {
if (this.touchX === null) return;
const dx = (e.changedTouches[0]?.clientX ?? this.touchX) - this.touchX;
this.touchX = null;
if (Math.abs(dx) < SWIPE_THRESHOLD_PX) return;
if (dx < 0) this.goNext();
else this.goPrev();
},
onKeyDown(e) {
if (getters.currentPromptName?.()) return;
switch (e.key) {
case " ":
e.preventDefault();
this.togglePause();
break;
case "ArrowRight":
e.preventDefault();
this.goNext();
break;
case "ArrowLeft":
e.preventDefault();
this.goPrev();
break;
case "f":
case "F":
this.toggleFullscreen();
break;
case "Escape":
// The browser exits fullscreen on Escape by itself, so only leave the slideshow when not fullscreen.
if (!(document.fullscreenElement || document.webkitFullscreenElement)) this.exit();
break;
}
},
enterFullscreen() {
const el = this.$refs.root;
if (!el) return;
const request = el.requestFullscreen || el.webkitRequestFullscreen;
if (!request) return;
try {
const result = request.call(el);
if (result && typeof result.catch === "function") result.catch(() => {});
} catch (_) { /* not allowed in this context */ }
},
exitFullscreen() {
const exit = document.exitFullscreen || document.webkitExitFullscreen;
if (!exit) return;
try {
const result = exit.call(document);
if (result && typeof result.catch === "function") result.catch(() => {});
} catch (_) { /* ignore */ }
},
toggleFullscreen() {
if (document.fullscreenElement || document.webkitFullscreenElement) this.exitFullscreen();
else this.enterFullscreen();
},
async requestWakeLock() {
if (this.wakeLock || !navigator.wakeLock) return;
try {
this.wakeLock = await navigator.wakeLock.request("screen");
} catch (_) { /* not available or denied */ }
},
releaseWakeLock() {
this.wakeLock?.release?.();
this.wakeLock = null;
},
exit() {
this.pause();
if (document.fullscreenElement || document.webkitFullscreenElement) this.exitFullscreen();
// Return to the preview of the slide that was showing last. Fall back to the folder if there is none.
// Replace the slideshow entry so Back from that preview doesn't return here.
const slide = this.currentSlide;
const target = slide ? buildItemUrl(slide.source, slide.path) : state.route.path;
router.replace({ path: target });
},
},
};
</script>
<style scoped>
.slideshow {
position: fixed;
top: 0;
right: 0;
bottom: 0;
/* left is set inline so the stage makes room for a pinned sidebar. */
z-index: 2000;
background: #000;
color: #fff;
overflow: hidden;
user-select: none;
}
.slideshow.cursor-hidden {
cursor: none;
}
.slideshow-stage {
position: absolute;
inset: 0;
}
.slide-layer {
position: absolute;
inset: 0;
opacity: 0;
transition: opacity 1.2s ease-in-out;
display: flex;
align-items: center;
justify-content: center;
}
.slide-layer.active {
opacity: 1;
z-index: 1;
}
.slideshow.no-transition .slide-layer {
transition: none;
}
.slide-layer img,
.slide-layer video {
width: 100%;
height: 100%;
object-fit: contain;
}
.slideshow.fit-cover .slide-layer img,
.slideshow.fit-cover .slide-layer video {
object-fit: cover;
}
/* Never display media larger than its natural size. Cover and fill only apply when enlarging. */
.slideshow.no-enlarge .slide-layer img,
.slideshow.no-enlarge .slide-layer video {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
/* Ken Burns: one shared keyframe driven by per-slide custom properties. */
.slide-layer img.kb {
animation: slideshow-kb var(--kb-duration, 5s) ease-in-out forwards;
}
.slideshow.is-paused .slide-layer img.kb {
animation-play-state: paused;
}
@keyframes slideshow-kb {
from {
transform: scale(1) translate(0, 0);
}
to {
transform: scale(var(--kb-scale, 1.1)) translate(var(--kb-x, 0), var(--kb-y, 0));
}
}
.slideshow-chrome {
opacity: 0;
transition: opacity 0.4s;
z-index: 2;
}
.slideshow.chrome-visible .slideshow-chrome,
.slideshow.is-paused .slideshow-chrome {
opacity: 1;
}
.slideshow-top-left {
position: absolute;
top: 1em;
left: 1em;
}
.slideshow-top-right {
position: absolute;
top: 1em;
right: 1em;
padding: 0.4em 0.8em;
border-radius: var(--borderRadius);
background: rgb(0 0 0 / 55%);
}
/* Round, icon-only floating button, matching the FloatingActionButton style. */
.slideshow-exit {
width: 2.75em;
height: 2.75em;
padding: 0;
border-radius: 50%;
background: rgb(0 0 0 / 55%);
box-shadow: 0 2px 8px rgb(0 0 0 / 40%);
display: inline-flex;
align-items: center;
justify-content: center;
}
/* Outside fullscreen the app navbar is visible, so the top buttons sit below it with extra padding. */
.slideshow.below-navbar .slideshow-top-left {
top: calc(var(--header-height) + 1em);
left: 1.5em;
}
.slideshow.below-navbar .slideshow-top-right {
top: calc(var(--header-height) + 1em);
right: 1.5em;
}
.slideshow-controls {
position: absolute;
bottom: 1.5em;
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 0.4em;
padding: 0.4em;
border-radius: var(--borderRadius);
background: rgb(0 0 0 / 55%);
backdrop-filter: blur(8px);
}
.slideshow .button {
color: #fff;
}
.slideshow-filename {
position: absolute;
bottom: 6em;
left: 0;
right: 0;
font-size: 1.5rem;
font-weight: 600;
text-align: center;
text-shadow: 0 1px 4px rgb(0 0 0 / 90%);
z-index: 2;
pointer-events: none;
}
.slideshow-empty {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1em;
z-index: 3;
}
</style>