Lindenii Project Forge
Commit info | |
---|---|
ID | c7407d31e0815768c27ad88c0e23d1aa4f5afad6 |
Author | Runxi Yu<me@runxiyu.org> |
Author date | Mon, 10 Feb 2025 22:33:44 +0800 |
Committer | Runxi Yu<me@runxiyu.org> |
Committer date | Mon, 10 Feb 2025 22:33:44 +0800 |
Actions | Get patch |
index: Categories -> groups again
package main import ( "net/http" "os" ) func handle_index(w http.ResponseWriter, r *http.Request) { data := make(map[string]any) entries, err := os.ReadDir(config.Git.Root) if err != nil {
_, _ = w.Write([]byte("Error listing categories: " + err.Error()))
_, _ = w.Write([]byte("Error listing groups: " + err.Error()))
return }
categories := []string{}
groups := []string{}
for _, entry := range entries {
categories = append(categories, entry.Name())
groups = append(groups, entry.Name())
}
data["categories"] = categories
data["groups"] = groups
err = templates.ExecuteTemplate(w, "index", data) if err != nil { _, _ = w.Write([]byte("Error rendering template: " + err.Error())) return } }
{{- define "index" -}} <!DOCTYPE html> <html> <head> {{ template "head_common" . }}
<title>Categories – Lindenii Forge</title>
<title>Groups – Lindenii Forge</title>
</head> <body class="index"> <div class="padding-wrapper"> <h1>
Categories
Groups
</h1> <ul>
{{- range .categories }}
{{- range .groups }}
<li> <a href="g/{{ . }}/repos/">{{ . }}</a> </li> {{- end }} </ul> </div> <footer> {{ template "footer" . }} </footer> </body> </html> {{- end -}}