bind website page
This commit is contained in:
parent
bdb9af5a26
commit
ddb1ca205a
3 changed files with 26 additions and 5 deletions
|
@ -92,16 +92,20 @@ func handleGarageKey(w http.ResponseWriter, r *http.Request) {
|
||||||
tKey.Execute(w, &view)
|
tKey.Execute(w, &view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type webListView struct {
|
||||||
|
Status *LoginStatus
|
||||||
|
Key *garage.KeyInfo
|
||||||
|
}
|
||||||
func handleGarageWebsiteList(w http.ResponseWriter, r *http.Request) {
|
func handleGarageWebsiteList(w http.ResponseWriter, r *http.Request) {
|
||||||
login, s3key, err := checkLoginAndS3(w, r)
|
login, s3key, err := checkLoginAndS3(w, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Println(login, s3key)
|
view := webListView{Status: login, Key: s3key}
|
||||||
|
|
||||||
tWebsiteList := getTemplate("garage_website_list.html")
|
tWebsiteList := getTemplate("garage_website_list.html")
|
||||||
tWebsiteList.Execute(w, nil)
|
tWebsiteList.Execute(w, &view)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleGarageWebsiteNew(w http.ResponseWriter, r *http.Request) {
|
func handleGarageWebsiteNew(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
7
main.go
7
main.go
|
@ -105,7 +105,12 @@ func readConfig() ConfigFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTemplate(name string) *template.Template {
|
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() {
|
func main() {
|
||||||
|
|
|
@ -15,12 +15,24 @@
|
||||||
<th scope="col">URLs</th>
|
<th scope="col">URLs</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{{ range $buck := .Key.Buckets }}
|
||||||
|
{{ if $buck.GlobalAliases }}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<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>
|
||||||
<td>aa</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue