aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-04-19 12:17:27 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-04-19 12:17:27 +0200
commitddb1ca205abb6349b59bc5ea7764a68484e72338 (patch)
tree84db9ac2260ad87b04bca10ba6a90ecb1b4b83b3
parentbdb9af5a26f49799cb1feec866d289513eb09e7b (diff)
downloadguichet-ddb1ca205abb6349b59bc5ea7764a68484e72338.tar.gz
guichet-ddb1ca205abb6349b59bc5ea7764a68484e72338.zip
bind website page
-rw-r--r--garage.go8
-rw-r--r--main.go7
-rw-r--r--templates/garage_website_list.html16
3 files changed, 26 insertions, 5 deletions
diff --git a/garage.go b/garage.go
index e8962ae..d399ff7 100644
--- a/garage.go
+++ b/garage.go
@@ -92,16 +92,20 @@ func handleGarageKey(w http.ResponseWriter, r *http.Request) {
tKey.Execute(w, &view)
}
+type webListView struct {
+ Status *LoginStatus
+ Key *garage.KeyInfo
+}
func handleGarageWebsiteList(w http.ResponseWriter, r *http.Request) {
login, s3key, err := checkLoginAndS3(w, r)
if err != nil {
log.Println(err)
return
}
- log.Println(login, s3key)
+ view := webListView{Status: login, Key: s3key}
tWebsiteList := getTemplate("garage_website_list.html")
- tWebsiteList.Execute(w, nil)
+ tWebsiteList.Execute(w, &view)
}
func handleGarageWebsiteNew(w http.ResponseWriter, r *http.Request) {
diff --git a/main.go b/main.go
index 0e47e73..ca33795 100644
--- a/main.go
+++ b/main.go
@@ -105,7 +105,12 @@ func readConfig() ConfigFile {
}
func getTemplate(name string) *template.Template {
- return template.Must(template.ParseFiles(templatePath+"/layout.html", templatePath+"/"+name))
+ return template.Must(template.New("layout.html").Funcs(template.FuncMap {
+ "contains": strings.Contains,
+ }).ParseFiles(
+ templatePath+"/layout.html",
+ templatePath+"/"+name,
+ ))
}
func main() {
diff --git a/templates/garage_website_list.html b/templates/garage_website_list.html
index 6f5312f..ded8096 100644
--- a/templates/garage_website_list.html
+++ b/templates/garage_website_list.html
@@ -15,12 +15,24 @@
<th scope="col">URLs</th>
</thead>
<tbody>
+ {{ range $buck := .Key.Buckets }}
+ {{ if $buck.GlobalAliases }}
<tr>
<td>
- <a href="/garage/website/b/aa">aa</a>
+ <a href="/garage/website/b/{{$buck.Id}}">{{$buck.Id}}</a>
+ </td>
+ <td>
+ {{ range $alias := $buck.GlobalAliases }}
+ {{ if contains $alias "." }}
+ https://{{ $alias }}
+ {{ else }}
+ https://{{ $alias }}.web.deuxfleurs.fr
+ {{ end }}
+ {{ end }}
</td>
- <td>aa</td>
</tr>
+ {{ end }}
+ {{ end }}
</tbody>
</table>
{{end}}