common login (#124)
parent
3836bd0fb8
commit
448fda02a8
@ -1,12 +1,54 @@
|
||||
package template
|
||||
|
||||
// LoginName is the name of the login template.
|
||||
const LoginName = "login"
|
||||
import (
|
||||
libtemplate "github.com/feditools/go-lib/template"
|
||||
"github.com/feditools/relay/internal/language"
|
||||
"github.com/feditools/relay/internal/models"
|
||||
)
|
||||
|
||||
// Login contains the variables for the "login" template.
|
||||
type Login struct {
|
||||
Common
|
||||
libtemplate.Login
|
||||
}
|
||||
|
||||
// AddHeadLink adds a headder link to the template.
|
||||
func (t *Login) AddHeadLink(l libtemplate.HeadLink) {
|
||||
if t.HeadLinks == nil {
|
||||
t.HeadLinks = []libtemplate.HeadLink{}
|
||||
}
|
||||
t.HeadLinks = append(t.HeadLinks, l)
|
||||
}
|
||||
|
||||
// AddFooterScript adds a footer script to the template.
|
||||
func (t *Login) AddFooterScript(s libtemplate.Script) {
|
||||
if t.FooterScripts == nil {
|
||||
t.FooterScripts = []libtemplate.Script{}
|
||||
}
|
||||
t.FooterScripts = append(t.FooterScripts, s)
|
||||
}
|
||||
|
||||
// AddFooterExtraScript adds a footer script to the template.
|
||||
func (t *Login) AddFooterExtraScript(s string) {
|
||||
if t.FooterExtraScript == nil {
|
||||
t.FooterExtraScript = []string{}
|
||||
}
|
||||
t.FooterExtraScript = append(t.FooterExtraScript, s)
|
||||
}
|
||||
|
||||
// SetLanguage sets the template's default language.
|
||||
func (t *Login) SetLanguage(l string) {
|
||||
t.Language = l
|
||||
}
|
||||
|
||||
FormError string
|
||||
FormInstance string
|
||||
// SetLocalizer sets the localizer the template will use to generate text.
|
||||
func (t *Login) SetLocalizer(l *language.Localizer) {
|
||||
t.TextLogin = l.TextLogin()
|
||||
}
|
||||
|
||||
// SetNavbar sets the top level navbar used by the template.
|
||||
func (t *Login) SetNavbar(nodes libtemplate.Navbar) {}
|
||||
|
||||
// SetNavbarDark sets the navbar theme.
|
||||
func (t *Login) SetNavbarDark(dark bool) {}
|
||||
|
||||
// SetAccount sets the currently logged-in account.
|
||||
func (t *Login) SetAccount(account *models.Account) {}
|
||||
|
@ -1,58 +0,0 @@
|
||||
{{ define "login" -}}
|
||||
<!doctype html>
|
||||
<html lang="{{ .Language }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<title>{{ .PageTitle }}</title>
|
||||
{{ range $link := .HeadLinks }}
|
||||
{{template "head_link" $link -}}
|
||||
{{- end }}
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
padding-top: 40px;
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
.centerbox {
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.centerbox .form-control {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="text-center">
|
||||
<div class="centerbox" style="max-width: 330px">
|
||||
<form method="post">
|
||||
<img class="mb-4" src="{{ logoSrcDark }}" alt="" width="100" height="100">
|
||||
<h1 class="h3 mb-3 font-weight-normal">{{ .Localizer.TextLogin }}</h1>
|
||||
{{- if .FormError }}
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
{{.FormError}}
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{{- end }}
|
||||
<input class="form-control" type="text" name="instance" {{if .FormInstance}}value="{{.FormInstance}}" {{end}}placeholder="{{ .Localizer.TextInstance }}" aria-label="instance">
|
||||
<button type="submit" class="btn btn-lg btn-primary btn-block">{{ .Localizer.TextLogin }}</button>
|
||||
</form>
|
||||
</div>
|
||||
{{- range $link := .FooterScripts}}
|
||||
{{template "script" $link }}
|
||||
{{- end}}
|
||||
</body>
|
||||
</html>
|
||||
{{ end }}
|
Loading…
Reference in new issue