Add support for fb2 books (#1757)

This commit is contained in:
Dmitry Manannikov
2025-12-13 20:16:56 -08:00
committed by GitHub
parent 0486a4f070
commit 708e851e0b
12 changed files with 1408 additions and 8 deletions

View File

@@ -38,7 +38,7 @@
<p-button [rounded]="true" icon="pi pi-info" class="info-btn" (click)="openBookInfo(book)"></p-button>
}
<p-button [hidden]="isSeriesViewActive()" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
<p-button [hidden]="isSeriesViewActive() || !canReadBook()" [rounded]="true" icon="pi pi-book" class="read-btn" (click)="readBook(book)"></p-button>
@if (isCheckboxEnabled) {
<p-checkbox

View File

@@ -618,6 +618,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
case 'epub':
case 'mobi':
case 'azw3':
case 'fb2':
return 'pi pi-book';
case 'cbz':
case 'cbr':
@@ -641,6 +642,10 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
return this.isAdmin() || (this.userPermissions?.canEditMetadata ?? false);
}
canReadBook(): boolean {
return this.book?.bookType !== 'FB2';
}
private hasDownloadPermission(): boolean {
return this.isAdmin() || (this.userPermissions?.canDownload ?? false);
}

View File

@@ -3,7 +3,7 @@ import {CbxBackgroundColor, CbxFitMode, CbxPageSpread, CbxPageViewMode, CbxScrol
import {BookReview} from '../components/book-reviews/book-review-service';
import {ZoomType} from 'ngx-extended-pdf-viewer';
export type BookType = "PDF" | "EPUB" | "CBX";
export type BookType = "PDF" | "EPUB" | "CBX" | "FB2";
export enum AdditionalFileType {
ALTERNATIVE_FORMAT = 'ALTERNATIVE_FORMAT',

View File

@@ -1,7 +1,7 @@
import {SortOption} from './sort.model';
export type LibraryScanMode = 'FILE_AS_BOOK' | 'FOLDER_AS_BOOK';
export type BookFileType = 'PDF' | 'EPUB' | 'CBX';
export type BookFileType = 'PDF' | 'EPUB' | 'CBX' | 'FB2';
export interface Library {
id?: number;

View File

@@ -459,7 +459,7 @@
<p-splitbutton label="Read" icon="pi pi-book" [model]="readItems" (onClick)="read(book.id, 'ngx')" severity="primary"/>
}
}
@if (book!.bookType !== 'PDF') {
@if (book!.bookType !== 'PDF' && book!.bookType !== 'FB2') {
<p-button label="Read" icon="pi pi-book" (onClick)="read(book?.metadata!.bookId, undefined)" severity="primary"/>
}
<p-button label="Shelf" icon="pi pi-folder" severity="secondary" outlined (onClick)="assignShelf(book.id)"></p-button>

View File

@@ -89,7 +89,7 @@
[maxFileSize]="maxFileSizeBytes"
[customUpload]="true"
[multiple]="true"
accept=".pdf,.epub,.cbz,.cbr,.cb7"
accept=".pdf,.epub,.cbz,.cbr,.cb7,.fb2"
(onSelect)="onFilesSelect($event)"
(uploadHandler)="uploadFiles($event)"
[disabled]="value === 'library' ? (!selectedLibrary || !selectedPath) : false">
@@ -176,7 +176,7 @@
</div>
<h3 class="empty-title">Drag and Drop Files</h3>
<p class="empty-description">
Supported formats: <strong>.pdf</strong>, <strong>.epub</strong>, <strong>.cbz</strong>, <strong>.cbr</strong>, <strong>.cb7</strong>
Supported formats: <strong>.pdf</strong>, <strong>.epub</strong>, <strong>.cbz</strong>, <strong>.cbr</strong>, <strong>.cb7</strong>, <strong>.fb2</strong>
<br/>
Maximum file size: 100 MB per file
</p>