From 84cbd02269c434a8c139f8f600864e7a7e3c181c Mon Sep 17 00:00:00 2001 From: Benjamin Erb Date: Fri, 6 Mar 2026 18:17:30 +0100 Subject: [PATCH] change behavior of book card component to also show actual hyperlinks on the read button (#3192) --- .../book-card/book-card.component.html | 4 +- .../app/shared/service/url-helper.service.ts | 37 ++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/booklore-ui/src/app/features/book/components/book-browser/book-card/book-card.component.html b/booklore-ui/src/app/features/book/components/book-browser/book-card/book-card.component.html index 8b559b07b..980782050 100644 --- a/booklore-ui/src/app/features/book/components/book-browser/book-card/book-card.component.html +++ b/booklore-ui/src/app/features/book/components/book-browser/book-card/book-card.component.html @@ -39,10 +39,10 @@ } @if (!_isSeriesViewActive && hasDigitalFile()) { - + [ariaLabel]="_isContinueReading ? ('book.card.alt.continueReading' | transloco) : (_isAudiobook ? ('book.card.alt.playAudiobook' | transloco) : ('book.card.alt.readBook' | transloco))"> } @if (isCheckboxEnabled) { diff --git a/booklore-ui/src/app/shared/service/url-helper.service.ts b/booklore-ui/src/app/shared/service/url-helper.service.ts index 411c76900..2a33ebf07 100644 --- a/booklore-ui/src/app/shared/service/url-helper.service.ts +++ b/booklore-ui/src/app/shared/service/url-helper.service.ts @@ -4,7 +4,7 @@ import {AuthService} from './auth.service'; import {BookService} from '../../features/book/service/book.service'; import {CoverGeneratorComponent} from '../components/cover-generator/cover-generator.component'; import {Router} from '@angular/router'; -import {Book} from '../../features/book/model/book.model'; +import {Book,BookType} from '../../features/book/model/book.model'; @Injectable({ providedIn: 'root' @@ -119,6 +119,41 @@ export class UrlHelperService { }); } + getBookPrimaryReadingUrl(book: Book) { + const bookType: BookType | undefined = book.primaryFile?.bookType; + + let baseUrl: string | null = null; + + switch (bookType) { + case 'PDF': + baseUrl = 'pdf-reader'; + break; + + case 'EPUB': + case 'FB2': + case 'MOBI': + case 'AZW3': + baseUrl = 'ebook-reader'; + break; + + case 'CBX': + baseUrl = 'cbx-reader'; + break; + + case 'AUDIOBOOK': + baseUrl = 'audiobook-player'; + break; + } + + if (!baseUrl) { + console.error('Unsupported book type:', bookType); + //Go to book URL as a fall-back + return this.getBookUrl(book); + } + + return this.router.createUrlTree([`/${baseUrl}/book/${book.id}`], undefined); + } + filterBooksBy(filterKey: string, filterValue: string) { if (filterKey === 'series') { return this.router.createUrlTree(['/series', encodeURIComponent(filterValue)])