add datastar and render shim
This commit is contained in:
parent
9ce576e7e8
commit
2accb26546
6 changed files with 173 additions and 42 deletions
|
|
@ -1 +1,4 @@
|
|||
from repub.pages.dashboard import admin_page
|
||||
from repub.pages.dashboard import admin_component
|
||||
from repub.pages.shim import shim_page
|
||||
|
||||
__all__ = ["admin_component", "shim_page"]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import htpy as h
|
|||
from htpy import Node, Renderable
|
||||
|
||||
from repub.components import (
|
||||
base_layout,
|
||||
input_field,
|
||||
nav_link,
|
||||
select_field,
|
||||
|
|
@ -451,7 +450,7 @@ def settings_panel() -> Renderable:
|
|||
]
|
||||
|
||||
|
||||
def admin_page(*, stylesheet_href: str) -> Renderable:
|
||||
def admin_component() -> Renderable:
|
||||
running_rows = (
|
||||
(
|
||||
h.div(class_="font-semibold text-slate-950")["Pangea mobile articles"],
|
||||
|
|
@ -559,40 +558,39 @@ def admin_page(*, stylesheet_href: str) -> Renderable:
|
|||
),
|
||||
)
|
||||
|
||||
return base_layout(
|
||||
page_title="Republisher Admin UI",
|
||||
stylesheet_href=stylesheet_href,
|
||||
content=h.div(class_="min-h-screen lg:grid lg:grid-cols-[18rem_minmax(0,1fr)]")[
|
||||
sidebar(),
|
||||
h.main(class_="px-4 py-5 sm:px-6 lg:px-8 lg:py-8")[
|
||||
h.div(class_="mx-auto max-w-7xl space-y-6")[
|
||||
page_header(),
|
||||
overview_section(),
|
||||
h.div(
|
||||
class_="grid gap-6 xl:grid-cols-[minmax(0,1.35fr)_minmax(22rem,0.95fr)]"
|
||||
)[
|
||||
h.div(class_="space-y-6")[
|
||||
source_form_section(),
|
||||
configured_sources_section(),
|
||||
job_table_section(
|
||||
title="Running executions",
|
||||
subtitle="Operators can inspect active crawls and stop them if needed.",
|
||||
rows=running_rows,
|
||||
),
|
||||
job_table_section(
|
||||
title="Upcoming jobs",
|
||||
subtitle="Schedule preview with enable, disable, run now, and delete affordances.",
|
||||
rows=upcoming_rows,
|
||||
),
|
||||
job_table_section(
|
||||
title="Completed executions",
|
||||
subtitle="Recent history with direct access to text logs.",
|
||||
rows=completed_rows,
|
||||
),
|
||||
],
|
||||
h.div(class_="space-y-6")[log_panel(), settings_panel()],
|
||||
return h.main(
|
||||
id="morph",
|
||||
class_="min-h-screen lg:grid lg:grid-cols-[18rem_minmax(0,1fr)]",
|
||||
)[
|
||||
sidebar(),
|
||||
h.div(class_="px-4 py-5 sm:px-6 lg:px-8 lg:py-8")[
|
||||
h.div(class_="mx-auto max-w-7xl space-y-6")[
|
||||
page_header(),
|
||||
overview_section(),
|
||||
h.div(
|
||||
class_="grid gap-6 xl:grid-cols-[minmax(0,1.35fr)_minmax(22rem,0.95fr)]"
|
||||
)[
|
||||
h.div(class_="space-y-6")[
|
||||
source_form_section(),
|
||||
configured_sources_section(),
|
||||
job_table_section(
|
||||
title="Running executions",
|
||||
subtitle="Operators can inspect active crawls and stop them if needed.",
|
||||
rows=running_rows,
|
||||
),
|
||||
job_table_section(
|
||||
title="Upcoming jobs",
|
||||
subtitle="Schedule preview with enable, disable, run now, and delete affordances.",
|
||||
rows=upcoming_rows,
|
||||
),
|
||||
job_table_section(
|
||||
title="Completed executions",
|
||||
subtitle="Recent history with direct access to text logs.",
|
||||
rows=completed_rows,
|
||||
),
|
||||
],
|
||||
]
|
||||
],
|
||||
h.div(class_="space-y-6")[log_panel(), settings_panel()],
|
||||
],
|
||||
]
|
||||
],
|
||||
)
|
||||
]
|
||||
|
|
|
|||
34
repub/pages/shim.py
Normal file
34
repub/pages/shim.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import htpy as h
|
||||
from htpy import Node, Renderable
|
||||
|
||||
ON_LOAD_JS = (
|
||||
"@post(window.location.pathname + "
|
||||
"(window.location.search + '&u=').replace(/^&/,'?'), "
|
||||
"{retryMaxCount: Infinity})"
|
||||
)
|
||||
|
||||
TAB_ID_JS = "self.crypto.randomUUID().substring(0,8)"
|
||||
|
||||
|
||||
def shim_page(*, datastar_src: str, head: Node | None = None) -> Renderable:
|
||||
return h.html(lang="en")[
|
||||
h.head[
|
||||
h.meta(charset="UTF-8"),
|
||||
head,
|
||||
h.script(id="js", defer=True, type="module", src=datastar_src),
|
||||
h.meta(name="viewport", content="width=device-width, initial-scale=1.0"),
|
||||
],
|
||||
h.body[
|
||||
h.div({"data-signals:tabid": TAB_ID_JS}),
|
||||
h.div(
|
||||
{
|
||||
"data-init": ON_LOAD_JS,
|
||||
"data-on:online__window": ON_LOAD_JS,
|
||||
}
|
||||
),
|
||||
h.noscript["Your browser does not support JavaScript!"],
|
||||
h.main(id="morph"),
|
||||
],
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue