Added auth layout and route for login.
This commit is contained in:
parent
869fa82f14
commit
fe0fb8c801
8 changed files with 124 additions and 32 deletions
|
|
@ -13,6 +13,8 @@ func (h *Home) Get(c echo.Context) error {
|
||||||
p.Layout = "main"
|
p.Layout = "main"
|
||||||
p.Name = "home"
|
p.Name = "home"
|
||||||
p.Data = "Hello world"
|
p.Data = "Hello world"
|
||||||
|
p.Metatags.Description = "Welcome to the homepage."
|
||||||
|
p.Metatags.Keywords = []string{"Go", "MVC", "Web", "Software"}
|
||||||
|
|
||||||
return h.RenderPage(c, p)
|
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) {
|
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>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
{{template "metatags" .}}
|
||||||
<title>{{ .AppName }}{{ if .Title }} | {{ .Title }}{{ end }}</title>
|
{{template "css" .}}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
</head>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<body>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
|
<nav class="navbar is-dark">
|
||||||
</head>
|
<div class="container">
|
||||||
<body>
|
<div class="navbar-brand">
|
||||||
<nav class="navbar is-dark">
|
<a href="{{call .Reverse "home"}}" class="navbar-item">{{.AppName}}</a>
|
||||||
<div class="container">
|
</div>
|
||||||
<div class="navbar-brand">
|
<div id="navbarMenu" class="navbar-menu">
|
||||||
<a href="{{call .Reverse "home"}}" class="navbar-item">{{.AppName}}</a>
|
<div class="navbar-end">
|
||||||
</div>
|
{{link (call .Reverse "home") "Home" .Path "navbar-item"}}
|
||||||
<div id="navbarMenu" class="navbar-menu">
|
{{link (call .Reverse "about") "About" .Path "navbar-item"}}
|
||||||
<div class="navbar-end">
|
{{link (call .Reverse "contact") "Contact" .Path "navbar-item"}}
|
||||||
{{link (call .Reverse "home") "Home" .Path "navbar-item"}}
|
{{- if .IsAuth}}
|
||||||
{{link (call .Reverse "about") "About" .Path "navbar-item"}}
|
|
||||||
{{link (call .Reverse "contact") "Contact" .Path "navbar-item"}}
|
{{- else}}
|
||||||
|
{{link (call .Reverse "login") "Login" .Path "navbar-item"}}
|
||||||
|
{{- end}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</nav>
|
||||||
</nav>
|
|
||||||
|
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{{- if .Title}}
|
{{- if .Title}}
|
||||||
<h1 class="title">{{.Title}}</h1>
|
<h1 class="title">{{.Title}}</h1>
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
|
||||||
{{template "messages" .}}
|
{{template "messages" .}}
|
||||||
{{template "content" .}}
|
{{template "content" .}}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<p>Click here to return home</p>
|
<p>Click {{link (call .Reverse "home") "here" .Path}} to return home</p>
|
||||||
{{end}}
|
{{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…
Add table
Add a link
Reference in a new issue