Add functionality to delete images from the gallery and Cloudinary
Implement image deletion functionality, including a confirmation dialog and API endpoint for removing images from Cloudinary and updating the gallery map. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 23852c00-4779-460a-9e0c-d09fee4b6c92 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 37efc56d-aeff-47ff-8064-9aa64d8b204c 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:
+29
-1
@@ -7,7 +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 { listCloudinaryGalleryDetailed, deleteFromCloudinary } from "./cloudinary";
|
||||
import multer from "multer";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
@@ -434,6 +434,34 @@ export async function registerRoutes(
|
||||
}
|
||||
});
|
||||
|
||||
app.post("/api/admin/cloudinary-gallery/delete", async (req, res) => {
|
||||
try {
|
||||
const { publicId } = req.body;
|
||||
if (!publicId) {
|
||||
return res.status(400).json({ message: "publicId required" });
|
||||
}
|
||||
const success = await deleteFromCloudinary(publicId);
|
||||
if (!success) {
|
||||
return res.status(500).json({ message: "Löschen fehlgeschlagen" });
|
||||
}
|
||||
|
||||
const mapPath = path.join(process.cwd(), "server/cloudinary-gallery-map.json");
|
||||
if (fs.existsSync(mapPath)) {
|
||||
const map = JSON.parse(fs.readFileSync(mapPath, "utf-8"));
|
||||
for (const [key, val] of Object.entries(map)) {
|
||||
if (val === publicId) {
|
||||
delete map[key];
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(mapPath, JSON.stringify(map, null, 2));
|
||||
}
|
||||
|
||||
res.json({ ok: true, deleted: publicId });
|
||||
} 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