consensus/cmd/web/views/base.qtpl
DataHoarder 71689792e6
All checks were successful
continuous-integration/drone/push Build is passing
Convert web templates to quicktemplate for speedup, remove usages of stick
2023-05-27 13:08:22 +02:00

77 lines
1.5 KiB
Plaintext

{% import (
_ "embed"
) %}
{% code
//go:embed "css/style.css"
var styleCssContent string
%}
{% interface
Page {
Title()
Content()
Style()
}
%}
{% code
type ContextProviderPage interface {
Page
Context() *GlobalRequestContext
}
type ContextSetterPage interface {
ContextProviderPage
SetContext(ctx *GlobalRequestContext)
}
%}
Page prints a page implementing Page interface.
{% func PageTemplate(p ContextProviderPage) %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="referrer" content="no-referrer">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>{%=h p.Title() %}</title>
<style>
{%= p.Style() %}
</style>
</head>
<body>
{%= Header(p.Context()) %}
<div class="content center">
{%= p.Content() %}
</div>
{%= Footer(p.Context()) %}
</body>
</html>
{% endfunc %}
Base page implementation. Other pages may inherit from it if they need
overriding only certain Page methods
{% code type BasePage struct {
ctx *GlobalRequestContext
} %}
{% func (p *BasePage) Title() %}
{% if p.Context().SiteTitle == "" %}
P2Pool Observer
{% else %}
{%s p.Context().SiteTitle %}
{% endif %}
{% endfunc %}
{% func (p *BasePage) Body() %}{% endfunc %}
{% code
func (p *BasePage) Context() *GlobalRequestContext {
return p.ctx
}
func (p *BasePage) SetContext(ctx *GlobalRequestContext) {
p.ctx = ctx
}
%}
{% func (p *BasePage) Style() %}
{%s= styleCssContent %}
{% endfunc %}