config: fix go-import pretty url
This commit is contained in:
parent
0e6eaa2113
commit
089ada4cac
2 changed files with 7 additions and 4 deletions
|
@ -23,7 +23,7 @@ type Config struct {
|
||||||
} `yaml:"meta"`
|
} `yaml:"meta"`
|
||||||
Misc struct {
|
Misc struct {
|
||||||
GoImport struct {
|
GoImport struct {
|
||||||
PrettyURL string `yaml:"string"`
|
PrettyURL string `yaml:"prettyURL"`
|
||||||
} `yaml:"goImport"`
|
} `yaml:"goImport"`
|
||||||
} `yaml:"misc"`
|
} `yaml:"misc"`
|
||||||
Server struct {
|
Server struct {
|
||||||
|
|
|
@ -114,13 +114,16 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cloneURL := fmt.Sprintf("https://%s/%s", d.c.Server.FQDN, name)
|
cloneURL := fmt.Sprintf("https://%s/%s", d.c.Server.FQDN, name)
|
||||||
|
prettyURL := d.c.Misc.GoImport.PrettyURL
|
||||||
|
|
||||||
if d.c.Misc.GoImport.PrettyURL == "" {
|
if prettyURL == "" {
|
||||||
d.c.Misc.GoImport.PrettyURL = cloneURL
|
prettyURL = cloneURL
|
||||||
|
} else {
|
||||||
|
prettyURL = filepath.Join(prettyURL, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
goImport := fmt.Sprintf(`<meta name="go-import" content="%s git %s">`,
|
goImport := fmt.Sprintf(`<meta name="go-import" content="%s git %s">`,
|
||||||
d.c.Misc.GoImport.PrettyURL, cloneURL)
|
prettyURL, cloneURL)
|
||||||
|
|
||||||
tpath := filepath.Join(d.c.Dirs.Templates, "*")
|
tpath := filepath.Join(d.c.Dirs.Templates, "*")
|
||||||
t := template.Must(template.ParseGlob(tpath))
|
t := template.Must(template.ParseGlob(tpath))
|
||||||
|
|
Loading…
Reference in a new issue