Fix base layout
This commit is contained in:
parent
6dbbc350bc
commit
c485bd119e
3 changed files with 61 additions and 5 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
@ -35,9 +36,36 @@ var (
|
|||
"anchor": anchor,
|
||||
"html": html,
|
||||
"field": field,
|
||||
"modelName": modelName,
|
||||
"active": active,
|
||||
"pluralize": pluralize,
|
||||
"lower": lower,
|
||||
}
|
||||
)
|
||||
|
||||
func modelName(value interface{}) string {
|
||||
if t := reflect.TypeOf(value); t.Kind() == reflect.Ptr {
|
||||
return t.Elem().Name()
|
||||
} else {
|
||||
return t.Name()
|
||||
}
|
||||
}
|
||||
|
||||
func lower(text string) string {
|
||||
return strings.ToLower(text)
|
||||
}
|
||||
|
||||
func pluralize(text string) string {
|
||||
return inflection.Plural(text)
|
||||
}
|
||||
|
||||
func active(value string, model interface{}) string {
|
||||
log.Println(pluralize(lower(modelName(model))))
|
||||
if value == pluralize(lower(modelName(model))) {
|
||||
return "active"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
func field(name string, value interface{}) interface{} {
|
||||
if value != nil {
|
||||
s := reflect.ValueOf(value).Elem()
|
||||
|
|
|
@ -11,16 +11,15 @@
|
|||
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark">
|
||||
<nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-primary">
|
||||
<a class="navbar-brand" href="/teachers?{{query "tpl_layout" "base" "tpl_content" "teachers"}}">OEF</a>
|
||||
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div id="navbar" class="collapse navbar-collapse">
|
||||
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/teachers?{{query "tpl_layout" "base" "tpl_content" "questions"}}">Domande</a>
|
||||
</li>
|
||||
<a class="nav-item nav-link {{.Data|active "questions"}}" href="{{all "Question"}}">Domande</a>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
|
29
templates/login.html.tpl
Normal file
29
templates/login.html.tpl
Normal file
|
@ -0,0 +1,29 @@
|
|||
{{ define "content" }}
|
||||
<div class="container">
|
||||
<h1 class="text-center karmen-title">
|
||||
<span class="fa fa-glasses"></span>
|
||||
karmen
|
||||
<small>Behind the scenes she is.</small>
|
||||
</h1>
|
||||
<div class="login">
|
||||
<form action="/login" method="post">
|
||||
<div class="form-group">
|
||||
<label for="username">Nome utente</label>
|
||||
<input type="text" class="form-control" id="username" name="username" placeholder="Nome utente" required autofocus="" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required />
|
||||
</div>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
|
||||
</form>
|
||||
{{if .Options.Get "failed"}}
|
||||
<p class="text-center text-danger">Autenticazione fallita!</p>
|
||||
{{end}}
|
||||
<p class="text-center">Sviluppato con <span class="glyphicon glyphicon-heart" aria-hidden="true"></span> da <a href="https://github.com/remogatto">Andrea
|
||||
Fazzi</a> per il <a href="https://www.carducci-dante.gov.it">Liceo
|
||||
"Carducci-Dante"</a> di Trieste</p>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
Loading…
Reference in a new issue