-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.templ
66 lines (55 loc) · 1.32 KB
/
main.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import "fmt"
templ Base(title string, headArea, navBar, bodyArea, footer templ.Component) {
<!DOCTYPE html>
<html>
<head>
<title>{ title }</title>
<link rel="stylesheet" href="https://cdn.xeiaso.net/static/pkg/xess/xess.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
if headArea != nil {
@headArea
}
</head>
<body id="top">
<main>
if navBar != nil {
<nav>
@navBar
</nav>
}
<h1>{ title }</h1>
@bodyArea
if footer != nil {
<footer>
@footer
</footer>
}
</main>
</body>
</html>
}
templ Simple(title string, body templ.Component) {
@Base(title, nil, nil, body, nil)
}
templ index(objects []string) {
<a href="/upload">Upload a file</a>
<ul>
for _, obj := range objects {
<li><a href={templ.SafeURL(fmt.Sprintf("/img/%s", obj))}>{obj}</a></li>
}
</ul>
}
templ upload() {
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" value="Submit" />
</form>
}
templ viewImage(object string, presignedGet, presignedDelete string) {
<img src={presignedGet} />
<p>Presigned GET URL:</p>
<textarea readonly cols="80" rows="5">{presignedGet}</textarea>
<p>To delete this image:</p>
<textarea readonly cols="80" rows="5">curl -X DELETE {presignedDelete}</textarea>
}