diff options
Diffstat (limited to 'roseh.moe.go')
| -rw-r--r-- | roseh.moe.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/roseh.moe.go b/roseh.moe.go index 76e1e18..9a0d548 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -142,12 +142,14 @@ func loadSecrets() error { type packageConfig struct { Name string `xml:",attr"` URL string `xml:",attr"` + Source string `xml:",attr"` Description string `xml:",attr"` } type commandConfig struct { Name string `xml:",attr"` URL string `xml:",attr"` + Source string `xml:",attr"` Description string `xml:",attr"` Multi bool `xml:",attr"` } @@ -886,7 +888,14 @@ func cmd(w http.ResponseWriter, r *http.Request) { return } if r.FormValue("go-get") == "1" { - fmt.Fprintf(w, `<meta name="go-import" content="roseh.moe/cmd/%s %s">`, r.PathValue("cmd"), serviceConfig.CommandRedirects[sourceIdx].URL) + fmt.Fprintf(w, "<meta name=\"go-import\" content=\"roseh.moe/cmd/%s %s\">\n", + r.PathValue("cmd"), + serviceConfig.CommandRedirects[sourceIdx].URL) + if source := serviceConfig.CommandRedirects[sourceIdx].Source; source != "" { + fmt.Fprintf(w, "<meta name=\"go-source\" content=\"roseh.moe/cmd/%s %s\">\n", + r.PathValue("cmd"), + source) + } } else { http.Redirect(w, r, "https://pkg.go.dev/roseh.moe/cmd/"+r.PathValue("cmd"), http.StatusMovedPermanently) } @@ -949,7 +958,12 @@ func pkg(w http.ResponseWriter, r *http.Request) { return } if r.FormValue("go-get") == "1" { - fmt.Fprintf(w, `<meta name="go-import" content="roseh.moe/pkg/%s %s">`, r.PathValue("pkg"), serviceConfig.PackageRedirects[sourceIdx].URL) + fmt.Fprintf(w, "<meta name=\"go-import\" content=\"roseh.moe/pkg/%s %s\">\n", r.PathValue("pkg"), serviceConfig.PackageRedirects[sourceIdx].URL) + if source := serviceConfig.PackageRedirects[sourceIdx].Source; source != "" { + fmt.Fprintf(w, "<meta name=\"go-source\" content=\"roseh.moe/pkg/%s %s\">\n", + r.PathValue("pkg"), + source) + } } else { http.Redirect(w, r, "https://pkg.go.dev/roseh.moe/pkg/"+r.PathValue("pkg"), http.StatusMovedPermanently) } |
