Added user authentication
This commit is contained in:
parent
d7e7af5a10
commit
cb54057305
40 changed files with 710 additions and 218 deletions
11
templates/auth/login.html
Normal file
11
templates/auth/login.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<form method="post" action="/auth/login" class="post-form">
|
||||
<p>
|
||||
<input name="email" value="" placeholder="Email">
|
||||
</p>
|
||||
<p>
|
||||
<input name="password" type="password" value="" placeholder="Password">
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Login">
|
||||
</p>
|
||||
</form>
|
||||
|
|
@ -3,6 +3,7 @@ package templates
|
|||
import "embed"
|
||||
|
||||
//go:embed *.html
|
||||
//go:embed auth/*.html
|
||||
//go:embed layouts/*.html
|
||||
//go:embed posts/*.html
|
||||
var FS embed.FS
|
||||
|
|
|
|||
13
templates/layouts/login.html
Normal file
13
templates/layouts/login.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/assets/css/reset.css">
|
||||
<link rel="stylesheet" href="/assets/css/main.css">
|
||||
<title>Hugo CRM</title>
|
||||
</head>
|
||||
<body>
|
||||
{{embed}}
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
<link rel="stylesheet" href="/assets/css/reset.css">
|
||||
<link rel="stylesheet" href="/assets/css/main.css">
|
||||
<title>Hugo CRM</title>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||
</head>
|
||||
<body>
|
||||
{{embed}}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@
|
|||
<link rel="stylesheet" href="/assets/css/reset.css">
|
||||
<link rel="stylesheet" href="/assets/css/main.css">
|
||||
<title>Hugo CMS</title>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||
</head>
|
||||
<body class="role-site">
|
||||
<header>
|
||||
<h1>Hugo CMS</h1>
|
||||
<nav>
|
||||
<span>{{.site.Name}}</span>
|
||||
<a href="{{.site.URL}}">Visit</a>
|
||||
<a href="#">User</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
</div>
|
||||
|
||||
{{range .posts}}
|
||||
{{if .Title}}
|
||||
<h3>{{.Title}}</h3>
|
||||
{{end}}
|
||||
|
||||
<div class="post">
|
||||
{{if .Title}}
|
||||
<h3>{{.Title}}</h3>
|
||||
{{end}}
|
||||
|
||||
{{.Body | markdown}}
|
||||
|
||||
<div>
|
||||
<a href="/sites/{{$.site.ID}}/posts/{{.ID}}">Edit</a>
|
||||
<a href="/sites/{{$.site.ID}}/posts/{{.ID}}">Edit</a> |
|
||||
<a hx-delete="/sites/{{$.site.ID}}/posts/{{.ID}}" hx-confirm="Delete post?" hx-target="closest .post" href="#">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
{{else}}
|
||||
<p>No posts yet</p>
|
||||
{{end}}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{{- $postTarget := printf "/sites/%v/posts" .site.ID -}}
|
||||
{{- if .post.ID -}}
|
||||
{{- if (ne .post.ID 0) -}}
|
||||
{{- $postTarget = printf "/sites/%v/posts/%v" .site.ID .post.ID -}}
|
||||
{{- end -}}
|
||||
<form method="post" action="{{$postTarget}}" class="post-form">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue