all: no more pretty urls
Anirudh Oppiliappan x@icyphox.sh
Mon, 19 Dec 2022 09:02:23 +0530
10 files changed,
17 insertions(+),
35 deletions(-)
M
config.yaml
→
config.yaml
@@ -14,10 +14,7 @@ static: ./static
meta: title: git good description: i think it's a skill issue -misc: - goImport: - prettyURL: icyphox.sh server: - fqdn: git.icyphox.sh + name: git.icyphox.sh host: 127.0.0.1 port: 5555
M
config/config.go
→
config/config.go
@@ -21,13 +21,8 @@ Meta struct {
Title string `yaml:"title"` Description string `yaml:"description"` } `yaml:"meta"` - Misc struct { - GoImport struct { - PrettyURL string `yaml:"prettyURL"` - } `yaml:"goImport"` - } `yaml:"misc"` Server struct { - FQDN string `yaml:"fqdn,omitempty"` + Name string `yaml:"fqdn,omitempty"` Host string `yaml:"host"` Port int `yaml:"port"` } `yaml:"server"`
M
routes/handler.go
→
routes/handler.go
@@ -5,9 +5,9 @@ "log"
"net/http" "path/filepath" + "git.icyphox.sh/legit/config" "github.com/alexedwards/flow" "github.com/sosedoff/gitkit" - "icyphox.sh/legit/config" ) type depsWrapper struct {
M
routes/routes.go
→
routes/routes.go
@@ -1,7 +1,6 @@
package routes import ( - "fmt" "html/template" "log" "net/http"@@ -10,10 +9,10 @@ "path/filepath"
"sort" "time" + "git.icyphox.sh/legit/config" + "git.icyphox.sh/legit/git" "github.com/alexedwards/flow" "github.com/dustin/go-humanize" - "icyphox.sh/legit/config" - "icyphox.sh/legit/git" ) type deps struct {@@ -113,18 +112,6 @@ log.Println(err)
return } - cloneURL := fmt.Sprintf("https://%s/%s", d.c.Server.FQDN, name) - prettyURL := d.c.Misc.GoImport.PrettyURL - - if prettyURL == "" { - prettyURL = cloneURL - } else { - prettyURL = filepath.Join(prettyURL, name) - } - - goImport := fmt.Sprintf(`<meta name="go-import" content="%s git %s">`, - prettyURL, cloneURL) - tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath))@@ -138,8 +125,7 @@ data["ref"] = mainBranch
data["readme"] = readmeContent data["commits"] = commits data["desc"] = getDescription(path) - data["clone"] = cloneURL - data["goimport"] = template.HTML(goImport) + data["servername"] = d.c.Server.Name if err := t.ExecuteTemplate(w, "repo", data); err != nil { log.Println(err)
M
routes/template.go
→
routes/template.go
@@ -9,7 +9,7 @@ "net/http"
"path/filepath" "strings" - "icyphox.sh/legit/git" + "git.icyphox.sh/legit/git" ) func (d *deps) Write404(w http.ResponseWriter) {
M
templates/head.html
→
templates/head.html
@@ -4,8 +4,8 @@ <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="/static/style.css" type="text/css"> <link rel="stylesheet" href="https://cdn.icyphox.sh/fonts/inter.css" type="text/css"> - {{ if .goimport }} - {{ .goimport }} + {{ if .servername }} + <meta name="go-import" content="{{ .servername}}/{{ .name }} git https://{{ .servername }}/{{ .name }}"> {{ end }} <!-- other meta tags here --> </head>
M
templates/repo.html
→
templates/repo.html
@@ -36,7 +36,7 @@
<div class="clone-url"> <strong>clone</strong> <pre> -git clone {{ .clone -}} +git clone https://{{ .servername }}/{{ .name }} </pre> </div> </main>