Better
This commit is contained in:
1 parent
ea193e1264
commit
2fea308b38
106 files changed
+1234
-878
No files matched your search
@@ -0,0 +1,104 @@
|
||||
{# The shell every page is wrapped in. Rendered by sw.js, not by the build,
|
||||
so editing this file changes every page without regenerating any of them.
|
||||
|
||||
Context: title, content (safe HTML fragment), mark (bookmark or null).
|
||||
|
||||
Bootstrap is the whole stylesheet. The fragments carry semantic USFM
|
||||
classes and no Bootstrap ones, so the body text is styled by Reboot; the
|
||||
chrome here is what uses the framework. #}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<title>{% block title %}{{ title | safe }}{% endblock %}</title>
|
||||
{# Vendored rather than linked from a CDN: sw.js only caches same-origin
|
||||
responses, so a CDN stylesheet would leave the app unstyled offline. #}
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
{# app.css comes second so its variable overrides win. It styles the
|
||||
scripture; Bootstrap styles the chrome. #}
|
||||
<link rel="stylesheet" href="css/app.css">
|
||||
{# History entries are whole books, and htmx keeps its history cache in
|
||||
localStorage -- a couple of them would blow the quota. Turned off: going
|
||||
back re-requests the fragment, which the worker answers from its cache. #}
|
||||
<meta name="htmx-config"
|
||||
content='{"historyCacheSize":0,"refreshOnHistoryMiss":true}'>
|
||||
{# The bundle carries Popper, which the navbar collapse and the modal do not
|
||||
need -- but a dropdown or tooltip added later would, and this is one file
|
||||
in the precache either way. Deferred scripts run in order, so `bootstrap`
|
||||
is defined by the time app.js runs. #}
|
||||
<script src="js/bootstrap.bundle.min.js" defer></script>
|
||||
{# htmx is not deferred: hx-boost has to be in place before the first click. #}
|
||||
<script src="js/htmx.min.js"></script>
|
||||
<script src="js/app.js" defer></script>
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<meta name="theme-color" content="#1a202c">
|
||||
<link rel="apple-touch-icon" href="icons/apple-touch-icon.png">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="Bible">
|
||||
</head>
|
||||
{# Boosted links swap only the fragment, so the navbar, the modal and the
|
||||
scripts above survive navigation and never reload. #}
|
||||
<body class="{% block body_class %}{% endblock %} bg-body-tertiary"
|
||||
hx-boost="true" hx-target="#content" hx-swap="innerHTML show:top">
|
||||
|
||||
<nav class="site-header navbar navbar-expand-lg bg-dark sticky-top"
|
||||
data-bs-theme="dark">
|
||||
<div class="container-xl">
|
||||
<a class="navbar-brand" href="./">Bible</a>
|
||||
<button class="navbar-toggler" type="button"
|
||||
data-bs-toggle="collapse" data-bs-target="#site-nav"
|
||||
aria-controls="site-nav" aria-expanded="false"
|
||||
aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="site-nav">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
{% block navbar_nav %}
|
||||
{% endblock %}
|
||||
</ul>
|
||||
{% include "bookmark.njk" %}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{# col-xl-8 keeps a line of verse near a readable measure instead of running
|
||||
the full width of a desktop window. #}
|
||||
<main class="container-xl my-4">
|
||||
<div class="row justify-content-center">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{# Chrome, so it is written once here instead of built in JavaScript on every
|
||||
page. app.js only fills in the reference and shows it. #}
|
||||
<div class="modal fade" id="verse-dialog" tabindex="-1"
|
||||
aria-labelledby="verse-dialog-ref" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2 class="modal-title fs-5 verse-dialog-ref" id="verse-dialog-ref"></h2>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
||||
aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% include "status.njk" %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<form class="verse-dialog-actions d-flex flex-wrap gap-2 m-0"
|
||||
hx-post="api/bookmark" hx-target="#bookmark" hx-swap="outerHTML">
|
||||
<input type="hidden" name="ref" value="">
|
||||
<input type="hidden" name="href" value="">
|
||||
<button class="btn btn-outline-secondary" type="button"
|
||||
data-action="copy">Copy link</button>
|
||||
<button class="btn btn-primary" type="submit">Set bookmark</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
{% extends "base.njk" %}
|
||||
{% block body_class %}reading{% endblock %}
|
||||
{% block content %}{{ content | safe }}{% endblock %}
|
||||
@@ -0,0 +1,27 @@
|
||||
{# The navbar's bookmark slot. Rendered into the shell with whatever mark the
|
||||
worker holds, and returned on its own by api/bookmark after a write. Both
|
||||
paths must produce the same element for the swap to be seamless.
|
||||
|
||||
mark is null in one case only: boot.html composed this page, so there was
|
||||
no worker to ask. The slot is then hidden rather than absent and fetches
|
||||
itself once app.js reports a worker is controlling -- which is why the htmx
|
||||
attributes are on the empty state and not the filled one. A filled slot is
|
||||
only ever replaced by the modal's form, which names #bookmark itself.
|
||||
|
||||
Empty state is d-none, not the hidden attribute: Bootstrap declares .d-flex
|
||||
after Reboot's [hidden] rule, both !important and at the same specificity,
|
||||
so the utility would win. #}
|
||||
<span class="bookmark navbar-text {% if mark %}d-flex{% else %}d-none{% endif %} align-items-center gap-2"
|
||||
id="bookmark"
|
||||
{%- if not mark %}
|
||||
hx-get="api/bookmark" hx-trigger="worker-ready from:body"
|
||||
hx-target="this" hx-swap="outerHTML"
|
||||
{%- endif %}>
|
||||
{%- if mark %}
|
||||
<span class="bookmark-label badge text-bg-secondary">Bookmark</span>
|
||||
{# Not boosted: a real navigation lets the browser scroll to the verse
|
||||
anchor, which a swap into #content would not do. #}
|
||||
<a class="bookmark-link link-light text-truncate" href="{{ mark.href }}"
|
||||
hx-boost="false">{{ mark.ref }}</a>
|
||||
{%- endif %}
|
||||
</span>
|
||||
@@ -0,0 +1,7 @@
|
||||
{% extends "base.njk" %}
|
||||
{% block body_class %}browsing{% endblock %}
|
||||
{# Already on the index, so the nav entry marks the current page instead of
|
||||
offering a link to it. #}
|
||||
{% block navbar_nav %}
|
||||
{% endblock %}
|
||||
{% block content %}{{ content | safe }}{% endblock %}
|
||||
@@ -0,0 +1,12 @@
|
||||
{# A page that could not be delivered, written in the same shape as a real
|
||||
one: a title and one root element naming the template that wraps it.
|
||||
|
||||
Sent with 200 on purpose. htmx only swaps a 2xx body, and an error status
|
||||
would leave the reader looking at the page they came from with nothing to
|
||||
say what happened. #}
|
||||
<title>{{ heading }}</title>
|
||||
<div class="notice" data-template="page">
|
||||
<h1>{{ heading }}</h1>
|
||||
<p>{{ text }}</p>
|
||||
<p><a href="./">All books</a></p>
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
{# Fallback for a fragment that names no template of its own. #}
|
||||
{% extends "base.njk" %}
|
||||
{% block content %}{{ content | safe }}{% endblock %}
|
||||
@@ -0,0 +1,5 @@
|
||||
{# The modal's status line. One template for both paths: the shell renders it
|
||||
empty, and the bookmark API re-renders it with oob set so a single response
|
||||
updates the header slot and this line together. #}
|
||||
<p class="verse-dialog-status form-text m-0" id="verse-dialog-status"
|
||||
role="status" aria-live="polite"{% if oob %} hx-swap-oob="true"{% endif %}>{{ text }}</p>
|
||||
Reference in new issue
Block a user