Renamed views directory to templates.
This commit is contained in:
parent
d0caa8119e
commit
299774c0c7
12 changed files with 1 additions and 1 deletions
3
templates/components/forms.gohtml
Normal file
3
templates/components/forms.gohtml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{{define "csrf"}}
|
||||
<input type="hidden" name="csrf" value="{{.CSRF}}"/>
|
||||
{{end}}
|
||||
20
templates/components/head.gohtml
Normal file
20
templates/components/head.gohtml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{{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}}
|
||||
|
||||
{{define "js"}}
|
||||
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||
{{end}}
|
||||
20
templates/components/messages.gohtml
Normal file
20
templates/components/messages.gohtml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{{define "messages"}}
|
||||
{{- range (.GetMessages "success")}}
|
||||
{{template "message" dict "Type" "success" "Text" .}}
|
||||
{{- end}}
|
||||
{{- range (.GetMessages "info")}}
|
||||
{{template "message" dict "Type" "info" "Text" .}}
|
||||
{{- end}}
|
||||
{{- range (.GetMessages "warning")}}
|
||||
{{template "message" dict "Type" "warning" "Text" .}}
|
||||
{{- end}}
|
||||
{{- range (.GetMessages "danger")}}
|
||||
{{template "message" dict "Type" "danger" "Text" .}}
|
||||
{{- end}}
|
||||
{{end}}
|
||||
|
||||
{{define "message"}}
|
||||
<article class="message is-{{.Type}}">
|
||||
<div class="message-body">{{.Text}}</div>
|
||||
</article>
|
||||
{{end}}
|
||||
27
templates/layouts/auth.gohtml
Normal file
27
templates/layouts/auth.gohtml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{template "metatags" .}}
|
||||
{{template "css" .}}
|
||||
{{template "js" .}}
|
||||
</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">
|
||||
{{- if .Title}}
|
||||
<h1 class="title">{{.Title}}</h1>
|
||||
{{- end}}
|
||||
<div class="box">
|
||||
{{template "messages" .}}
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
40
templates/layouts/main.gohtml
Normal file
40
templates/layouts/main.gohtml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{template "metatags" .}}
|
||||
{{template "css" .}}
|
||||
{{template "js" .}}
|
||||
</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}}
|
||||
{{link (call .Reverse "logout") "Logout" .Path "navbar-item"}}
|
||||
{{- else}}
|
||||
{{link (call .Reverse "login") "Login" .Path "navbar-item"}}
|
||||
{{- end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
{{- if .Title}}
|
||||
<h1 class="title">{{.Title}}</h1>
|
||||
{{- end}}
|
||||
|
||||
{{template "messages" .}}
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
3
templates/pages/about.gohtml
Normal file
3
templates/pages/about.gohtml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{{define "content"}}
|
||||
<p>{{.Data}}</p>
|
||||
{{end}}
|
||||
18
templates/pages/contact.gohtml
Normal file
18
templates/pages/contact.gohtml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{{define "content"}}
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<label class="label">Message</label>
|
||||
<div class="control">
|
||||
<textarea class="textarea" placeholder="Textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<button class="button is-link">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{template "csrf" .}}
|
||||
</form>
|
||||
{{end}}
|
||||
11
templates/pages/error.gohtml
Normal file
11
templates/pages/error.gohtml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{{define "content"}}
|
||||
{{if gt .StatusCode 500}}
|
||||
<p>Please try again. Request ID: {{.RequestID}}</p>
|
||||
{{else if or (eq .StatusCode 403) (eq .StatusCode 401)}}
|
||||
<p>You are not authorized to view the requested page.</p>
|
||||
{{else if eq .StatusCode 404}}
|
||||
<p>Click {{link (call .Reverse "home") "here" .Path}} to return home</p>
|
||||
{{else}}
|
||||
<p>Something went wrong</p>
|
||||
{{end}}
|
||||
{{end}}
|
||||
4
templates/pages/home.gohtml
Normal file
4
templates/pages/home.gohtml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{{define "content"}}
|
||||
Hello homepage {{upper "data"}}: {{ .Data }}
|
||||
<p><img src="{{file "gopher.png"}}" alt="Gopher"/></p>
|
||||
{{end}}
|
||||
26
templates/pages/login.gohtml
Normal file
26
templates/pages/login.gohtml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{{define "content"}}
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<label for="login" class="label">Username</label>
|
||||
<div class="control">
|
||||
<input id="login" type="text" name="username" class="input" value="{{.Data.Username}}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="password" class="label">Password</label>
|
||||
<div class="control">
|
||||
<input id="password" type="password" name="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>
|
||||
{{template "csrf" .}}
|
||||
</form>
|
||||
<div class="content is-small"><a href="{{call .Reverse "register"}}">Create an account</a></div>
|
||||
{{end}}
|
||||
25
templates/pages/register.gohtml
Normal file
25
templates/pages/register.gohtml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{{define "content"}}
|
||||
<form method="post">
|
||||
<div class="field">
|
||||
<label for="username" class="label">Username</label>
|
||||
<div class="control">
|
||||
<input type="text" id="username" name="username" class="input" value="{{.Data.Username}}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="password" class="label">Password</label>
|
||||
<div class="control">
|
||||
<input type="password" id="password" name="password" placeholder="*******" class="input" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field is-grouped">
|
||||
<p class="control">
|
||||
<button class="button is-primary">Register</button>
|
||||
</p>
|
||||
<p class="control">
|
||||
<a href="{{call .Reverse "home"}}" class="button is-light">Cancel</a>
|
||||
</p>
|
||||
</div>
|
||||
{{template "csrf" .}}
|
||||
</form>
|
||||
{{end}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue