Added auth layout and route for login.
This commit is contained in:
parent
869fa82f14
commit
fe0fb8c801
@ -13,6 +13,8 @@ func (h *Home) Get(c echo.Context) error {
|
||||
p.Layout = "main"
|
||||
p.Name = "home"
|
||||
p.Data = "Hello world"
|
||||
p.Metatags.Description = "Welcome to the homepage."
|
||||
p.Metatags.Keywords = []string{"Go", "MVC", "Web", "Software"}
|
||||
|
||||
return h.RenderPage(c, p)
|
||||
}
|
||||
|
24
controllers/login.go
Normal file
24
controllers/login.go
Normal file
@ -0,0 +1,24 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type Login struct {
|
||||
Controller
|
||||
}
|
||||
|
||||
func (l *Login) Get(c echo.Context) error {
|
||||
p := NewPage(c)
|
||||
p.Layout = "auth"
|
||||
p.Name = "login"
|
||||
p.Title = "Log in"
|
||||
p.Data = "This is the login page"
|
||||
return l.RenderPage(c, p)
|
||||
}
|
||||
|
||||
//func (a *Contact) Post(c echo.Context) error {
|
||||
// msg.Set(c, msg.Success, "Thank you for contacting us!")
|
||||
// msg.Set(c, msg.Info, "We will respond to you shortly.")
|
||||
// return a.Redirect(c, "home")
|
||||
//}
|
@ -61,5 +61,6 @@ func navRoutes(e *echo.Echo, ctr controllers.Controller) {
|
||||
}
|
||||
|
||||
func userRoutes(e *echo.Echo, ctr controllers.Controller) {
|
||||
// TODO
|
||||
login := controllers.Login{Controller: ctr}
|
||||
e.GET("/user/login", login.Get).Name = "login"
|
||||
}
|
||||
|
16
views/components/head.gohtml
Normal file
16
views/components/head.gohtml
Normal file
@ -0,0 +1,16 @@
|
||||
{{define "metatags"}}
|
||||
<title>{{ .AppName }}{{ if .Title }} | {{ .Title }}{{ end }}</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
{{- if .Metatags.Description}}
|
||||
<meta name="description" content="{{.Metatags.Description}}">
|
||||
{{- end}}
|
||||
{{- if .Metatags.Keywords}}
|
||||
<meta name="keywords" content="{{.Metatags.Keywords | join ", "}}">
|
||||
{{- end}}
|
||||
{{end}}
|
||||
|
||||
{{define "css"}}
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
|
||||
{{end}}
|
23
views/layouts/auth.gohtml
Normal file
23
views/layouts/auth.gohtml
Normal file
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{template "metatags" .}}
|
||||
{{template "css" .}}
|
||||
</head>
|
||||
<body>
|
||||
<section class="hero is-info is-fullheight">
|
||||
<div class="hero-body">
|
||||
<div class="container">
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-half">
|
||||
<h1 class="title">Log in</h1>
|
||||
<div class="box">
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
@ -1,37 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{ .AppName }}{{ if .Title }} | {{ .Title }}{{ end }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar is-dark">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a href="{{call .Reverse "home"}}" class="navbar-item">{{.AppName}}</a>
|
||||
</div>
|
||||
<div id="navbarMenu" class="navbar-menu">
|
||||
<div class="navbar-end">
|
||||
{{link (call .Reverse "home") "Home" .Path "navbar-item"}}
|
||||
{{link (call .Reverse "about") "About" .Path "navbar-item"}}
|
||||
{{link (call .Reverse "contact") "Contact" .Path "navbar-item"}}
|
||||
<head>
|
||||
{{template "metatags" .}}
|
||||
{{template "css" .}}
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar is-dark">
|
||||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
<a href="{{call .Reverse "home"}}" class="navbar-item">{{.AppName}}</a>
|
||||
</div>
|
||||
<div id="navbarMenu" class="navbar-menu">
|
||||
<div class="navbar-end">
|
||||
{{link (call .Reverse "home") "Home" .Path "navbar-item"}}
|
||||
{{link (call .Reverse "about") "About" .Path "navbar-item"}}
|
||||
{{link (call .Reverse "contact") "Contact" .Path "navbar-item"}}
|
||||
{{- if .IsAuth}}
|
||||
|
||||
{{- else}}
|
||||
{{link (call .Reverse "login") "Login" .Path "navbar-item"}}
|
||||
{{- end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</nav>
|
||||
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
{{- if .Title}}
|
||||
<h1 class="title">{{.Title}}</h1>
|
||||
{{- end}}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
{{- if .Title}}
|
||||
<h1 class="title">{{.Title}}</h1>
|
||||
{{- end}}
|
||||
|
||||
{{template "messages" .}}
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
{{template "messages" .}}
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
@ -1,3 +1,3 @@
|
||||
{{define "content"}}
|
||||
<p>Click here to return home</p>
|
||||
<p>Click {{link (call .Reverse "home") "here" .Path}} to return home</p>
|
||||
{{end}}
|
24
views/pages/login.gohtml
Normal file
24
views/pages/login.gohtml
Normal file
@ -0,0 +1,24 @@
|
||||
{{define "content"}}
|
||||
<form action="" class="">
|
||||
<div class="field">
|
||||
<label for="" class="label">Email</label>
|
||||
<div class="control">
|
||||
<input type="email" placeholder="e.g. bobsmith@gmail.com" class="input" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="" class="label">Password</label>
|
||||
<div class="control">
|
||||
<input type="password" placeholder="*******" class="input" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field is-grouped">
|
||||
<p class="control">
|
||||
<button class="button is-primary">Log in</button>
|
||||
</p>
|
||||
<p class="control">
|
||||
<a href="{{call .Reverse "home"}}" class="button is-light">Cancel</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
{{end}}
|
Loading…
Reference in New Issue
Block a user