mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Adds book deletion and restore to the web client.
Soft deletes books so the scan keeps their paths reserved, lists the deleted books on a themed page, and lets the user restore them. Updates the API, bundled themes, localization, documentation and tests. Closes #213
This commit is contained in:
1 parent
ef5ede6325
commit
f26b07d4ff
125 files changed
+9856
-378
No files matched your search
@@ -49,7 +49,9 @@ Opening a book library shows a page with the library title, a search box, a sort
|
||||
- **The alpha picker** jumps to titles starting with a chosen character. It offers All, then the number and symbol keys, then A to Z. You can also press a letter key to filter, and press Escape to clear the filter.
|
||||
- **Pagination** splits the list into pages when you have it enabled, with previous and next buttons and a page indicator. When it is off, the whole list is shown and the count is the total.
|
||||
|
||||
Each book is a card with its cover and title. Clicking a card opens the book in the reader; a book can only be opened when a reader for its format is enabled for the library. Right-clicking a card, or using its actions button, opens a menu with **Read** and **View details**.
|
||||
Each book is a card with its cover and title. Clicking a card opens the book in the reader; a book can only be opened when a reader for its format is enabled for the library. Right-clicking a card, or using its actions button, opens a menu with **Read**, **View details** and **Delete**.
|
||||
|
||||
Deleting a book asks for confirmation and moves it to the library's **Deleted items**, together with the metadata and artwork Lumina stored for it. The file behind it is left untouched. The book stops appearing in the library, and an automatic scan does not add it back. If the file is later removed from disk, the next scan permanently removes the deleted book, including the metadata and artwork kept for it. The **Deleted items** button on the library page lists the deleted books and restores one when you select **Restore**. The book details page offers the same deletion with its **Delete book** button.
|
||||
|
||||
## Reading a book
|
||||
|
||||
|
||||
@@ -26,13 +26,17 @@
|
||||
- [Get Reading Manifest](#get-reading-manifest)
|
||||
- [Get Reading Manifest Request](#get-reading-manifest-request)
|
||||
- [Get Reading Manifest Response](#get-reading-manifest-response)
|
||||
- [Get Reading Resource](#get-reading-resource)
|
||||
- [Get Reading Resource Request](#get-reading-resource-request)
|
||||
- [Get Reading Resource Response](#get-reading-resource-response)
|
||||
- [Get Reading Section](#get-reading-section)
|
||||
- [Get Reading Section Request](#get-reading-section-request)
|
||||
- [Get Reading Section Response](#get-reading-section-response)
|
||||
- [Get Reading Resource](#get-reading-resource)
|
||||
- [Get Reading Resource Request](#get-reading-resource-request)
|
||||
- [Get Reading Resource Response](#get-reading-resource-response)
|
||||
- [Get Deleted Books](#get-deleted-books)
|
||||
- [Get Deleted Books Request](#get-deleted-books-request)
|
||||
- [Get Deleted Books Response](#get-deleted-books-response)
|
||||
- [Delete Book](#delete-book)
|
||||
- [Restore Book](#restore-book)
|
||||
|
||||
## Book
|
||||
|
||||
@@ -872,14 +876,64 @@ Returns the binary resource identified by `resourceKey` of the book identified b
|
||||
|
||||
The response is the raw bytes of the resource, served with the `Content-Type` of the resource and with `X-Content-Type-Options: nosniff`. A resource whose declared media type could be rendered as an active document (for example an SVG) is served as an opaque binary download instead.
|
||||
|
||||
### Delete Book
|
||||
### Get Deleted Books
|
||||
|
||||
#### Get Deleted Books Request
|
||||
|
||||
```js
|
||||
DELETE api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{bookId}
|
||||
GET api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/deleted-items
|
||||
```
|
||||
|
||||
Returns the books of the media library identified by the route that the user deleted and that can still be restored. The books are ordered by the time they were deleted, most recent first.
|
||||
|
||||
#### Get Deleted Books Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
Deletes the book identified by the route, together with its stored artwork.
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "f4c8a9a0-3d77-4e86-9b1a-2f7a5c4b6d31",
|
||||
"libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
|
||||
"title": "The Fellowship of the Ring",
|
||||
"originalTitle": null,
|
||||
"path": "/media/libraries/books/the-fellowship-of-the-ring.pdf",
|
||||
"deletedOnUtc": "2026-11-12T10:15:30Z",
|
||||
"coverPath": "/media/books/tolkien/the-fellowship-of-the-ring/cover.jpg"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Delete Book
|
||||
|
||||
#### Delete Book Request
|
||||
|
||||
```js
|
||||
DELETE api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{bookId}
|
||||
```
|
||||
|
||||
#### Delete Book Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
Moves the book identified by the route to the deleted items of its media library. The book is no longer listed, read or materialized again by automatic scans, and its metadata and stored artwork are kept so that it can be restored. The deleted row keeps its file system path reserved in the library, so a later scan does not add the file back. The path stays reserved until the book is restored, or until the file disappears from disk and the scan permanently removes the deleted row.
|
||||
|
||||
### Restore Book
|
||||
|
||||
#### Restore Book Request
|
||||
|
||||
```js
|
||||
POST api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{bookId}/restore
|
||||
```
|
||||
|
||||
#### Restore Book Response
|
||||
|
||||
```js
|
||||
200 Ok
|
||||
```
|
||||
|
||||
Restores the deleted book identified by the route to the catalogue of its media library, together with the metadata and artwork that were kept while it was deleted. The path of the restored book stops being reserved by the deletion state, and the book is returned to the ordinary catalogue reads and scans.
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
GET {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/deleted-items
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
POST {{host}}/api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/books/{{$guid}}/restore
|
||||
Authorization: Bearer {{ACCESS_TOKEN}}
|
||||
@@ -20,6 +20,8 @@ The web client of Lumina is a themed shell: every page is rendered inside the te
|
||||
- [The audio player sub templates](#the-audio-player-sub-templates)
|
||||
- [The Navigation Template (shared/nav-menu)](#the-navigation-template-sharednav-menu)
|
||||
- [Page Templates](#page-templates)
|
||||
- [The Books Index Page](#the-books-index-page)
|
||||
- [The Deleted Items Page](#the-deleted-items-page)
|
||||
- [The Playlist Pages](#the-playlist-pages)
|
||||
- [The Shared Add to Playlist Action](#the-shared-add-to-playlist-action)
|
||||
- [The Album Track Actions Menu](#the-album-track-actions-menu)
|
||||
@@ -161,7 +163,7 @@ Every themed page is identified by a page key that mirrors the path of the corre
|
||||
1. An explicit mapping in `templates` when the manifest declares the page key.
|
||||
2. A mirrored template file at `templates/{pageKey}.html`, walking up the scope of the path when the exact mirror does not exist.
|
||||
|
||||
When neither an explicit mapping nor a mirrored file exists, the theme has no template for that page, and the application renders its own fallback unstylied Razor view instead.
|
||||
When neither an explicit mapping nor a mirrored file exists, the theme has no template for that page, and the application renders its own fallback unstyled Razor view instead.
|
||||
|
||||
For example, the books index page has the page key `library/written-content-library/book-library/books/index`. The engine tries, in order: the explicit `templates` entry for that key, `templates/library/written-content-library/book-library/books/index.html`, then the parent scopes such as `templates/library/written-content-library/book-library/books.html`. When none exists, the application renders the books page view itself.
|
||||
|
||||
@@ -177,6 +179,7 @@ Known page keys:
|
||||
| `shared/audio-player/queue-item` | The queue item of the audio player bar. |
|
||||
| `shared/audio-player/playlist-item` | The playlist item of the audio player bar. |
|
||||
| `library/written-content-library/book-library/books/index` | The books browsing page. |
|
||||
| `library/written-content-library/book-library/books/deleted-items` | The deleted items page of a book library, which restores deleted books. |
|
||||
| `playlists/index` | The page that lists and deletes the playlists of the current user. |
|
||||
| `playlists/item` | The page that creates a playlist, or edits, reorders, plays and deletes an existing playlist of the current user. The `isNew` page data field tells the two modes apart. |
|
||||
| `favorites/index` | The page that lists, filters and removes the favorites of the current user across media kinds. |
|
||||
@@ -555,6 +558,69 @@ Page templates are rendered into a content section that the layout wraps. A page
|
||||
{{/scripts}}
|
||||
```
|
||||
|
||||
#### The Books Index Page
|
||||
|
||||
`library/written-content-library/book-library/books/index` receives a model with the following fields:
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `libraryId` | The Id of the library whose books are browsed. |
|
||||
| `itemsUrl` | The route that returns the books of the library. |
|
||||
| `settingsUrl` | The route that returns the settings of the current user, which drive pagination and the alpha picker. |
|
||||
| `readUrl` | The route template of the reader of a book. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the book. |
|
||||
| `detailsUrl` | The route template of the details page of a book. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the book. |
|
||||
| `deleteUrl` | The route template that deletes a book. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the book. |
|
||||
| `deletedBooksUrl` | The route of the deleted items page of the library. |
|
||||
| `availabilityUrl` | The route template that reports whether a book can be read. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the book. |
|
||||
| `strings` | The localized strings of the page, keyed by their resource names. |
|
||||
| `stringsJson` | The same localized strings serialized as JSON, with camel case keys, for the page script. |
|
||||
|
||||
The page script renders the cards into `books-container` and drives these hooks:
|
||||
|
||||
| Hook | Purpose |
|
||||
| --- | --- |
|
||||
| `search-input` and `search-button` | Filter the books by title. |
|
||||
| `sort-toggle` | Toggle the sort direction. |
|
||||
| `btn-deleted-books` | Opens the deleted items page of the library. |
|
||||
| `count-label` | Shows the total number of books or the range of the current page. |
|
||||
| `alpha-picker` | Filters the books by their first character. |
|
||||
| `pagination`, `prev-page`, `next-page` and `page-indicator` | Navigate the pages. |
|
||||
| `no-items` and `no-items-matching` | Show the empty states without and with active filters. |
|
||||
| `.media-card`, `.card-actions-trigger` and `.card-actions-menu` | Render a book card and its actions menu. |
|
||||
| `.card-action-delete` | Deletes the book of the card. |
|
||||
|
||||
#### The Deleted Items Page
|
||||
|
||||
`library/written-content-library/book-library/books/deleted-items` lists the books that were deleted from a book library and lets the user restore them. Its fallback is `Core/Views/Library/WrittenContentLibrary/BookLibrary/Books/DeletedItems.cshtml`. The bundled themes ship their own `templates/library/written-content-library/book-library/books/deleted-items.html`; when a theme has no template for the page, the application renders the fallback view.
|
||||
|
||||
Template resolution walks up the path scopes, so a theme that ships `templates/library/written-content-library/book-library/books.html` without a `deleted-items.html` would render that parent template for this page. A theme that provides a books parent template must also provide the deleted items template.
|
||||
|
||||
Page data:
|
||||
|
||||
| Field | Content |
|
||||
| --- | --- |
|
||||
| `libraryId` | The Id of the library whose deleted books are listed. |
|
||||
| `libraryTitle` | The title of that library. |
|
||||
| `deletedBooksJson` | The deleted books, serialized as a JSON array. Each item carries `id`, `libraryId`, `title`, `originalTitle`, `path`, `deletedOnUtc` and `coverPath`. |
|
||||
| `restoreUrl` | The route template that restores a deleted book. The trailing `00000000-0000-0000-0000-000000000000` is replaced by the Id of the book, and `libraryId` is appended as a query parameter. |
|
||||
| `backUrl` | The route of the books page of the library. |
|
||||
| `antiforgeryToken` | The anti-forgery request token for the restore POST. |
|
||||
| `strings` | The localized strings of the page, keyed by their resource names. |
|
||||
| `stringsJson` | The same localized strings serialized as JSON, with camel case keys, for the page script. |
|
||||
|
||||
The page script drives these hooks:
|
||||
|
||||
| Hook | Purpose |
|
||||
| --- | --- |
|
||||
| `btn-back-to-library` | Returns to the books page of the library. |
|
||||
| `deleted-books-table` | Holds the deleted books. The restore click handler is bound to it. |
|
||||
| `no-deleted-books` | The empty state, shown when no deleted books remain. |
|
||||
| `.deleted-book-row` | A deleted book row, carrying the book Id in `data-book-id`. Removed after a successful restore. |
|
||||
| `.btn-restore-book` | The restore button of a row, carrying the book Id in `data-book-id`. |
|
||||
| `input[name="__RequestVerificationToken"]` | The anti-forgery token that the restore POST sends. |
|
||||
|
||||
A theme that provides this page must keep these hooks and render the anti-forgery token, or reimplement the restore behavior itself.
|
||||
|
||||
#### The Playlist Pages
|
||||
|
||||
`playlists/index` receives a model with the following fields:
|
||||
|
||||
Reference in new issue
Block a user