all: no more pretty urls

This commit is contained in:
Anirudh Oppiliappan 2022-12-19 09:02:23 +05:30
parent 232a3603a6
commit df0962a39e
No known key found for this signature in database
GPG key ID: 8A93F96F78C5D4C4
10 changed files with 17 additions and 35 deletions

View file

@ -14,10 +14,7 @@ dirs:
meta: meta:
title: git good title: git good
description: i think it's a skill issue description: i think it's a skill issue
misc:
goImport:
prettyURL: icyphox.sh
server: server:
fqdn: git.icyphox.sh name: git.icyphox.sh
host: 127.0.0.1 host: 127.0.0.1
port: 5555 port: 5555

View file

@ -21,13 +21,8 @@ type Config struct {
Title string `yaml:"title"` Title string `yaml:"title"`
Description string `yaml:"description"` Description string `yaml:"description"`
} `yaml:"meta"` } `yaml:"meta"`
Misc struct {
GoImport struct {
PrettyURL string `yaml:"prettyURL"`
} `yaml:"goImport"`
} `yaml:"misc"`
Server struct { Server struct {
FQDN string `yaml:"fqdn,omitempty"` Name string `yaml:"fqdn,omitempty"`
Host string `yaml:"host"` Host string `yaml:"host"`
Port int `yaml:"port"` Port int `yaml:"port"`
} `yaml:"server"` } `yaml:"server"`

2
go.mod
View file

@ -1,4 +1,4 @@
module icyphox.sh/legit module git.icyphox.sh/legit
go 1.19 go 1.19

View file

@ -6,8 +6,8 @@ import (
"log" "log"
"net/http" "net/http"
"icyphox.sh/legit/config" "git.icyphox.sh/legit/config"
"icyphox.sh/legit/routes" "git.icyphox.sh/legit/routes"
) )
func main() { func main() {

4
readme
View file

@ -7,3 +7,7 @@ Pronounced however you like; I prefer channeling my beret-wearing
Frenchman, and say "Oui, il est le git!" Frenchman, and say "Oui, il est le git!"
But yeah it's pretty legit, on god no cap fr fr. But yeah it's pretty legit, on god no cap fr fr.
INSTALLING
Clone it, 'go build' it.

View file

@ -5,9 +5,9 @@ import (
"net/http" "net/http"
"path/filepath" "path/filepath"
"git.icyphox.sh/legit/config"
"github.com/alexedwards/flow" "github.com/alexedwards/flow"
"github.com/sosedoff/gitkit" "github.com/sosedoff/gitkit"
"icyphox.sh/legit/config"
) )
type depsWrapper struct { type depsWrapper struct {

View file

@ -1,7 +1,6 @@
package routes package routes
import ( import (
"fmt"
"html/template" "html/template"
"log" "log"
"net/http" "net/http"
@ -10,10 +9,10 @@ import (
"sort" "sort"
"time" "time"
"git.icyphox.sh/legit/config"
"git.icyphox.sh/legit/git"
"github.com/alexedwards/flow" "github.com/alexedwards/flow"
"github.com/dustin/go-humanize" "github.com/dustin/go-humanize"
"icyphox.sh/legit/config"
"icyphox.sh/legit/git"
) )
type deps struct { type deps struct {
@ -113,18 +112,6 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) {
return 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, "*") tpath := filepath.Join(d.c.Dirs.Templates, "*")
t := template.Must(template.ParseGlob(tpath)) t := template.Must(template.ParseGlob(tpath))
@ -138,8 +125,7 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) {
data["readme"] = readmeContent data["readme"] = readmeContent
data["commits"] = commits data["commits"] = commits
data["desc"] = getDescription(path) data["desc"] = getDescription(path)
data["clone"] = cloneURL data["servername"] = d.c.Server.Name
data["goimport"] = template.HTML(goImport)
if err := t.ExecuteTemplate(w, "repo", data); err != nil { if err := t.ExecuteTemplate(w, "repo", data); err != nil {
log.Println(err) log.Println(err)

View file

@ -9,7 +9,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"icyphox.sh/legit/git" "git.icyphox.sh/legit/git"
) )
func (d *deps) Write404(w http.ResponseWriter) { func (d *deps) Write404(w http.ResponseWriter) {

View file

@ -4,8 +4,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/style.css" type="text/css"> <link rel="stylesheet" href="/static/style.css" type="text/css">
<link rel="stylesheet" href="https://cdn.icyphox.sh/fonts/inter.css" type="text/css"> <link rel="stylesheet" href="https://cdn.icyphox.sh/fonts/inter.css" type="text/css">
{{ if .goimport }} {{ if .servername }}
{{ .goimport }} <meta name="go-import" content="{{ .servername}}/{{ .name }} git https://{{ .servername }}/{{ .name }}">
{{ end }} {{ end }}
<!-- other meta tags here --> <!-- other meta tags here -->
</head> </head>

View file

@ -36,7 +36,7 @@
<div class="clone-url"> <div class="clone-url">
<strong>clone</strong> <strong>clone</strong>
<pre> <pre>
git clone {{ .clone -}} git clone https://{{ .servername }}/{{ .name }}
</pre> </pre>
</div> </div>
</main> </main>