Logo: a Lanna gable whose crossed kalae horns stand over a desk, gold on navy, with "Lanna Desk" and "Visas · stays · contracts" in Sarabun drawn as outlines. static/brand/ has the mark, the logo for light and for dark backgrounds and a one-color version; scripts/gen_logo.py makes them, the favicon and the header's mark from forms/fonts/Sarabun-Bold/SemiBold (SIL Open Font License, next to the Regular already there). `/` is now lannadesk.com's public page (templates/landing.html, static/landing.css): what Lanna Desk takes care of, how a client starts (write, open the link, sign first, we keep the dates), how the data is kept, contact@lannadesk.com and "Staff sign-in". It needs no session and shows no records. The back office's first page, the deadlines, moves to `/desk` (web::HOME): the header, the nav, the filter, the login's default target and the messages' links follow. Signing out now ends the session at id.cnx.network too. Kanidm names no end_session_endpoint, but its GET /ui/logout ends the session and clears its cookies (SameSite=Lax, so they come along on a top-level navigation). The logout form may only lead to this site (CSP form-action 'self'), so /signed-out sends the browser on with a refresh and offers the link as well; providers that are not Kanidm keep the old page. Checks: fmt, clippy, 109 unit and 57 integration tests (the public page open and free of records, /desk behind the sign-in, the sign-out page leading to the provider); the page at 1280 and 390 px; the header's mark in both themes; the style check on the README, PLAN and the page.
114 lines
4.4 KiB
Python
114 lines
4.4 KiB
Python
"""Lanna Desk logo: the mark (a Lanna gable with its crossed kalae horns over
|
|
a desk) and the wordmark in Sarabun, drawn as outlines so it renders the same
|
|
everywhere. Writes static/brand/ and static/favicon.svg; the header's copy of the mark
|
|
is templates/_mark.html. The fonts are forms/fonts/Sarabun-*.ttf (OFL).
|
|
|
|
uv run --with fonttools python scripts/gen_logo.py
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from fontTools.pens.svgPathPen import SVGPathPen
|
|
from fontTools.pens.transformPen import TransformPen
|
|
from fontTools.ttLib import TTFont
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
OUT = Path(sys.argv[1]) if len(sys.argv) > 1 else ROOT / "static" / "brand"
|
|
FONTS = ROOT / "forms" / "fonts"
|
|
|
|
NAVY = "#071323"
|
|
GOLD = "#f5c000"
|
|
WHITE = "#ffffff"
|
|
# gold dark enough to read on white (contrast about 3:1 for large type)
|
|
GOLD_ON_LIGHT = "#b88a00"
|
|
|
|
|
|
def text_path(font_file, text, size, x=0.0, y=0.0, tracking=0.0):
|
|
"""The text as one SVG path, baseline at y, and its advance width."""
|
|
font = TTFont(font_file)
|
|
glyphs = font.getGlyphSet()
|
|
cmap = font.getBestCmap()
|
|
scale = size / font["head"].unitsPerEm
|
|
pen = SVGPathPen(glyphs)
|
|
cursor = 0.0
|
|
for ch in text:
|
|
name = cmap[ord(ch)]
|
|
g = glyphs[name]
|
|
tp = TransformPen(pen, (scale, 0, 0, -scale, x + cursor, y))
|
|
g.draw(tp)
|
|
cursor += g.width * scale + tracking
|
|
return pen.getCommands(), cursor - tracking
|
|
|
|
|
|
def mark(roof=GOLD, desk=WHITE, ground=NAVY, rx=14):
|
|
"""The mark in a 64 x 64 box: the gable whose two boards cross at the
|
|
ridge and end in the kalae's horns, curving outwards, over the desk."""
|
|
bg = f'<rect width="64" height="64" rx="{rx}" fill="{ground}"/>' if ground else ""
|
|
return (
|
|
bg
|
|
+ f'<g fill="none" stroke="{roof}" stroke-width="4.6" stroke-linecap="round" stroke-linejoin="round">'
|
|
# the left board: eave, ridge, then on as the right horn, its tip
|
|
# curling outwards as a kalae's carved horn does
|
|
'<path d="M7.5 39 L32 20 C35 17.7 37 15.2 38.6 11.4 C39.1 10.2 40.2 9.6 41.6 9.8"/>'
|
|
# the right board: eave, ridge, then on as the left horn
|
|
'<path d="M56.5 39 L32 20 C29 17.7 27 15.2 25.4 11.4 C24.9 10.2 23.8 9.6 22.4 9.8"/>'
|
|
"</g>"
|
|
# the desk under the roof, and its two legs
|
|
f'<g fill="none" stroke="{desk}" stroke-width="4.6" stroke-linecap="round">'
|
|
'<path d="M17 47 H47"/>'
|
|
'<path d="M22.5 47 V54.5 M41.5 47 V54.5"/>'
|
|
"</g>"
|
|
)
|
|
|
|
|
|
def svg(w, h, body, title):
|
|
return (
|
|
f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {w:g} {h:g}" '
|
|
f'width="{w:g}" height="{h:g}" role="img" aria-label="{title}">'
|
|
f"<title>{title}</title>{body}</svg>\n"
|
|
)
|
|
|
|
|
|
def lockup(name_fill, tag_fill, roof, desk, ground):
|
|
"""The mark, then "Lanna Desk" and the line under it."""
|
|
bold = FONTS / "Sarabun-Bold.ttf"
|
|
medium = FONTS / "Sarabun-SemiBold.ttf"
|
|
name, nw = text_path(bold, "Lanna Desk", 46, x=82, y=42, tracking=0.2)
|
|
tag, tw = text_path(medium, "VISAS · STAYS · CONTRACTS", 11.2, x=83, y=60, tracking=1.9)
|
|
w = 82 + max(nw, tw) + 4
|
|
body = (
|
|
mark(roof, desk, ground)
|
|
+ f'<path fill="{name_fill}" d="{name}"/>'
|
|
+ f'<path fill="{tag_fill}" d="{tag}"/>'
|
|
)
|
|
return svg(round(w, 1), 64, body, "Lanna Desk")
|
|
|
|
|
|
def main():
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
files = {
|
|
# the app icon and favicon: navy tile, gold roof, white desk
|
|
"lannadesk-mark.svg": svg(64, 64, mark(), "Lanna Desk"),
|
|
# on white: navy tile kept, navy name, dark gold line
|
|
"lannadesk-logo.svg": lockup(NAVY, GOLD_ON_LIGHT, GOLD, WHITE, NAVY),
|
|
# on navy or dark: no tile, white name, gold line
|
|
"lannadesk-logo-dark.svg": lockup(WHITE, GOLD, GOLD, WHITE, None),
|
|
# one colour, for stamps, fax and engraving
|
|
"lannadesk-logo-mono.svg": lockup(NAVY, NAVY, NAVY, NAVY, None),
|
|
}
|
|
for name, text in files.items():
|
|
(OUT / name).write_text(text, encoding="utf-8", newline="\n")
|
|
print(name, len(text), "bytes")
|
|
if len(sys.argv) == 1:
|
|
(ROOT / "static" / "favicon.svg").write_text(files["lannadesk-mark.svg"], encoding="utf-8", newline="\n")
|
|
(ROOT / "templates" / "_mark.html").write_text(
|
|
f'<svg class="mark" viewBox="0 0 64 64" aria-hidden="true">{mark()}</svg>\n',
|
|
encoding="utf-8",
|
|
newline="\n",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|