Update admin gallery to fetch images directly from Cloudinary
Integrates Cloudinary API to fetch image details for the admin gallery page, replacing previous data sources. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 23852c00-4779-460a-9e0c-d09fee4b6c92 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: eb361b34-3147-44e1-a7c3-11100d3e83b8 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/23852c00-4779-460a-9e0c-d09fee4b6c92/ncMMRQ9 Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -7,6 +7,7 @@ import { generateDailyHoroscopes, getHoroscopesForToday, getOrGenerateHoroscope
|
||||
import { analyzeAllArticleImages, getCachedFocalPoints } from "./focal-point";
|
||||
import { optimizeImage } from "./image-optimizer";
|
||||
import { getAuthUrl, exchangeCodeForTokens, isConnected, fetchGalleryFromDropbox, getValidAccessToken, migrateGalleryToCloudinary } from "./dropbox";
|
||||
import { listCloudinaryGalleryDetailed } from "./cloudinary";
|
||||
import multer from "multer";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
@@ -411,6 +412,28 @@ export async function registerRoutes(
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/api/admin/cloudinary-gallery", async (_req, res) => {
|
||||
try {
|
||||
const images = await listCloudinaryGalleryDetailed();
|
||||
const aPath = path.join(process.cwd(), "server/gallery-artist-overrides.json");
|
||||
let artistOverrides: Record<string, string> = {};
|
||||
if (fs.existsSync(aPath)) {
|
||||
artistOverrides = JSON.parse(fs.readFileSync(aPath, "utf-8"));
|
||||
}
|
||||
const result = images.map((img) => {
|
||||
const overriddenArtist = artistOverrides[img.fileName];
|
||||
return {
|
||||
...img,
|
||||
artist: overriddenArtist || img.artist,
|
||||
artistOverridden: !!overriddenArtist,
|
||||
};
|
||||
});
|
||||
res.json(result);
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/api/gallery/artists", (_req, res) => {
|
||||
try {
|
||||
const aPath = path.join(process.cwd(), "server/gallery-artist-overrides.json");
|
||||
|
||||
Reference in New Issue
Block a user