Hi… I am well aware that this diff view is very suboptimal. It will be fixed when the refactored server comes along!
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 -}}