Neuheiten+Planung: Pagination (50/Seite, Infinite Scroll) + quellen_url in Planung mit Quellen-Link

This commit is contained in:
Flo Hartmann
2026-08-24 22:44:18 +00:00
parent fa453518d4
commit aea52d1563
6 changed files with 69 additions and 6 deletions

View File

@@ -98,10 +98,12 @@ class NeuheitenPlugin(BasePlugin):
richtung: str = STANDARD_SORTIERUNG[1],
meldung: str = "",
fehler: str = "",
seite_nr: int = 1,
):
spalte = SORTIERBAR.get(sort, SORTIERBAR[STANDARD_SORTIERUNG[0]])
abwaerts = richtung == "ab" if sort in SORTIERBAR else False
spalte_sortiert = spalte.desc() if abwaerts else spalte.asc()
pro_seite = 50
with self.context.session_factory() as db:
abfrage = select(Neuheit)
@@ -116,8 +118,11 @@ class NeuheitenPlugin(BasePlugin):
)
if status.strip():
abfrage = abfrage.where(Neuheit.status == status.strip())
gesamt = db.scalar(select(func.count()).select_from(abfrage.subquery())) or 0
eintraege = db.scalars(
abfrage.order_by(spalte_sortiert, Neuheit.id.asc())
.offset((max(seite_nr, 1) - 1) * pro_seite)
.limit(pro_seite)
).all()
status_optionen = [
zeile for zeile in db.scalars(
@@ -126,6 +131,7 @@ class NeuheitenPlugin(BasePlugin):
]
quellen_zeilen = self._quellen_uebersicht(db)
hat_weitere = max(seite_nr, 1) * pro_seite < gesamt
kontext = {
"user": user,
"titel": self.title,
@@ -143,7 +149,9 @@ class NeuheitenPlugin(BasePlugin):
),
"suchbegriffe": ", ".join(self._suchbegriffe) or "",
"sync_aktiv": self._scheduler is not None and self._scheduler.running,
"anzahl": len(eintraege),
"anzahl": gesamt,
"hat_weitere": hat_weitere,
"naechste_seite": max(seite_nr, 1) + 1,
"quellen_zeilen": quellen_zeilen,
"quellen_sync_aktiv": (
os.environ.get("SPIELE_NEUHEITEN_QUELLEN_SYNC_AKTIV", "1").strip()

View File

@@ -119,3 +119,10 @@
</table>
</div>
</div>
{% if hat_weitere %}
<div id="lade-mehr"
hx-get="/neuheiten?seite_nr={{ naechste_seite }}&q={{ q }}&status={{ status_filter }}&sort={{ sort }}&richtung={{ richtung }}"
hx-trigger="revealed delay:150ms" hx-swap="outerHTML">
<div class="py-6 text-center text-sm text-slate-400">Lade weitere Eintr&auml;ge&nbsp;&hellip;</div>
</div>
{% endif %}