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:
2026-03-22 00:41:40 +00:00
parent 451b04ad03
commit 8e0f7eb4d8
5 changed files with 111 additions and 0 deletions

View File

@@ -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));