diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-19 01:20:19 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-19 01:20:19 +0800 |
commit | 1f27db389c23c36a5e2b8365768ed218a78e6af1 (patch) | |
tree | d4021bafb4cf5a5b092b8cb06ae389ce5b36793f | |
parent | contrib/index: Remove erroneous go-git/v5 (diff) | |
download | forge-1f27db389c23c36a5e2b8365768ed218a78e6af1.tar.gz forge-1f27db389c23c36a5e2b8365768ed218a78e6af1.tar.zst forge-1f27db389c23c36a5e2b8365768ed218a78e6af1.zip |
http: Add blank contrib/%d template
-rw-r--r-- | http_handle_repo_contrib_num.go | 9 | ||||
-rw-r--r-- | http_server.go | 10 | ||||
-rw-r--r-- | templates/repo_contrib_num.tmpl | 18 |
3 files changed, 36 insertions, 1 deletions
diff --git a/http_handle_repo_contrib_num.go b/http_handle_repo_contrib_num.go new file mode 100644 index 0000000..c4ed5d1 --- /dev/null +++ b/http_handle_repo_contrib_num.go @@ -0,0 +1,9 @@ +package main + +import ( + "net/http" +) + +func handle_repo_contrib_num(w http.ResponseWriter, r *http.Request, params map[string]any) { + render_template(w, "repo_contrib_num", params) +} diff --git a/http_server.go b/http_server.go index 2bd345c..b44add3 100644 --- a/http_server.go +++ b/http_server.go @@ -45,6 +45,7 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { } params := make(map[string]any) + params["url_segments"] = segments params["global"] = global_data var _user_id int // 0 for none _user_id, params["username"], err = get_user_info_from_request(r) @@ -193,7 +194,14 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { if redirect_with_slash(w, r) { return } - handle_repo_contrib_index(w, r, params) + switch non_empty_last_segments_len { + case separator_index+4: + handle_repo_contrib_index(w, r, params) + case separator_index+5: + handle_repo_contrib_num(w, r, params) + default: + http.Error(w, "Too many parameters", http.StatusBadRequest) + } default: http.Error(w, fmt.Sprintf("Unknown repo feature: %s", repo_feature), http.StatusNotFound) } diff --git a/templates/repo_contrib_num.tmpl b/templates/repo_contrib_num.tmpl new file mode 100644 index 0000000..dc34c53 --- /dev/null +++ b/templates/repo_contrib_num.tmpl @@ -0,0 +1,18 @@ +{{- define "repo_contrib_num" -}} +<!DOCTYPE html> +<html lang="en"> + <head> + {{ template "head_common" . }} + <title>Merge requests – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + </head> + <body class="repo-contrib-num"> + {{ template "header" . }} + <div class="padding-wrapper"> + Test + </div> + <footer> + {{ template "footer" . }} + </footer> + </body> +</html> +{{- end -}} |