Inital commit

This commit is contained in:
2022-02-24 01:07:09 +13:00
commit 8bc3cee328
55 changed files with 2292 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
{{define "footer"}}
<footer></footer>
{{end}}

View File

@@ -0,0 +1,5 @@
{{define "header"}}
<header>
{{template "nav" .}}
</header>
{{end}}

22
views/layouts/layout.gtpl Normal file
View File

@@ -0,0 +1,22 @@
{{define "layout"}}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{{.Title}}</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
</head>
<body>
{{template "header" .}}
{{template "content" .}}
{{template "footer" .}}
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js"
integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous"></script>
<script src="public/js/main.js"></script>
</body>
</body>
</html>
{{end}}

20
views/layouts/nav.gtpl Normal file
View File

@@ -0,0 +1,20 @@
{{define "nav"}}
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Otfe</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
</nav>
{{end}}

17
views/post/edit.gtpl Normal file
View File

@@ -0,0 +1,17 @@
{{define "content"}}
<form action="/user/new" method="post">
<fieldset>
<legend>New User</legend>
<div>Username</div>
<input type="text" name="username">
<div>Email</div>
<input type="email" name="email">
<div>Password</div>
<input type="password" name="password">
<div>Password Repeat</div>
<input type="password" name="password-repeat"><br>
<input type="submit" value="Submit">
</fieldset>
</form>
{{end}}

11
views/post/new.gtpl Normal file
View File

@@ -0,0 +1,11 @@
{{define "content"}}
<form action="/user/new" method="post">
<fieldset>
<legend>New Post</legend>
<div>Title</div>
<input type="text" name="title">
<input type="text" name="content">
<input type="submit" value="Submit">
</fieldset>
</form>
{{end}}

11
views/post/post.gtpl Normal file
View File

@@ -0,0 +1,11 @@
{{define "content"}}
<h1>{{.Post.Ttile}}</h1>
<h2>Username: {{.User.Username}}</h2>
<h2>Email: {{.User.Email}}</h2>
<h2>Password: {{.User.Password}}</h2>
<form action="/user/{{.User.Username}}/delete" method="post">
<button type="submit">Delete</button>
</form>
<h1>{{getId .User.ID}}</h1>
{{end}}

17
views/post/posts.gtpl Normal file
View File

@@ -0,0 +1,17 @@
{{define "content"}}
<h1>{{.Title}}</h1>
<ul>
{{range $i, $a := .Posts}}
<li>
<a href="/user/{{$a.ID}}">{{$a.ID}}</a>
</li>
{{end}}
</ul>
<form action="/user/new">
<button type="submit">New User</button>
</form>
{{end}}

3
views/static/home.gtpl Normal file
View File

@@ -0,0 +1,3 @@
{{define "content"}}
{{end}}

13
views/static/login.gtpl Normal file
View File

@@ -0,0 +1,13 @@
{{define "content"}}
<h1>Login</h1>
{{.Err}}
<form action="/login" method="post">
<div>Username or Email</div>
<input type="text" name="email">
<div>Password</div>
<input type="password" name="password">
<br>
<button type="submit">Login</button>
</form>
{{end}}

17
views/user/edit.gtpl Normal file
View File

@@ -0,0 +1,17 @@
{{define "content"}}
<form action="/user/new" method="post">
<fieldset>
<legend>New User</legend>
<div>Username</div>
<input type="text" name="username">
<div>Email</div>
<input type="email" name="email">
<div>Password</div>
<input type="password" name="password">
<div>Password Repeat</div>
<input type="password" name="password-repeat"><br>
<input type="submit" value="Submit">
</fieldset>
</form>
{{end}}

17
views/user/new.gtpl Normal file
View File

@@ -0,0 +1,17 @@
{{define "content"}}
<form action="/user/new" method="post">
<fieldset>
<legend>New User</legend>
<div>Username</div>
<input type="text" name="username">
<div>Email</div>
<input type="email" name="email">
<div>Password</div>
<input type="password" name="password">
<div>Password Repeat</div>
<input type="password" name="password-repeat"><br>
<input type="submit" value="Submit">
</fieldset>
</form>
{{end}}

11
views/user/user.gtpl Normal file
View File

@@ -0,0 +1,11 @@
{{define "content"}}
<h1>{{.User.Name}}</h1>
<h2>Username: {{.User.Username}}</h2>
<h2>Email: {{.User.Email}}</h2>
<h2>Password: {{.User.Password}}</h2>
<form action="/user/{{.User.Username}}/delete" method="post">
<button type="submit">Delete</button>
</form>
<h1>{{getId .User.ID}}</h1>
{{end}}

17
views/user/users.gtpl Normal file
View File

@@ -0,0 +1,17 @@
{{define "content"}}
<h1>{{.Title}}</h1>
<ul>
{{range $i, $a := .Users}}
<li>
<a href="/user/{{$a.Username}}">{{$a.Username}}</a>
</li>
{{end}}
</ul>
<form action="/user/new">
<button type="submit">New User</button>
</form>
{{end}}