1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-03-10 13:38:20 +00:00
This commit is contained in:
osmarks 2025-03-07 16:57:14 +00:00
parent 132c1a0572
commit 573e934cbc
5 changed files with 6 additions and 66 deletions

View File

@ -1,60 +0,0 @@
{{define "confirm"}}Confirm{{end}}
{{define "cancel"}}Cancel{{end}}
{{define "save"}}Save{{end}}
{{define "error"}}Error{{end}}
{{define "delete"}}Delete{{end}}
{{define "page"}}
<!doctype html>
<html lang="{{.Meta.Locale}}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{block "title" .}}{{end}}</title>
<link rel="icon" href="/static/favicon.ico">
<link rel="stylesheet" href="/static/style.css">
{{range .HeadElements}}{{.}}{{end}}
</head>
<body data-rrh-addr="{{if .Addr}}{{.Addr}}{{else}}{{.Meta.Addr}}{{end}}"{{range $key, $value := .BodyAttributes}} data-rrh-{{$key}}="{{$value}}"{{end}}>
<header>
<div class="logo">
<img src="/static/favicon.ico" alt="A picture of mathematician Leonhard Euler, stretched into a square" />
<div class="ominous"><span>{{.Motd}}</span></div>
</div>
<nav class="main-width top-bar">
<ul class="top-bar__wrapper">
<li class="top-bar__section top-bar__section_home">
<div class="top-bar__home-link-wrapper">
<a class="top-bar__home-link" href="/">{{block "wiki name" .}}{{end}}</a>
</div>
</li>
<li class="top-bar__section top-bar__section_search">
<form class="top-bar__search" method="GET" action="/title-search">
<input type="text" name="q" class="top-bar__search-bar"
placeholder="{{block `search by title` .}}Search{{end}}">
</form>
</li>
<li class="top-bar__section top-bar__section_auth">
{{block "auth" .}}{{end}}
</li>
<li class="top-bar__section top-bar__section_highlights">
<ul class="top-bar__highlights">
{{range .HeaderLinks}}
<li class="top-bar__highlight">
<a class="top-bar__highlight-link" href="{{.Href}}">{{.Display}}</a>
</li>
{{end}}
</ul>
</li>
</ul>
</nav>
</header>
{{block "body" .}}{{end}}
<script src="/static/common.js"></script>
<script src="/static/shortcuts.js"></script>
<script src="/static/view.js"></script>
{{range .CommonScripts}}
<script src="{{.}}"></script>
{{end}}
</body>
</html>
{{end}}

View File

@ -73,7 +73,7 @@
<li class="hypha-info__entry hypha-info__entry_backlinks"> <li class="hypha-info__entry hypha-info__entry_backlinks">
<a class="hypha-info__link" href="/backlinks/{{.HyphaName}}"> <a class="hypha-info__link" href="/backlinks/{{.HyphaName}}">
{{block "backlinks" .}}backlink{{if gt .BacklinkCount 1}}s{{end}}{{end}}</a></li> {{block "backlinks" .}}{{.BacklinkCount}} backlink{{if ne .BacklinkCount 1}}s{{end}}{{end}}</a></li>
</ul> </ul>
</nav> </nav>
</section> </section>

View File

@ -18,7 +18,7 @@
<header> <header>
<div class="logo"> <div class="logo">
<img src="/static/favicon.ico" alt="A picture of mathematician Leonhard Euler, stretched into a square" /> <img src="/static/favicon.ico" alt="A picture of mathematician Leonhard Euler, stretched into a square" />
<div class="ominous"><span>{{.Motd}}</span></div> <div class="ominous"><span>{{.Meta.Motd}}</span></div>
</div> </div>
<nav class="main-width top-bar"> <nav class="main-width top-bar">
<ul class="top-bar__wrapper"> <ul class="top-bar__wrapper">

View File

@ -7,6 +7,7 @@ import (
"github.com/bouncepaw/mycorrhiza/internal/user" "github.com/bouncepaw/mycorrhiza/internal/user"
"github.com/bouncepaw/mycorrhiza/l18n" "github.com/bouncepaw/mycorrhiza/l18n"
"github.com/bouncepaw/mycorrhiza/util"
) )
// Meta is a bundle of common stuffs used by views, templates. // Meta is a bundle of common stuffs used by views, templates.
@ -15,6 +16,7 @@ type Meta struct {
U *user.User U *user.User
W io.Writer W io.Writer
Addr string Addr string
Motd string
// New template additions // New template additions
HeadElements []template.HTML HeadElements []template.HTML
@ -28,6 +30,7 @@ func MetaFrom(w http.ResponseWriter, rq *http.Request) Meta {
U: user.FromRequest(rq), U: user.FromRequest(rq),
W: w, W: w,
Addr: rq.URL.Path, Addr: rq.URL.Path,
Motd: util.GetMotd(),
} }
} }

View File

@ -100,14 +100,12 @@ type BaseData struct {
Title string // TODO: remove Title string // TODO: remove
Body string // TODO: remove Body string // TODO: remove
BodyAttributes map[string]string BodyAttributes map[string]string
Motd string
} }
func (bd *BaseData) withBaseValues(meta Meta, headerLinks []HeaderLink, commonScripts []string) { func (bd *BaseData) withBaseValues(meta Meta, headerLinks []HeaderLink, commonScripts []string) {
bd.Meta = meta bd.Meta = meta
bd.HeaderLinks = headerLinks bd.HeaderLinks = headerLinks
bd.CommonScripts = commonScripts bd.CommonScripts = commonScripts
bd.Motd = util.GetMotd()
} }
// Base is a temporary wrapper around BaseEn and BaseRu, meant to facilitate the migration from qtpl. // Base is a temporary wrapper around BaseEn and BaseRu, meant to facilitate the migration from qtpl.
@ -125,7 +123,6 @@ func Base(meta Meta, title, body string, bodyAttributes map[string]string, headE
EditScripts: cfg.EditScripts, EditScripts: cfg.EditScripts,
Body: body, Body: body,
BodyAttributes: bodyAttributes, BodyAttributes: bodyAttributes,
Motd: util.GetMotd(),
}) })
if err != nil { if err != nil {
slog.Info("Failed to execute the legacy Base template; proceeding anyway", "err", err) slog.Info("Failed to execute the legacy Base template; proceeding anyway", "err", err)