Enable htmx

This commit is contained in:
2026-03-21 20:33:06 +01:00
parent 3ac792720e
commit c47a01df22
3 changed files with 10 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ Provides clean URL structure and integrates with library.py business logic.
import traceback
from datetime import date
from typing import Annotated, Any
from typing import Annotated, Any, Literal
from flask import (
Blueprint,
@@ -39,7 +39,7 @@ bp = Blueprint("main", __name__)
# Pydantic validation models
StrOrNone = Annotated[str | None, BeforeValidator(lambda v: v.strip() or None)]
StripStr = Annotated[str, StringConstraints(strip_whitespace=True)]
ISBNOrNone = Annotated[ISBN | None, BeforeValidator(lambda v: v.strip() or None)]
ISBNOrEmpty = Annotated[ISBN | Literal[""], BeforeValidator(lambda v: v.strip() or "")]
TextareaList = Annotated[
list[str],
BeforeValidator(
@@ -57,7 +57,7 @@ IntOrNone = Annotated[int | None, BeforeValidator(lambda v: v.strip() or None)]
class BookFormData(BaseModel):
title: StripStr = Field(min_length=1)
owner: StrOrNone = None
isbn: ISBNOrNone = None
isbn: ISBNOrEmpty = ""
authors: TextareaList = Field(default_factory=list)
genres: TextareaList = Field(default_factory=list)
first_published: IntOrNone = Field(default=None, le=2030)
@@ -205,7 +205,7 @@ def create_book() -> ResponseReturnValue:
owner_id=owner_id,
authors=form_data.authors,
genres=form_data.genres,
isbn=str(form_data.isbn) if form_data.isbn else None,
isbn=str(form_data.isbn),
publisher=form_data.publisher,
edition=form_data.edition,
description=form_data.description,
@@ -256,7 +256,7 @@ def update_book(book_id: int) -> ResponseReturnValue:
owner_id=owner_id,
authors=form_data.authors,
genres=form_data.genres,
isbn=str(form_data.isbn) if form_data.isbn else None,
isbn=form_data.isbn,
publisher=form_data.publisher,
edition=form_data.edition,
description=form_data.description,

View File

@@ -14,8 +14,8 @@
<link rel="icon" type="image/png" sizes="16x16" href="{{ url_for('static', filename='favicon-16x16.png') }}">
<link rel="manifest" href="{{ url_for('static', filename='site.webmanifest') }}">
{#
<script src="{{ url_for('static', filename='htmx.min.js') }}"></script> #}
<script src="{{ url_for('static', filename='htmx.min.js') }}"></script>
{#
<script src="{{ url_for('static', filename='alpine.min.js') }}" defer></script> #}
{#
@@ -33,7 +33,7 @@
</head>
<body>
<body hx-boost="true">
<!-- Header -->
{% include 'components/header.html.j2' %}

View File

@@ -1,4 +1,4 @@
<div class="card book-card h-100" onclick="window.location.href='/book/{{ book.id }}'">
<a href="/book/{{ book.id }}" class="card book-card h-100 text-decoration-none text-reset">
<div class="position-relative">
<!-- TODO: Book cover image -->
<div class="card-img-top bg-light d-flex align-items-center justify-content-center text-muted">
@@ -73,4 +73,4 @@
<small class="text-muted"> • {{ book.location_place }}</small>
{% endif %}
</div>
</div>
</a>