Add Docs module for searching and organizing PDFs and EPUBs

Create a new Docs module that consolidates PDF and eBook handling into a
unified system with subjects and authors support. This replaces the
separate PDF/eBook modelers with a single Doc model backed by an
alembic migration (rename ebook to doc).

Key changes:
- New modules/docs package with models, API, extractors, and lib
- Subject and author metadata extraction with case-insensitive
  normalization for cleaner PDF metadata
- Frontend Docs pages with AuthorsPage, SubjectsPage using
  CollectionTable, and doc card deletion
- Global search integration for subjects and authors
- Generic collection item count support
- Frontend file card metadata adjusted to match collection sort
- Bump yt-dlp version
This commit is contained in:
Roland 2026-03-17 18:35:57 -06:00
parent 4a21499bdd
commit aefc7b1def
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
90 changed files with 4484 additions and 1189 deletions

View file

@ -811,6 +811,38 @@ export async function fetchDomains() {
}
}
export async function fetchAuthors() {
const response = await apiGet(`${COLLECTIONS_API}?kind=author`);
if (response.ok) {
let data = await response.json();
return [data['collections'], data['totals']['collections']];
} else {
const message = await getErrorMessage(response, 'Unable to fetch Authors. See server logs.');
toast({
type: 'error',
title: 'Authors Error',
description: message,
time: 5000,
});
}
}
export async function fetchSubjects() {
const response = await apiGet(`${COLLECTIONS_API}?kind=subject`);
if (response.ok) {
let data = await response.json();
return [data['collections'], data['totals']['collections']];
} else {
const message = await getErrorMessage(response, 'Unable to fetch Subjects. See server logs.');
toast({
type: 'error',
title: 'Subjects Error',
description: message,
time: 5000,
});
}
}
export async function fetchChannels() {
const response = await apiGet(`${COLLECTIONS_API}?kind=channel`);
if (response.ok) {
@ -1378,6 +1410,11 @@ export function downloadArchiveMember(path, member) {
window.open(`${API_URI}/files/zip/download?${params}`, '_blank');
}
export function getArchiveMemberUrl(path, member) {
const params = new URLSearchParams({path, member});
return `${API_URI}/files/zip/download?${params}`;
}
export async function fetchFilesProgress() {
const response = await apiGet(`${API_URI}/files/worker_status`);
if (response.ok) {
@ -1817,6 +1854,8 @@ export async function searchSuggestions(search_str) {
return {
channels: content.channels,
domains: content.domains,
authors: content.authors || [],
subjects: content.subjects || [],
}
} else {
console.error('Failed to get file search suggestions!');
@ -2056,3 +2095,60 @@ export async function fetchSuggestedUserAgent() {
}
return '';
}
// Docs API
const DOCS_API = '/api/docs';
export async function getDocStatistics() {
return await apiGet(`${DOCS_API}/statistics`);
}
export async function getDoc(docId) {
return await apiGet(`${DOCS_API}/${docId}`);
}
export async function getDocByFileGroup(fileGroupId) {
return await apiGet(`${DOCS_API}/view/${fileGroupId}`);
}
export async function deleteDocs(docIds) {
const ids = Array.isArray(docIds) ? docIds.join(',') : docIds;
return await apiDelete(`${DOCS_API}/${ids}`);
}
export async function searchDocs(offset, limit, searchStr, order, tagNames, author, subject) {
offset = parseInt(offset || 0);
limit = parseInt(limit || DEFAULT_LIMIT);
let body = {offset, limit};
if (searchStr) {
body['search_str'] = searchStr;
}
if (order) {
body['order_by'] = order;
}
if (tagNames && tagNames.length > 0) {
body['tag_names'] = tagNames;
}
if (author) {
body['author'] = author;
}
if (subject) {
body['subject'] = subject;
}
console.debug('searching docs', body);
const response = await apiPost(`${DOCS_API}/search`, body);
if (response.ok) {
let data = await response.json();
return [data['file_groups'], data['totals']['file_groups']];
} else {
const message = await getErrorMessage(response, 'Cannot search docs. See server logs.');
toast({
type: 'error',
title: 'Unable to search docs',
description: message,
time: 5000,
});
throw Error(message);
}
}