* feat: Add custom font support for EPUB reader This commit introduces the ability to manage and use custom fonts in the EPUB reader. Key changes include: **Backend:** - Added `CustomFontService` for handling custom font operations. - Introduced `CustomFontController` for API endpoints. - Created `CustomFontEntity` and `CustomFontRepository` for database interactions. - Added `CustomFontMapper` and `CustomFontDto` for data transformation. - Updated `SecurityConfig` to include JWT filter for custom fonts. - Enhanced `GlobalExceptionHandler` to handle custom font-related exceptions. - Added database migrations: - `V83__Create_Custom_Font_Table.sql` for creating the custom font table. - `V84__Add_Custom_Font_To_Epub_Preferences.sql` for integrating custom fonts with EPUB preferences. **Frontend:** - Added `CustomFontsComponent` and `FontUploadDialogComponent` for managing custom fonts in the settings UI. - Updated `EpubReaderPreferencesComponent` to include custom font options. - Introduced `CustomFontService` and `CustomFontModel` for frontend logic and data handling. - Enhanced `SettingsComponent` to integrate custom font management. **Other Changes:** - Updated `EpubViewerPreferences` and `EpubViewerPreferencesEntity` to support custom fonts. - Modified existing components and services to accommodate the new feature. This feature enhances the user experience by allowing personalized font choices for EPUB reading. * fix: custom font does not apply after page layout changed * fix: duplicate API call when change EPUB global settings * fix: some code review items, extract shared filter logic and improve UX - Extract AbstractQueryParameterJwtFilter base class to reduce code duplication between CoverJwtFilter and CustomFontJwtFilter - Remove cssIdentifier and fontUrl fields from CustomFont model (no longer needed) - Add font name sanitization to prevent XSS and ensure data integrity - Improve error handling in CustomFontService with proper APIException usage - Replace RuntimeException handler with specific IllegalStateException and UnsupportedOperationException handlers in GlobalExceptionHandler - Add skeleton loading states for font previews and font dropdowns - Improve font loading state management in epub-reader component - Create shared custom-font.util.ts for dropdown population logic - Use reactive font$ subscription for real-time font updates in preferences - Make DB migrations idempotent with IF NOT EXISTS clauses - Optimize font file validation to read only header bytes instead of entire file * chore: re-version migration scripts * Fix: Kobo sync missing book covers (v1.16.4) (#2147) Co-authored-by: acx10 <acx10@users.noreply.github.com> * Fix: correctly update book cover hash on metadata refresh (#2149) Co-authored-by: acx10 <acx10@users.noreply.github.com> * Introduce Vitest as the frontend Angular testing framework for Booklore (#2150) Co-authored-by: acx10 <acx10@users.noreply.github.com> * Add Vitest frontend tests to CI with JUnit reporting and coverage (#2151) Co-authored-by: acx10 <acx10@users.noreply.github.com> * Update PR template to capture frontend test details * Add instructions for running Angular frontend tests --------- Co-authored-by: ACX <8075870+acx10@users.noreply.github.com> Co-authored-by: acx10 <acx10@users.noreply.github.com>
269 lines
6.4 KiB
TypeScript
269 lines
6.4 KiB
TypeScript
import {Shelf} from './shelf.model';
|
|
import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrollMode, NewPdfReaderSetting} from '../../settings/user-management/user.service';
|
|
import {BookReview} from '../components/book-reviews/book-review-service';
|
|
import {ZoomType} from 'ngx-extended-pdf-viewer';
|
|
|
|
export type BookType = "PDF" | "EPUB" | "CBX" | "FB2";
|
|
|
|
export enum AdditionalFileType {
|
|
ALTERNATIVE_FORMAT = 'ALTERNATIVE_FORMAT',
|
|
SUPPLEMENTARY = 'SUPPLEMENTARY'
|
|
}
|
|
|
|
export interface FileInfo {
|
|
fileName?: string;
|
|
filePath?: string;
|
|
fileSubPath?: string;
|
|
fileSizeKb?: number;
|
|
}
|
|
|
|
export interface AdditionalFile extends FileInfo {
|
|
id: number;
|
|
bookId: number;
|
|
additionalFileType: AdditionalFileType;
|
|
description?: string;
|
|
addedOn?: string;
|
|
}
|
|
|
|
export interface Book extends FileInfo {
|
|
id: number;
|
|
bookType: BookType;
|
|
libraryId: number;
|
|
libraryName: string;
|
|
metadata?: BookMetadata;
|
|
shelves?: Shelf[];
|
|
lastReadTime?: string;
|
|
addedOn?: string;
|
|
epubProgress?: EpubProgress;
|
|
pdfProgress?: PdfProgress;
|
|
cbxProgress?: CbxProgress;
|
|
koreaderProgress?: KoReaderProgress;
|
|
koboProgress?: KoboProgress;
|
|
seriesCount?: number | null;
|
|
seriesBooks?: Book[] | null;
|
|
metadataMatchScore?: number | null;
|
|
personalRating?: number | null;
|
|
readStatus?: ReadStatus;
|
|
dateFinished?: string;
|
|
libraryPath?: { id: number };
|
|
alternativeFormats?: AdditionalFile[];
|
|
supplementaryFiles?: AdditionalFile[];
|
|
[key: string]: unknown;
|
|
}
|
|
|
|
export interface EpubProgress {
|
|
cfi: string;
|
|
percentage: number;
|
|
}
|
|
|
|
export interface PdfProgress {
|
|
page: number;
|
|
percentage: number;
|
|
}
|
|
|
|
export interface CbxProgress {
|
|
page: number;
|
|
percentage: number;
|
|
}
|
|
|
|
export interface KoReaderProgress {
|
|
percentage: number;
|
|
}
|
|
|
|
export interface KoboProgress {
|
|
percentage: number;
|
|
}
|
|
|
|
export interface BookMetadata {
|
|
bookId: number;
|
|
title?: string;
|
|
subtitle?: string;
|
|
publisher?: string;
|
|
publishedDate?: string;
|
|
description?: string;
|
|
seriesName?: string;
|
|
seriesNumber?: number | null;
|
|
seriesTotal?: number | null;
|
|
isbn13?: string;
|
|
isbn10?: string;
|
|
asin?: string;
|
|
goodreadsId?: string;
|
|
comicvineId?: string;
|
|
hardcoverId?: string;
|
|
hardcoverBookId?: number | null;
|
|
googleId?: string;
|
|
pageCount?: number | null;
|
|
language?: string;
|
|
rating?: number | null;
|
|
reviewCount?: number | null;
|
|
amazonRating?: number | null;
|
|
amazonReviewCount?: number | null;
|
|
goodreadsRating?: number | null;
|
|
goodreadsReviewCount?: number | null;
|
|
hardcoverRating?: number | null;
|
|
hardcoverReviewCount?: number | null;
|
|
lubimyczytacId?: string;
|
|
lubimyczytacRating?: number | null;
|
|
coverUpdatedOn?: string;
|
|
authors?: string[];
|
|
categories?: string[];
|
|
moods?: string[];
|
|
tags?: string[];
|
|
provider?: string;
|
|
providerBookId?: string;
|
|
thumbnailUrl?: string | null;
|
|
reviews?: BookReview[];
|
|
titleLocked?: boolean;
|
|
subtitleLocked?: boolean;
|
|
publisherLocked?: boolean;
|
|
publishedDateLocked?: boolean;
|
|
descriptionLocked?: boolean;
|
|
seriesNameLocked?: boolean;
|
|
seriesNumberLocked?: boolean;
|
|
seriesTotalLocked?: boolean;
|
|
isbn13Locked?: boolean;
|
|
isbn10Locked?: boolean;
|
|
asinLocked?: boolean;
|
|
comicvineIdLocked?: boolean;
|
|
goodreadsIdLocked?: boolean;
|
|
hardcoverIdLocked?: boolean;
|
|
hardcoverBookIdLocked?: boolean;
|
|
googleIdLocked?: boolean;
|
|
pageCountLocked?: boolean;
|
|
languageLocked?: boolean;
|
|
amazonRatingLocked?: boolean;
|
|
amazonReviewCountLocked?: boolean;
|
|
goodreadsRatingLocked?: boolean;
|
|
goodreadsReviewCountLocked?: boolean;
|
|
hardcoverRatingLocked?: boolean;
|
|
hardcoverReviewCountLocked?: boolean;
|
|
lubimyczytacIdLocked?: boolean;
|
|
lubimyczytacRatingLocked?: boolean;
|
|
coverUpdatedOnLocked?: boolean;
|
|
authorsLocked?: boolean;
|
|
categoriesLocked?: boolean;
|
|
moodsLocked?: boolean;
|
|
tagsLocked?: boolean;
|
|
coverLocked?: boolean;
|
|
reviewsLocked?: boolean;
|
|
[key: string]: unknown;
|
|
}
|
|
|
|
export interface MetadataClearFlags {
|
|
title?: boolean;
|
|
subtitle?: boolean;
|
|
publisher?: boolean;
|
|
publishedDate?: boolean;
|
|
description?: boolean;
|
|
seriesName?: boolean;
|
|
seriesNumber?: boolean;
|
|
seriesTotal?: boolean;
|
|
isbn13?: boolean;
|
|
isbn10?: boolean;
|
|
asin?: boolean;
|
|
goodreadsId?: boolean;
|
|
comicvineId?: boolean;
|
|
hardcoverId?: boolean;
|
|
hardcoverBookId?: boolean;
|
|
googleId?: boolean;
|
|
pageCount?: boolean;
|
|
language?: boolean;
|
|
amazonRating?: boolean;
|
|
amazonReviewCount?: boolean;
|
|
goodreadsRating?: boolean;
|
|
goodreadsReviewCount?: boolean;
|
|
hardcoverRating?: boolean;
|
|
hardcoverReviewCount?: boolean;
|
|
lubimyczytacId?: boolean;
|
|
lubimyczytacRating?: boolean;
|
|
authors?: boolean;
|
|
categories?: boolean;
|
|
moods?: boolean;
|
|
tags?: boolean;
|
|
cover?: boolean;
|
|
}
|
|
|
|
export interface MetadataUpdateWrapper {
|
|
metadata: BookMetadata;
|
|
clearFlags: MetadataClearFlags;
|
|
}
|
|
|
|
export interface PdfViewerSetting {
|
|
zoom: ZoomType;
|
|
spread: 'off' | 'even' | 'odd';
|
|
}
|
|
|
|
export interface EpubViewerSetting {
|
|
theme: string;
|
|
font: string;
|
|
fontSize: number;
|
|
flow: string;
|
|
lineHeight: number;
|
|
letterSpacing: number;
|
|
spread: string;
|
|
customFontId?: number | null;
|
|
}
|
|
|
|
export interface CbxViewerSetting {
|
|
pageSpread: CbxPageSpread;
|
|
pageViewMode: CbxPageViewMode;
|
|
fitMode: CbxFitMode;
|
|
scrollMode?: CbxScrollMode;
|
|
backgroundColor?: CbxBackgroundColor;
|
|
}
|
|
|
|
export interface BookSetting {
|
|
pdfSettings?: PdfViewerSetting;
|
|
epubSettings?: EpubViewerSetting;
|
|
cbxSettings?: CbxViewerSetting;
|
|
newPdfSettings?: NewPdfReaderSetting;
|
|
[key: string]: unknown;
|
|
}
|
|
|
|
export interface BookRecommendation {
|
|
book: Book;
|
|
similarityScore: number;
|
|
}
|
|
|
|
export interface BulkMetadataUpdateRequest {
|
|
bookIds: number[];
|
|
authors?: string[];
|
|
clearAuthors?: boolean;
|
|
publisher?: string;
|
|
clearPublisher?: boolean;
|
|
language?: string;
|
|
clearLanguage?: boolean;
|
|
seriesName?: string;
|
|
clearSeriesName?: boolean;
|
|
seriesTotal?: number | null;
|
|
clearSeriesTotal?: boolean;
|
|
publishedDate?: string | null;
|
|
clearPublishedDate?: boolean;
|
|
genres?: string[];
|
|
clearGenres?: boolean;
|
|
moods?: string[];
|
|
clearMoods?: boolean;
|
|
tags?: string[];
|
|
clearTags?: boolean;
|
|
mergeCategories?: boolean;
|
|
mergeMoods?: boolean;
|
|
mergeTags?: boolean;
|
|
}
|
|
|
|
export interface BookDeletionResponse {
|
|
deleted: number[];
|
|
failedFileDeletions: number[];
|
|
}
|
|
|
|
export enum ReadStatus {
|
|
UNREAD = 'UNREAD',
|
|
READING = 'READING',
|
|
RE_READING = 'RE_READING',
|
|
READ = 'READ',
|
|
PARTIALLY_READ = 'PARTIALLY_READ',
|
|
PAUSED = 'PAUSED',
|
|
WONT_READ = 'WONT_READ',
|
|
ABANDONED = 'ABANDONED',
|
|
UNSET = 'UNSET'
|
|
}
|