render html change templ

This commit is contained in:
2024-12-11 17:11:53 +08:00
parent cff64975d7
commit e9876b0c6f
65 changed files with 1548 additions and 475 deletions

View File

@@ -1,20 +0,0 @@
<!-- <!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="/statics/css/bootstrap.min.css" />
<title>HLS流媒体</title>
{{block "css" .}}{{end}}
</head>
<body>
<div class="wrapper"> -->
{{define "footer"}}
</div>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.bundle.min.js"></script>
{{block "js" .}}{{end}}
</body>
</html>
{{end}}

View File

@@ -1,44 +0,0 @@
{{define "header"}}
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="/statics/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/static/css/bootstrap.min.css" />
<link rel="stylesheet" href="/static/css/index.css" />
{{block "css" .}}{{end}}
<title>URL段地址服务</title>
</head>
<body>
<div class="wrapper">
<nav class="navbar navbar-light bg-light navbar-wh">
<a class="navbar-brand navbar-brand-fs" href="/">
URL段地址服务
</a>
<ul class="flex oauth">
{{if currentUser}}
<li style="font-size: 12px;">
欢迎您: {{ currentUser.Name }}
</li>
<li style="font-size: 12px;">
<a href="/logout" class="btn btn-primary btn-sm">退出</a>
</li>
{{else}}
<li>
<a href="/login" class="btn btn-outline-primary btn-sm">登录</a>
</li>
<li>
<a href="/register" class="btn btn-primary btn-sm">注册</a>
</li>
{{end}}
</ul>
</nav>
{{end}}
<!-- </div>
<script src="/statics/js/jquery.slim.min.js"></script>
<script src="/statics/js/bootstrap.bundle.min.js"></script>
</body>
</html> -->

View File

@@ -1,83 +0,0 @@
{{template "header" .}}
<div class="container-fluid flex justify-content">
<div class="main">
<h3 style="margin-top: 20px;margin-bottom: 10px;">短地址列表 <a class="btn btn-primary"
href="/create-short-url">添加</a></h3>
<table class="my_table" style="display: block;">
<tr>
<th width="600px">原地址</th>
<th width="320px">短地址</th>
<th width="80px">是否有效</th>
<th width="80px">删除</th>
</tr>
{{range .}}
<tr>
<td width="600px">{{.OriginUrl}}</td>
<td width="320px"><a target="_blank" href="{{genShortUrl .ShortUrl}}">{{genShortUrl .ShortUrl}}</a></td>
<td width="80px">
{{if eq .Status 0}}
<code>YES</code>
{{else}}
<code>NO</code>
{{end}}
</td>
<td width="80px">
{{if eq .Status 0}}
<button data-short-url="{{.ShortUrl}}" class="btn btn-danger deleteShortUrl">删除</button>
{{end}}
</td>
</tr>
{{end}}
</table>
{{ csrfField }}
</div>
</div>
{{define "css"}}
<style>
.my_table {
display: block;
max-width: 1280px;
}
.my_table tr {
display: inline-block;
width: 100%;
border: 1px solid #eee;
border-collapse: collapse;
}
.my_table tr td {
display: inline-block;
word-wrap: break-word;
padding: 2px 5px;
}
</style>
{{end}}
{{define "js"}}
<script>
$('.deleteShortUrl').click(function () {
let csrfToken = $('input[name="csrf_token"]').val()
let u = $(this).attr('data-short-url')
$.ajax({
url: '/delete-short-url/' + u,
type: 'POST',
cache: false,
processData: false,
contentType: false,
headers: {
"X-CSRF-Token": csrfToken
},
success: function (res) {
if (res.success) {
alert('删除成功');
window.location.reload();
} else {
alert('删除失败');
}
}
})
});
</script>
{{end}}
{{template "footer" .}}

View File

@@ -1,25 +0,0 @@
{{template "header" .}}
<div class="container">
<div class="flex flex-column align-items row py-md-5 mt-md-5">
<h1>创建短路径</h1>
<div class="col-sm-4 py-md-5">
<form action="/create-short-url" method="post">
{{ csrfField }}
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">原路径</span>
</div>
<input type="text" name="long_url" class="form-control" required id="long_url">
</div>
</div>
<button type="submit" class="btn btn-primary btn-block">创建</button>
</form>
{{if .}}
<div class="py-md-5" style="color: #f44336;">
</div>
{{end}}
</div>
</div>
</div>
{{template "footer" .}}

View File

@@ -1,42 +0,0 @@
{{template "header" .}}
<div class="container">
<div class="flex flex-column align-items row py-md-5 mt-md-5">
<h1>登录</h1>
<div class="col-sm-4 py-md-5">
<form action="/login" method="post">
{{ csrfField }}
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">邮箱</span>
</div>
<input type="email" name="email" class="form-control" required id="email" value="{{.Email}}"
aria-describedby="emailValid">
</div>
{{if .EmailMsg}}
<small id="emailValid" style="color: #f44336;" class="form-text">{{.EmailMsg}}</small>
{{end}}
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">密码</span>
</div>
<input type="password" name="password" class="form-control" required id="password"
value="{{.Password}}" aria-describedby="passwordValid">
</div>
{{if .PasswordMsg}}
<small id="passwordValid" style="color: #f44336;" class="form-text">{{.PasswordMsg}}</small>
{{end}}
</div>
<button type="submit" class="btn btn-primary btn-block">提交</button>
</form>
{{if .Summary}}
<div class="py-md-5" style="color: #f44336;">
{{.Summary}}
</div>
{{end}}
</div>
</div>
</div>
{{template "footer" .}}

View File

@@ -1,54 +0,0 @@
{{template "header" .}}
<div class="container">
<div class="flex flex-column align-items row py-md-5 mt-md-5">
<h1>注册</h1>
<div class="col-sm-4 py-md-5">
<form action="/register" method="post">
{{ csrfField }}
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">邮箱</span>
</div>
<input type="email" name="email" class="form-control" required id="email" value="{{.Email}}"
aria-describedby="emailValid">
</div>
{{if .EmailMsg}}
<small id="emailValid" style="color: #f44336;" class="form-text">{{.EmailMsg}}</small>
{{end}}
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">名称</span>
</div>
<input type="text" name="username" class="form-control" required id="username"
value="{{.Username}}" aria-describedby="usernameValid">
</div>
{{if .UsernameMsg}}
<small id="usernameValid" style="color: #f44336;" class="form-text">{{.UsernameMsg}}</small>
{{end}}
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">密码</span>
</div>
<input type="password" name="password" class="form-control" required id="password"
value="{{.Password}}" aria-describedby="passwordValid">
</div>
{{if .PasswordMsg}}
<small id="passwordValid" style="color: #f44336;" class="form-text">{{.PasswordMsg}}</small>
{{end}}
</div>
<button type="submit" class="btn btn-primary btn-block">提交</button>
</form>
{{if .Summary}}
<div class="py-md-5" style="color: #f44336;">
{{.Summary}}
</div>
{{end}}
</div>
</div>
</div>
{{template "footer" .}}