From d0cf88cfc3d2c328f9e398ba94a770141f3a7be4 Mon Sep 17 00:00:00 2001
From: Runxi Yu <me@runxiyu.org>
Date: Mon, 10 Feb 2025 20:01:09 +0800
Subject: [PATCH] category_index -> category_repos

---
 handle_category_index.go                                       | 4 ++--
 main.go                                                        | 2 +-
 templates/category_index.html => templates/category_repos.html | 6 +++---
 templates/index.html                                           | 2 +-

diff --git a/handle_category_index.go b/handle_category_index.go
index d81899a7e76d9ba2ca3d87bcf90c37e47d63b01e..f9b201c2afcd6421dd66c940ec9df13fe0bec62c 100644
--- a/handle_category_index.go
+++ b/handle_category_index.go
@@ -7,7 +7,7 @@ 	"path/filepath"
 	"strings"
 )
 
-func handle_category_index(w http.ResponseWriter, r *http.Request) {
+func handle_category_repos(w http.ResponseWriter, r *http.Request) {
 	data := make(map[string]any)
 	category_name := r.PathValue("category_name")
 	data["category_name"] = category_name
@@ -26,7 +26,7 @@ 		}
 	}
 	data["repos"] = repos
 
-	err = templates.ExecuteTemplate(w, "category_index", data)
+	err = templates.ExecuteTemplate(w, "category_repos", data)
 	if err != nil {
 		_, _ = w.Write([]byte("Error rendering template: " + err.Error()))
 		return
diff --git a/main.go b/main.go
index 18733c453d2c250785008d7c80ff5a35271288bb..81657cdc8d1946b43e0bc9f1d7b5e580a90cbd52 100644
--- a/main.go
+++ b/main.go
@@ -32,7 +32,7 @@ 		clog.Fatal(1, "Serving static: "+err.Error())
 	}
 
 	http.HandleFunc("/{$}", handle_index)
-	http.HandleFunc("/{category_name}/{$}", handle_category_index)
+	http.HandleFunc("/{category_name}/repos/{$}", handle_category_repos)
 	http.HandleFunc("/{category_name}/repos/{repo_name}/{$}", handle_repo_index)
 	http.HandleFunc("/{category_name}/repos/{repo_name}/tree/{ref}/{rest...}", handle_repo_tree)
 
diff --git a/templates/category_index.html b/templates/category_repos.html
rename from templates/category_index.html
rename to templates/category_repos.html
index 7f206a45960359435211370c74793c1e45015d0d..406fee48b9bc6f3e493a1cd3dd1ec973ccf6c71c 100644
--- a/templates/category_index.html
+++ b/templates/category_repos.html
@@ -1,9 +1,9 @@
-{{- define "category_index" -}}
+{{- define "category_repos" -}}
 <!DOCTYPE html>
 <html>
 	<head>
 		{{ template "head_common" . }}
-		<title>{{ .category_name }} &ndash; Lindenii Forge</title>
+		<title>Repos in {{ .category_name }} &ndash; Lindenii Forge</title>
 	</head>
 	<body class="category-index">
 		<div class="padding-wrapper">
@@ -13,7 +13,7 @@ 			</h1>
 			<ul>
 				{{- range .repos }}
 					<li>
-						<a href="repos/{{ . }}/">{{ . }}</a>
+						<a href="{{ . }}/">{{ . }}</a>
 					</li>
 				{{- end }}
 			</ul>
diff --git a/templates/index.html b/templates/index.html
index 7ced7683900fe63baa912e3aca33685521d6144f..139abb02d0d3e43df27884b78ce97a14c0180803 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -13,7 +13,7 @@ 			</h1>
 			<ul>
 				{{- range .categories }}
 					<li>
-						<a href="{{ . }}/">{{ . }}</a>
+						<a href="{{ . }}/repos/">{{ . }}</a>
 					</li>
 				{{- end }}
 			</ul>

-- 
2.48.1