diff --git a/config.yaml b/config.yaml index 4c47f55..820d69d 100644 --- a/config.yaml +++ b/config.yaml @@ -14,6 +14,10 @@ dirs: meta: title: git good description: i think it's a skill issue +misc: + goImport: + prettyURL: icyphox.sh server: + fqdn: git.icyphox.sh host: 127.0.0.1 port: 5555 diff --git a/config/config.go b/config/config.go index 4b89dc1..b9bcbbd 100644 --- a/config/config.go +++ b/config/config.go @@ -21,7 +21,13 @@ type Config struct { Title string `yaml:"title"` Description string `yaml:"description"` } `yaml:"meta"` + Misc struct { + GoImport struct { + PrettyURL string `yaml:"string"` + } `yaml:"goImport"` + } `yaml:"misc"` Server struct { + FQDN string `yaml:"fqdn,omitempty"` Host string `yaml:"host"` Port int `yaml:"port"` } `yaml:"server"` diff --git a/routes/routes.go b/routes/routes.go index 12225ef..bb0d247 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -1,6 +1,7 @@ package routes import ( + "fmt" "html/template" "log" "net/http" @@ -112,6 +113,15 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) { return } + cloneURL := fmt.Sprintf("https://%s/%s", d.c.Server.FQDN, name) + + if d.c.Misc.GoImport.PrettyURL == "" { + d.c.Misc.GoImport.PrettyURL = cloneURL + } + + goImport := fmt.Sprintf(``, + d.c.Misc.GoImport.PrettyURL, cloneURL) + tpath := filepath.Join(d.c.Dirs.Templates, "*") t := template.Must(template.ParseGlob(tpath)) @@ -125,6 +135,8 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) { data["readme"] = readmeContent data["commits"] = commits data["desc"] = getDescription(path) + data["clone"] = cloneURL + data["goimport"] = template.HTML(goImport) if err := t.ExecuteTemplate(w, "repo", data); err != nil { log.Println(err) diff --git a/static/style.css b/static/style.css index 7ae9fc3..fc9d723 100644 --- a/static/style.css +++ b/static/style.css @@ -111,6 +111,14 @@ a:hover { min-width: 0; } +.clone-url { + padding-top: 2rem; +} + +.clone-url pre { + color: var(--dark); +} + .desc { color: var(--gray); font-style: italic; @@ -146,6 +154,11 @@ a:hover { white-space: pre-wrap; } +.readme { + padding-bottom: 2rem; + border-bottom: 1.5px solid var(--medium-gray); +} + .diff { margin: 1rem 0 1rem 0; padding: 1rem 0 1rem 0; @@ -160,10 +173,6 @@ a:hover { padding: 1rem 0 1rem 0; } -.commit-email { - color: var(--gray); -} - .commit-email:before { content: '<'; } @@ -230,7 +239,7 @@ a:hover { .commit-info { color: var(--gray); - font-size: 14px; + padding-bottom: 1.5rem; } @media (max-width: 600px) { diff --git a/templates/commit.html b/templates/commit.html index 9ab945a..1b4a8d9 100644 --- a/templates/commit.html +++ b/templates/commit.html @@ -10,8 +10,11 @@
           {{- .commit.Message -}}
         
-

{{ .commit.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}

-

{{ .commit.Author.Name }} {{ .commit.Author.Email}}

+
+ {{ .commit.Author.Name }} {{ .commit.Author.Email}} +
{{ .commit.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
+
+

commit: {{ .commit.This }} diff --git a/templates/head.html b/templates/head.html index 81ee777..0bde52e 100644 --- a/templates/head.html +++ b/templates/head.html @@ -4,6 +4,9 @@ + {{ if .goimport }} + {{ .goimport }} + {{ end }} {{ end }} diff --git a/templates/repo.html b/templates/repo.html index 687cafe..8dc5f54 100644 --- a/templates/repo.html +++ b/templates/repo.html @@ -25,12 +25,20 @@ {{ end }} - +{{- if .readme }}

-          {{- if .readme }}{{ .readme }}{{- end -}}
+          {{- .readme -}}
         
+{{- end -}} + +
+ clone +
+git clone {{ .clone -}}
+        
+