Update gallery to display images from the correct Dropbox folder
Refactor `server/dropbox.ts` to use `/family room/photos/oddaje/izvajalci selekcija` as the root for gallery images, replacing the old static list of folders. The `server/gallery-data.json` file is updated to reflect the new image structure and URLs. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 71ac514c-23c3-448b-8fe3-8664569d6305 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/VgutZ7W Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
146f797809
commit
c8e2684915
@ -2,20 +2,7 @@ import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const TOKEN_PATH = path.join(process.cwd(), "server/dropbox-token.json");
|
||||
const GALLERY_FOLDERS = [
|
||||
"/folx stadl bad tölz 25",
|
||||
"/folx stadl bad tölz 23",
|
||||
"/folx stadl 2022 attersee",
|
||||
"/a guadi musi 2023",
|
||||
"/hb fest 2023",
|
||||
"/slike epd",
|
||||
"/simon wild photos",
|
||||
"/adria soccer 2024",
|
||||
"/gipfelstammtisch 2024",
|
||||
"/die kaiser fanreise",
|
||||
"/sanabela 2023",
|
||||
"/ainringer musikfrühling 2022",
|
||||
];
|
||||
const GALLERY_ROOT = "/family room/photos/oddaje/izvajalci selekcija";
|
||||
|
||||
interface DropboxTokens {
|
||||
access_token: string;
|
||||
@ -225,22 +212,22 @@ export async function fetchGalleryFromDropbox(): Promise<GalleryImage[]> {
|
||||
if (!accessToken) return [];
|
||||
|
||||
try {
|
||||
const topEntries = await listFolder(accessToken, GALLERY_ROOT);
|
||||
const folders = topEntries.filter((e: any) => e[".tag"] === "folder");
|
||||
const images: GalleryImage[] = [];
|
||||
|
||||
for (const folderPath of GALLERY_FOLDERS) {
|
||||
for (const folder of folders) {
|
||||
try {
|
||||
const entries = await listFolder(accessToken, folderPath, true);
|
||||
const imageFiles = entries.filter(
|
||||
const folderName = folder.name;
|
||||
const folderEntries = await listFolder(accessToken, folder.path_lower);
|
||||
const imageFiles = folderEntries.filter(
|
||||
(e: any) => e[".tag"] === "file" && /\.(jpg|jpeg|png|webp|gif)$/i.test(e.name)
|
||||
);
|
||||
|
||||
const limitedFiles = imageFiles.slice(0, 8);
|
||||
const paths = limitedFiles.map((f: any) => f.path_lower);
|
||||
const paths = imageFiles.map((f: any) => f.path_lower);
|
||||
const tempLinks = await getTemporaryLinks(accessToken, paths);
|
||||
|
||||
const folderName = folderPath.split("/").pop() || folderPath;
|
||||
|
||||
for (const file of limitedFiles) {
|
||||
for (const file of imageFiles) {
|
||||
const link = tempLinks.get(file.path_lower) || "";
|
||||
if (link) {
|
||||
images.push({
|
||||
@ -253,7 +240,7 @@ export async function fetchGalleryFromDropbox(): Promise<GalleryImage[]> {
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error(`Folder ${folderPath} error:`, err.message);
|
||||
console.error(`Folder ${folder.name} error:`, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user