4 Commits

Author SHA1 Message Date
b87b9899fa migrated back to github
*heavy sigh*
2024-06-11 18:49:08 +01:00
52efa04b35 a bit more shiny 2024-06-06 17:24:15 +01:00
7e0796a50e wtf 2024-06-06 17:14:19 +01:00
2037bb371b adding avatar to pages 2024-05-25 10:35:09 +01:00
14 changed files with 81 additions and 69 deletions

View File

@@ -5,11 +5,11 @@ import (
"os"
"path/filepath"
"github.com/mleku/lol"
"gopkg.in/yaml.v3"
"mleku.net/slog"
)
var log, chk = slog.New(os.Stderr)
var log, chk = lol.New(os.Stderr)
type Config struct {
Repo struct {

View File

@@ -10,10 +10,10 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/storer"
"mleku.net/slog"
"github.com/mleku/lol"
)
var log, chk = slog.New(os.Stderr)
var log, chk = lol.New(os.Stderr)
type GitRepo struct {
r *git.Repository

10
go.mod
View File

@@ -1,6 +1,6 @@
module mleku.net/legit
module github.com/mleku/legit
go 1.22
go 1.22.4
require (
github.com/bluekeyes/go-gitdiff v0.7.3
@@ -8,10 +8,10 @@ require (
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-git/go-git/v5 v5.12.0
github.com/microcosm-cc/bluemonday v1.0.26
github.com/mleku/lol v0.0.0-20240611174317-3f1a2cbd9327
github.com/russross/blackfriday/v2 v2.1.0
golang.org/x/sys v0.20.0
golang.org/x/sys v0.21.0
gopkg.in/yaml.v3 v3.0.1
mleku.net/slog v1.0.18
)
require (
@@ -34,10 +34,10 @@ require (
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/atomic v1.11.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
mleku.net/atomic v1.11.10 // indirect
)
replace github.com/sergi/go-diff => github.com/sergi/go-diff v1.3.1

12
go.sum
View File

@@ -59,6 +59,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58=
github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs=
github.com/mleku/lol v0.0.0-20240611174317-3f1a2cbd9327 h1:mJ0Q49BRlBfhAm58Bn2P332MQyvQJUBkqNCbc8WNeWM=
github.com/mleku/lol v0.0.0-20240611174317-3f1a2cbd9327/go.mod h1:Mn7Iom10hDMLHoLqhY+7ixfdts8RSiG5Gf8aQiCjmJU=
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
@@ -86,6 +88,8 @@ github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
@@ -122,8 +126,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -155,7 +159,3 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mleku.net/atomic v1.11.10 h1:HLA3kfOa6xV96JZvau6wACnbQaX4SgYGcTQnxPc3ZiA=
mleku.net/atomic v1.11.10/go.mod h1:/7HwzqDA/Fr7GFRzBYOViU4LsXn3EngWFXZ8INJVH/c=
mleku.net/slog v1.0.18 h1:1bktX5u+jWMstCint3qg3AV3ITWUQVeLr+xRwvJeRyQ=
mleku.net/slog v1.0.18/go.mod h1:lz5ZvBZ0RJrNhR8eLrFUFR2+jm0cpRVU8Lmp4MRIbKs=

10
main.go
View File

@@ -6,15 +6,15 @@ import (
"net/http"
"os"
"mleku.net/legit/config"
"mleku.net/legit/routes"
"mleku.net/slog"
"github.com/mleku/legit/config"
"github.com/mleku/legit/routes"
"github.com/mleku/lol"
)
var log, chk = slog.New(os.Stderr)
var log, chk = lol.New(os.Stderr)
func main() {
slog.SetLogLevel(slog.Trace)
lol.SetLogLevel(lol.Trace)
log.I.Ln("logging")
var cfg string
flag.StringVar(&cfg, "config", "./config.yaml", "path to config file")

View File

@@ -3,7 +3,7 @@ package routes
import (
"net/http"
"mleku.net/legit/config"
"github.com/mleku/legit/config"
)
// Multiplex checks for git protocol-http(5) specific smells; if found, passes

View File

@@ -14,9 +14,9 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/microcosm-cc/bluemonday"
"github.com/mleku/legit/config"
"github.com/mleku/legit/git"
"github.com/russross/blackfriday/v2"
"mleku.net/legit/config"
"mleku.net/legit/git"
)
type deps struct {

View File

@@ -8,7 +8,7 @@ import (
"path/filepath"
"strings"
"mleku.net/legit/git"
"github.com/mleku/legit/git"
)
func (d *deps) Write404(w http.ResponseWriter) {
@@ -31,7 +31,8 @@ func (d *deps) Write500(w http.ResponseWriter) {
}
}
func (d *deps) listFiles(files []git.NiceTree, data map[string]any, w http.ResponseWriter) {
func (d *deps) listFiles(files []git.NiceTree, data map[string]any,
w http.ResponseWriter) {
var err error
tpath := filepath.Join(d.c.Dirs.Templates, "*")
t := template.Must(template.ParseGlob(tpath))
@@ -68,7 +69,8 @@ func countLines(r io.Reader) (int, error) {
}
}
func (d *deps) showFile(content string, data map[string]any, w http.ResponseWriter) {
func (d *deps) showFile(content string, data map[string]any,
w http.ResponseWriter) {
var err error
tpath := filepath.Join(d.c.Dirs.Templates, "*")
t := template.Must(template.ParseGlob(tpath))

View File

@@ -6,11 +6,11 @@ import (
"path/filepath"
"strings"
"mleku.net/legit/git"
"mleku.net/slog"
"github.com/mleku/legit/git"
"github.com/mleku/lol"
)
var log, chk = slog.New(os.Stderr)
var log, chk = lol.New(os.Stderr)
func isGoModule(gr *git.GitRepo) bool {
_, err := gr.FileContent("go.mod")
@@ -45,38 +45,39 @@ type repoInfo struct {
func (d *deps) getAllRepos() (repos []repoInfo, err error) {
maximum := strings.Count(d.c.Repo.ScanPath, string(os.PathSeparator)) + 2
err = filepath.WalkDir(d.c.Repo.ScanPath, func(path string, de fs.DirEntry, e error) (err error) {
if chk.E(e) {
return
}
if de.IsDir() {
// Check if we've exceeded our recursion depth
if strings.Count(path, string(os.PathSeparator)) > maximum {
return fs.SkipDir
err = filepath.WalkDir(d.c.Repo.ScanPath,
func(path string, de fs.DirEntry, e error) (err error) {
if chk.E(e) {
return
}
if d.isIgnored(path) {
log.I.Ln(path, "is ignored")
return fs.SkipDir
}
// A bare repo should always have at least a HEAD file, if it
// doesn't we can continue recursing
if _, err = os.Lstat(filepath.Join(path, "HEAD")); !chk.E(err) {
var gr *git.GitRepo
if gr, err = git.Open(path, ""); !chk.E(err) {
relpath, _ := filepath.Rel(d.c.Repo.ScanPath, path)
repos = append(repos, repoInfo{
Git: gr,
Path: relpath,
Category: d.category(path),
})
// Since we found a Git repo, we don't want to recurse
// further
if de.IsDir() {
// Check if we've exceeded our recursion depth
if strings.Count(path, string(os.PathSeparator)) > maximum {
return fs.SkipDir
}
if d.isIgnored(path) {
log.I.Ln(path, "is ignored")
return fs.SkipDir
}
// A bare repo should always have at least a HEAD file, if it
// doesn't we can continue recursing
if _, err = os.Lstat(filepath.Join(path, "HEAD")); !chk.E(err) {
var gr *git.GitRepo
if gr, err = git.Open(path, ""); !chk.E(err) {
relpath, _ := filepath.Rel(d.c.Repo.ScanPath, path)
repos = append(repos, repoInfo{
Git: gr,
Path: relpath,
Category: d.category(path),
})
// Since we found a Git repo, we don't want to recurse
// further
return fs.SkipDir
}
}
}
}
return
})
return
})
return
}

View File

@@ -1,8 +1,8 @@
:root {
--background: #000;
--cyan: #509c93;
--light-gray: #ccc;
--medium-gray: #ddd;
--light-gray: #eee;
--medium-gray: #ccc;
--gray: #666;
--dark: #aaa;
--darker: #888;
@@ -62,7 +62,14 @@ h2 {
font-size: 2em;
}
main h1, h3, strong {
h1 {
padding:1em;
}
h1 img {
padding:0;
}
main h3, strong {
padding: 0;
margin: 0;
font-family: var(--display-font);
@@ -83,7 +90,7 @@ div {
}
header {
padding: 0 0 2em 0;
padding: 0 0 0 0;
}
main h1 {
@@ -134,7 +141,7 @@ a {
word-wrap: break-word;
font-weight: 300;
padding: 0;
/*border-bottom: 1px solid var(--darkest);*/
border-bottom: 1px solid var(--darkest);
}
a:hover {
@@ -299,12 +306,13 @@ code {
flex-direction: row;
grid-template-columns: 1em minmax(0, 1fr);
gap: 1em;
background: var(--light-gray);
color:var(--light-gray);
background: var(--darkest);
overflow-x: auto;
}
.file-content {
background: var(--light-gray);
background: var(--darkest);
overflow-y: hidden;
overflow-x: auto;
}

View File

@@ -4,7 +4,7 @@
<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">
<link rel="icon" type="image/png" size="32x32" href="/static/legit.png">
<link rel="icon" type="image/png" size="32x32" href="https://i.nostr.build/9zPBz.png">
{{ if .parent }}
<title>{{ .meta.Title }} &mdash; {{ .name }} ({{ .ref }}): {{ .parent }}/</title>

View File

@@ -1,9 +1,9 @@
{{ define "index" }}
<html>
{{ template "head" . }}
<header>
<h1>{{ .meta.Title }}</h1>
<img width=64 height=64 src="https://i.nostr.build/9zPBz.png"> </img>
<h1> [ {{ .meta.Title }} ]</h1>
<h3>&nbsp;&nbsp;&nbsp;"{{ .meta.Description }}"</h3>
</header>
<body>

View File

@@ -22,7 +22,7 @@
<div class="refs">
{{ range .tags }}
<div>
<pre>{{ .Name }} commit: <a href="/{{ $name }}/commit/{{ .Hash }}">{{ .Hash }}</a> <a href="/{{ $name }}/tree/{{ .Name }}/">tree</a> {{ if .Message }}{{ .Message }}{{ end }}</pre>
<pre>{{ .Name }} commit: <a href="/{{ $name }}/commit/{{ .Hash }}">{{ .Hash }}</a> <a href="/{{ $name }}/tree/{{ .Name }}/">tree</a> {{ if .Message }}Signed Tag: {{ .Message }}{{ end }}</pre>
</div>
{{ end }}
</div>

View File

@@ -1,7 +1,8 @@
{{ define "repoheader" }}
<header>
<img width=64 height=64 src="https://i.nostr.build/9zPBz.png"> </img>
<h2>
<a href="/"><-</a> {{ .name }}
<a href="/"><-</a> {{ .name }}
{{ if .ref }}
<span class="ref">@ {{ .ref }}</span>
{{ end }}