Files
bookhoard/docs/developer/api/custom-section-builder.md
T
john-okeefe 4d321528b2 docs: update comprehensive API documentation and project guides
This commit updates all documentation files throughout the project:

- Updated IMPLEMENTATION_PLAN.md with new implementation details
- Updated PROJECT_GUIDELINES.md with coding standards and practices
- Updated README.md with current project information
- Updated SCREENSHOT_AUTOMATION.md with new automation details
- Added TEST_DATA.md with test fixtures data
- Updated cover_image_serving_plan.md with static URL patterns

Documentation API updates:
- Updated API reference documentation for all endpoints including:
  - Authentication (login, logout, register, refresh_token)
  - Book matching (auto_link, bulk_link, link_book, search)
  - Collections (CRUD operations, shelf mappings, auto-assign rules)
  - Conflicts (bulk operations, resolve/dismiss)
  - Devices (registration, approval, shelf management)
  - Highlights (create, update, delete, get)
  - Kobo sync (bookmark, markup, initialization, sync)
  - KOReader sync (library, metadata, bookmarks, progress)
  - Libraries (CRUD, folders, media items, stats)
  - Media items (bulk operations, CRUD)
  - Notes (CRUD operations)
  - OPDS (acquisition, feeds, publication)
  - Progress (reading progress tracking)
  - Queue (device queue management)
  - Ratings (star ratings)
  - Scanner (watch mode, scan operations)
  - Sync protocols (Kobo, KOReader)
  - Users (profile, password, admin operations)
  - WebSocket protocols

- Updated user guides (admin, dashboard, settings, sync)
- Updated device setup guides (Kobo, KOReader)
- Updated developer guides (testing, contributing, operations)
- Updated scripts/README.md
2026-02-27 17:06:22 -05:00

157 lines
3.8 KiB
Markdown

# Custom Section Builder API
The Custom Section Builder allows users to create personalized dashboard sections by defining filter rules or manually selecting books.
## Preview Collection
Evaluates filter rules and returns matching items without saving the collection.
**Endpoint:** `POST /api/collections/preview`
**Request Body:**
```json
{
"library_id": "uuid",
"rules": [
{
"id": "rule1",
"field": "genre",
"operator": "equals",
"value": "Sci-Fi",
"priority": 1
}
],
"manual_book_ids": ["uuid1", "uuid2"],
"limit": 20
}
```
**Available Filter Fields:**
| Field | Type | Operators |
| ------------ | ------ | ------------------------------------------------------------------------ |
| `title` | text | contains, equals, starts_with, ends_with, regex |
| `author` | text | contains, equals |
| `genre` | select | equals, not_equals, in, not_in |
| `series` | text | is_set, is_not_set, equals, contains |
| `progress` | number | equals, not_equals, greater_than, less_than, between, is_set, is_not_set |
| `rating` | number | equals, not_equals, greater_than, less_than, is_set, is_not_set |
| `date_added` | date | equals, not_equals, before, after, between, last_x_days |
| `last_read` | date | equals, before, after, between, last_x_days, is_set, is_not_set |
| `publisher` | text | contains, equals |
| `language` | select | equals, not_equals, in |
| `format` | select | equals, in |
| `tags` | text | contains, not_contains, equals |
| `narrators` | text | contains, equals, is_set, is_not_set |
**Response:**
```json
{
"items": [
{
"media_item_id": "uuid",
"title": "Book Title",
"author": "Author Name",
"cover_image_path": "/path/to/cover.jpg"
}
]
}
```
## Create Custom Section
Creates a new custom collection with filter rules and/or manual book selection.
**Endpoint:** `POST /api/collections`
**Request Body:**
```json
{
"name": "My Custom Section",
"description": "My favorite Sci-Fi books",
"icon": "📚",
"color": "#9333ea",
"show_on_dashboard": true,
"auto_assign_rules": "[{\"id\":\"rule1\",\"field\":\"genre\",\"operator\":\"equals\",\"value\":\"Sci-Fi\",\"priority\":1}]",
"manual_book_ids": ["uuid1", "uuid2"],
"view_settings": {}
}
```
**Response:** Returns the created collection object.
## Frontend Implementation
**Route:** `/custom-section`
**Template:** `templates/custom_section.templ`
**TypeScript:** `web/src/custom-section-builder.ts`
Key features:
- 14 filter fields with various operators
- Live preview functionality
- Search + multi-select for manual book addition
- AND/OR logic support for combining rules
## Example Use Cases
### Sci-Fi Favorites
```json
{
"rules": [
{
"field": "genre",
"operator": "equals",
"value": "Sci-Fi"
}
]
}
```
### High Rated Books
```json
{
"rules": [
{
"field": "rating",
"operator": "greater_than",
"value": "4"
}
]
}
```
### Long Books (Manual Selection)
```json
{
"manual_book_ids": ["uuid1", "uuid2", "uuid3"]
}
```
### Recently Finished Audiobooks
```json
{
"rules": [
{
"field": "format",
"operator": "equals",
"value": "Audiobook"
},
{
"field": "last_read",
"operator": "last_x_days",
"value": "30"
}
]
}
```