Combine error templates.

This commit is contained in:
mikestefanello 2021-12-11 16:06:28 -05:00
parent 3a9f0d1879
commit 58e75cf7a6
8 changed files with 24 additions and 18 deletions

View file

@ -28,12 +28,12 @@
<section class="section">
<div class="container">
{{- if .Title}}
<h1 class="title">{{.Title}}</h1>
{{- end}}
{{- if .Title}}
<h1 class="title">{{.Title}}</h1>
{{- end}}
{{template "messages" .}}
{{template "content" .}}
{{template "messages" .}}
{{template "content" .}}
</div>
</section>
</body>

11
views/pages/error.gohtml Normal file
View 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}}

View file

@ -1,3 +0,0 @@
{{define "content"}}
<p>Click {{link (call .Reverse "home") "here" .Path}} to return home</p>
{{end}}

View file

@ -1,3 +0,0 @@
{{define "content"}}
<p>Please try again</p>
{{end}}

View file

@ -1,15 +1,15 @@
{{define "content"}}
<form method="post">
<div class="field">
<label for="" class="label">Username</label>
<label for="username" class="label">Username</label>
<div class="control">
<input type="textfield" name="username" class="input" value="{{.Data.Username}}" required>
<input type="text" id="username" name="username" class="input" value="{{.Data.Username}}" required>
</div>
</div>
<div class="field">
<label for="" class="label">Password</label>
<label for="password" class="label">Password</label>
<div class="control">
<input type="password" name="password" placeholder="*******" class="input" required>
<input type="password" id="password" name="password" placeholder="*******" class="input" required>
</div>
</div>
<div class="field is-grouped">