Add catalog search on timeline header and fix Back to Timeline navigation.
Public GET /api/search over artists, movements, and paintings with a debounced header bar on the timeline; Back to Timeline resets zoom and gallery session. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
50fc253ab2
commit
acc4a91a08
@@ -13,6 +13,7 @@ const { logCuratorAction } = require('./audit-log');
|
||||
const authRoutes = require('./routes/auth');
|
||||
const { ensurePaintingImages, preloadArtistImagesLocal, replacePaintingImageFromUrl, replaceArtistPortraitFromUrl, clearPaintingImage, deletePainting, clearArtistPortrait, replacePaintingImageFromBuffer, replaceArtistPortraitFromBuffer, enrichPaintingRow, enrichArtistRow, IMAGE_DIR } = require('./image-service');
|
||||
const { getVersionInfo } = require('./version-info');
|
||||
const { searchCatalog } = require('./search-service');
|
||||
const { searchGoogleImagesFirst, searchArtistPortraitFirst, searchPaintingImagesMany, searchArtistPortraitMany, fetchImageBuffer, friendlyImageFetchError, pickExt } = require('../scripts/image-fetcher');
|
||||
|
||||
const app = express();
|
||||
@@ -181,6 +182,23 @@ const INFLUENCED_SQL = `
|
||||
WHERE pis.source_painting_id = $1 AND pis.source_type = 'painting'
|
||||
ORDER BY p.year NULLS LAST, p.title`;
|
||||
|
||||
app.get('/api/search', async (req, res) => {
|
||||
try {
|
||||
const q = typeof req.query.q === 'string' ? req.query.q : '';
|
||||
const limit = parseInt(req.query.limit, 10);
|
||||
const types = typeof req.query.types === 'string' ? req.query.types : undefined;
|
||||
const result = await searchCatalog(q, {
|
||||
limit: Number.isFinite(limit) ? limit : 20,
|
||||
types,
|
||||
});
|
||||
res.setHeader('Cache-Control', 'no-store');
|
||||
res.json(result);
|
||||
} catch (err) {
|
||||
console.error('Search error:', err.message);
|
||||
res.status(500).json({ error: 'Search failed' });
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/api/timeline', async (req, res) => {
|
||||
try {
|
||||
const { start, end } = req.query;
|
||||
|
||||
Reference in New Issue
Block a user