Replace JS with Go templates for stability

This commit is contained in:
Andrew-71 2024-03-28 10:21:04 +03:00
parent 0094534b31
commit f0198a4a72
11 changed files with 353 additions and 374 deletions

38
pages/base.html Normal file
View file

@ -0,0 +1,38 @@
{{define "header"}}
<header>
<h1>🌺 Hibiscus.txt</h1>
<p id="status">Today is <span id="today-date">a place</span></p>
</header>
{{end}}
{{define "base"}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="/public/favicon.ico">
<link rel="stylesheet" href="/public/main.css">
<script src="/public/date.js"></script>
<title>Hibiscus.txt</title>
</head>
<body>
{{template "header" .}}
<main>
{{template "main" .}}
</main>
{{template "footer" .}}
<script defer>
updateDate()
beginDateUpdater()
</script>
</body>
</html>
{{end}}
{{define "footer"}}
<footer>
<p><a href="/">today</a> | <a href="/day">previous days</a></p>
</footer>
{{end}}

View file

@ -1,33 +1,4 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="/public/favicon.ico">
<link rel="stylesheet" href="/public/main.css">
<script src="/public/date.js"></script>
<script src="/public/requests.js"></script>
<title>Hibiscus.txt</title>
</head>
<body>
<header>
<h1>🌺 Hibiscus.txt</h1>
<p id="status">Today is <span id="today-date">a place</span></p>
</header>
<main>
<h2 style="margin-bottom:0;"><label for="day">Viewing <span id="daytag"></span></label> | <a href="/days">Go back</a></h2>
<textarea id="day" cols="40" rows="15"></textarea>
</main>
<footer>
<p><a href="/">home </a> | <a href="/days">previous days</a> | <a href="/api/readme">readme.txt</a></p>
</footer>
<script defer>
updateDate()
beginDateUpdater()
loadDay()
</script>
</body>
</html>
{{define "main"}}
<h2 style="margin-bottom:0;"><label for="day">Viewing {{ .Date }}</label> | <a href="/day">Go back</a></h2>
<textarea id="day" cols="40" rows="15" readonly>{{ .Day }}</textarea>
{{end}}

View file

@ -1,33 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="/public/favicon.ico">
<link rel="stylesheet" href="/public/main.css">
<script src="/public/date.js"></script>
<script src="/public/requests.js"></script>
<title>Hibiscus.txt</title>
</head>
<body>
<header>
<h1>🌺 Hibiscus.txt</h1>
<p id="status">Today is <span id="today-date">a place</span></p>
</header>
<main>
<h2>Previous days</h2>
<ul id="days"></ul>
</main>
<footer>
<p><a href="/">home </a> | <a href="/days">previous days</a> | <a href="/api/readme">readme.txt</a></p>
</footer>
<script defer>
updateDate()
beginDateUpdater()
loadPrevious()
</script>
</body>
</html>
{{define "main"}}
<h2>{{.Title}}</h2>
<ul id="days">
{{range .Entries}}
<li><a href="/day/{{.Link}}">{{.Name}}</a></li>
{{end}}
</ul>
{{end}}

17
pages/error/500.html Normal file
View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="/public/favicon.ico">
<link rel="stylesheet" href="/public/main.css">
<title>Error 500</title>
</head>
<body>
<main>
<h1>Error 500 - Internal Server Error</h1>
<p>It's probably not your fault, but something broke</p>
<h3><a href="/">Go home?</a></h3>
</main>
</body>
</html>

View file

@ -1,34 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="/public/favicon.ico">
<link rel="stylesheet" href="/public/main.css">
<script src="/public/date.js"></script>
<script src="/public/requests.js"></script>
<title>Hibiscus.txt</title>
</head>
<body>
<header>
<h1>🌺 Hibiscus.txt</h1>
<p id="status">Today is <span id="today-date">a place</span></p>
</header>
<main>
<h2 style="margin-bottom:0;"><label for="day">Your day so far:</label></h2>
<textarea id="day" cols="40" rows="15"></textarea>
<button onclick="saveToday()">Save</button>
</main>
<footer>
<p><a href="/">home </a> | <a href="/days">previous days</a> | <a href="/api/readme">readme.txt</a></p>
</footer>
<script defer>
updateDate()
beginDateUpdater()
loadToday()
</script>
</body>
</html>
{{define "main"}}
<form method="POST">
<h2 style="margin-bottom:0;"><label for="day">Your day so far:</label></h2>
<textarea id="day" cols="40" rows="15" name="day">{{ .Day }}</textarea>
<button type="submit">Save</button>
</form>
{{end}}