97 lines
2.4 KiB
Plaintext
97 lines
2.4 KiB
Plaintext
// This is a base page template. All the other template pages implement this interface.
|
|
|
|
{% import "http5/status" %}
|
|
|
|
{% interface
|
|
Page {
|
|
Header()
|
|
Title(BaseTitle, PageTitle string)
|
|
Body()
|
|
Footer(st status.Status)
|
|
}
|
|
%}
|
|
|
|
// Base page implementation. Other pages may inherit from it if they need
|
|
// overriding only certain Page methods
|
|
{% code
|
|
type BasePage struct {
|
|
BaseTitle string
|
|
PageTitle string
|
|
Status status.Status
|
|
LogOutURL string
|
|
BootstrapCSS string
|
|
CommonCSS string
|
|
LoginCSS string
|
|
DMMonoCSS string
|
|
}
|
|
%}
|
|
{% func (p *BasePage) Title(BaseTitle, PageTitle string) %}
|
|
{%s BaseTitle %} - {%s PageTitle %}
|
|
{% endfunc %}
|
|
|
|
{% func (p *BasePage) Body() %}This is a base body{% endfunc %}
|
|
|
|
// Page prints a page implementing Page interface.
|
|
{% func PageTemplate(p Page) %}
|
|
{%= p.Header() %}
|
|
{%= p.Body() %}
|
|
{%= p.Footer(status.GetStatus()) %}
|
|
{% endfunc %}
|
|
|
|
|
|
{% func (p *BasePage) Header() %}
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>{%= p.Title(p.BaseTitle, p.PageTitle) %}</title>
|
|
<meta charset="utf-8">
|
|
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
|
|
<link href="/favicon.ico" rel="icon">
|
|
<link href="{%s p.BootstrapCSS %}" rel="stylesheet">
|
|
<link href="{%s p.CommonCSS %}" rel="stylesheet">
|
|
<div class="page-header mb-lg-5">
|
|
<h2 class="mb-3 font-weight-normal d0g-head">{%s p.BaseTitle %}</h2>
|
|
<p>welcome, <span class="text-success">admin</span>.</p>
|
|
</div>
|
|
</head>
|
|
<body class="text-center">
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
|
|
|
|
{% func (p *BasePage) Footer(st status.Status) %}
|
|
</body>
|
|
<footer class="footer">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-auto">
|
|
<span class="text-muted">status: </span>
|
|
{% switch st.Get() %}
|
|
{% case status.Busy %}
|
|
<span class="text-info">busy</span>
|
|
{% case status.Error %}
|
|
<span class="text-danger">error</span>
|
|
{% case status.OK %}
|
|
<span class="text-light">idle</span>
|
|
{% endswitch %}
|
|
</div>
|
|
<div class="col">
|
|
</div>
|
|
<div class="col-1">
|
|
<a href="{%s p.LogOutURL %}">logout</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
<!-- other status
|
|
<span class="text-info">busy</span>
|
|
<span class="text-light">idle</span>
|
|
<span class="text-danger">error</span>
|
|
-->
|
|
|
|
</html>
|
|
{% endfunc %}
|