Add maintenance menu (top-right ⚙) with generate missing PDF thumbnails
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
19
server.mjs
19
server.mjs
@@ -544,6 +544,25 @@ app.delete('/api/pdfs/:id', (req, res) => {
|
||||
ok(res);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Maintenance
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
app.post('/api/maintenance/pdf-thumbs', (req, res) => {
|
||||
const pdfs = list_pdfs();
|
||||
let generated = 0;
|
||||
for (const pdf of pdfs) {
|
||||
if (pdf.thumb_filename) continue;
|
||||
const thumb_prefix = join('./data/pdfs', pdf.id + '-thumb');
|
||||
const thumb_file = generate_pdf_thumb(join('./data/pdfs', pdf.filename), thumb_prefix);
|
||||
if (thumb_file) {
|
||||
set_pdf({ ...pdf, thumb_filename: thumb_file });
|
||||
generated++;
|
||||
}
|
||||
}
|
||||
ok(res, { generated, total: pdfs.length });
|
||||
});
|
||||
|
||||
// SPA fallback — serve index.html for any non-API, non-asset path
|
||||
const INDEX_HTML = new URL('./public/index.html', import.meta.url).pathname;
|
||||
app.get('/{*path}', (req, res) => res.sendFile(INDEX_HTML));
|
||||
|
||||
Reference in New Issue
Block a user