Templates + build

This commit is contained in:
William Bouzourène 2026-02-16 12:20:21 +01:00
parent 67e2e4d306
commit 7e821296a6
Signed by: bouzoure
GPG key ID: 423440D735B56BE2
13 changed files with 202 additions and 15 deletions

49
templates/base.templ Normal file
View file

@ -0,0 +1,49 @@
package templates
type BaseTemplateParams struct {
Title string
}
templ BaseTemplate(params BaseTemplateParams) {
<!doctype html>
<html lang="en">
<head>
<title>{ params.Title }</title>
<style>
body {
background-color: #000;
color: #fff;
font-family: monospace;
}
#main {
margin: 30px auto;
text-align: center;
max-width: 600px;
}
#main h1 {
margin-bottom: 30px;
}
input[name="url"] {
width: 100%;
max-width: 500px;
}
.error-message {
margin: 30px;
padding: 10px;
background-color: #aa0000;
}
a {
color: #fff;
}
</style>
</head>
<body>
{ children... }
</body>
</html>
}

26
templates/index.templ Normal file
View file

@ -0,0 +1,26 @@
package templates
type IndexParams struct {
Error string
}
templ Index(baseParams BaseTemplateParams, indexParams IndexParams) {
@BaseTemplate(baseParams) {
<div id="main">
<h1>GPX downloader</h1>
if len(indexParams.Error) <= 0 {
<form method="post" action="/fetch">
<input name="url" required />
<button type="submit">Fetch</button>
</form>
} else {
<div class="error-message">
{ indexParams.Error }
</div>
<a href="/">Retour</a>
}
</div>
}
}