all repos — elgit @ 4cb034adf2fd34dbaeae280c30d88601865dc7d8

fork of legit: web frontend for git, written in go

remove syntax highlighting

Alan Pearce
commit

4cb034adf2fd34dbaeae280c30d88601865dc7d8

parent

84ac9429d2b3dc331491481ff6669a3b78f99971

M config/config.goconfig/config.go
@@ -15,9 +15,8 @@ Unlisted []string `yaml:"unlisted,omitempty"`
} type Meta struct { - Title string `yaml:"title"` - Description string `yaml:"description"` - SyntaxHighlight string `yaml:"syntaxHighlight"` + Title string `yaml:"title"` + Description string `yaml:"description"` } type Server struct {
M go.modgo.mod
@@ -4,7 +4,6 @@ go 1.24.0
require ( alin.ovh/gomponents v1.6.0 - github.com/alecthomas/chroma/v2 v2.20.0 github.com/bluekeyes/go-gitdiff v0.8.1 github.com/cyphar/filepath-securejoin v0.4.1 github.com/dimfeld/httptreemux/v5 v5.5.0
@@ -23,7 +22,6 @@ github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.3.0 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/cloudflare/circl v1.6.1 // indirect - github.com/dlclark/regexp2 v1.11.5 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.6.2 // indirect
M go.sumgo.sum
@@ -7,15 +7,6 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw= github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE= -github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= -github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.19.0 h1:Im+SLRgT8maArxv81mULDWN8oKxkzboH07CHesxElq4= -github.com/alecthomas/chroma/v2 v2.19.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk= -github.com/alecthomas/chroma/v2 v2.20.0 h1:sfIHpxPyR07/Oylvmcai3X/exDlE8+FA820NTz+9sGw= -github.com/alecthomas/chroma/v2 v2.20.0/go.mod h1:e7tViK0xh/Nf4BYHl00ycY6rV7b8iXBksI9E359yNmA= -github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= -github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= -github.com/alecthomas/repr v0.5.1 h1:E3G4t2QbHTSNpPKBgMTln5KLkZHLOcU7r37J4pXBuIg= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
@@ -33,8 +24,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dimfeld/httptreemux/v5 v5.5.0 h1:p8jkiMrCuZ0CmhwYLcbNbl7DDo21fozhKHQ2PccwOFQ= github.com/dimfeld/httptreemux/v5 v5.5.0/go.mod h1:QeEylH57C0v3VO0tkKraVz9oD3Uu93CKPnTLbsidvSw= -github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= -github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o=
@@ -59,8 +48,6 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= -github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
@@ -99,15 +86,11 @@ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= -golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -116,18 +99,14 @@ golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.33.0 h1:NuFncQrRcaRvVmgRkvM3j/F00gWIAlcmlB8ACEKmGIg= -golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0= golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4= +golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
M nix/gomod2nix.tomlnix/gomod2nix.toml
@@ -13,9 +13,6 @@ hash = "sha256-tVNWDUMILZbJvarcl/E7tpSnkn7urqgSHa2Eaka5vSU="
[mod."github.com/ProtonMail/go-crypto"] version = "v1.3.0" hash = "sha256-TUG+C4MyeWglOmiwiW2/NUVurFHXLgEPRd3X9uQ1NGI=" - [mod."github.com/alecthomas/chroma/v2"] - version = "v2.19.0" - hash = "sha256-eQEL8riRi+0ecKomsjcq6gVAjJeKAR/y9cMr6XwZXuA=" [mod."github.com/aymerick/douceur"] version = "v0.2.0" hash = "sha256-NiBX8EfOvLXNiK3pJaZX4N73YgfzdrzRXdiBFe3X3sE="
@@ -31,9 +28,6 @@ hash = "sha256-NOV6MfbkcQbfhNmfADQw2SJmZ6q1nw0wwg8Pm2tf2DM="
[mod."github.com/dimfeld/httptreemux/v5"] version = "v5.5.0" hash = "sha256-jlIAxbGCSBefloquqvMJG1KDAsSA28HYCrkmlzMABws=" - [mod."github.com/dlclark/regexp2"] - version = "v1.11.5" - hash = "sha256-jN5+2ED+YbIoPIuyJ4Ou5pqJb2w1uNKzp5yTjKY6rEQ=" [mod."github.com/dustin/go-humanize"] version = "v1.0.1" hash = "sha256-yuvxYYngpfVkUg9yAmG99IUVmADTQA0tMbBXe0Fq0Mc="
@@ -83,14 +77,14 @@ [mod."github.com/xanzy/ssh-agent"]
version = "v0.3.3" hash = "sha256-l3pGB6IdzcPA/HLk93sSN6NM2pKPy+bVOoacR5RC2+c=" [mod."golang.org/x/crypto"] - version = "v0.40.0" - hash = "sha256-I6p2fqvz63P9MwAuoQrljI7IUbfZQvCem0ii4Q2zZng=" + version = "v0.41.0" + hash = "sha256-o5Di0lsFmYnXl7a5MBTqmN9vXMCRpE9ay71C1Ar8jEY=" [mod."golang.org/x/net"] - version = "v0.42.0" - hash = "sha256-YxileisIIez+kcAI+21kY5yk0iRuEqti2YdmS8jvP2s=" + version = "v0.43.0" + hash = "sha256-bf3iQFrsC8BoarVaS0uSspEFAcr1zHp1uziTtBpwV34=" [mod."golang.org/x/sys"] - version = "v0.34.0" - hash = "sha256-5rZ7p8IaGli5X1sJbfIKOcOEwY4c0yQhinJPh2EtK50=" + version = "v0.35.0" + hash = "sha256-ZKM8pesQE6NAFZeKQ84oPn5JMhGr8g4TSwLYAsHMGSI=" [mod."gopkg.in/warnings.v0"] version = "v0.1.2" hash = "sha256-ATVL9yEmgYbkJ1DkltDGRn/auGAjqGOfjQyBYyUo8s8="
M nix/nixos-module.nixnix/nixos-module.nix
@@ -91,12 +91,6 @@ type = types.str;
default = "git frontend"; description = "Website description."; }; - syntaxHighlight = mkOption { - type = types.nullOr types.str; - default = null; - example = "monokailight"; - description = "Syntax highlighting theme."; - }; }; options.server = { name = mkOption {
M readmereadme
@@ -9,6 +9,7 @@ • Uses gomponents instead of html/template.
• Better integration with [gitolite](https://gitolite.com/gitolite/index.html) • repo.ignore is ignored: only repositories listed in projects.list are shown. • Supports subdirectories +• Removed syntax highlighting FEATURES
@@ -42,7 +43,6 @@ - main
meta: title: git good description: i think it's a skill issue - syntaxHighlight: monokailight server: name: git.icyphox.sh host: 127.0.0.1
@@ -56,10 +56,6 @@ • repo.readme: readme files to look for.
• repo.mainBranch: main branch names to look for. • repo.unlisted: repos to hide, relative to root/repositories. • server.name: used for go-import meta tags and clone URLs. -• meta.syntaxHighlight: this is used to select the syntax theme to render. If left - blank or removed, the native theme will be used. If an invalid theme is set in this field, - it will default to "monokailight". For more information - about themes, please refer to chroma's gallery [1]. NOTES
@@ -74,5 +70,3 @@
LICENSE elgit is licensed under MIT. - -[1]: https://swapoff.org/chroma/playground/
M routes/routes.goroutes/routes.go
@@ -205,11 +205,7 @@
if raw { d.showRaw(contents, w) } else { - if d.c.Meta.SyntaxHighlight == "" { - d.showFile(contents, data, w) - } else { - d.showFileWithHighlight(treePath, contents, data, w) - } + d.showFile(contents, data, w) } }
M routes/template.goroutes/template.go
@@ -9,9 +9,6 @@ "strings"
"alin.ovh/elgit/git" "alin.ovh/elgit/templates" - "github.com/alecthomas/chroma/v2/formatters/html" - "github.com/alecthomas/chroma/v2/lexers" - "github.com/alecthomas/chroma/v2/styles" ) func (d *deps) Write404(w http.ResponseWriter) {
@@ -92,58 +89,6 @@ }
} } -func (d *deps) showFileWithHighlight( - name, content string, - data map[string]any, - w http.ResponseWriter, -) { - lexer := lexers.Get(name) - if lexer == nil { - lexer = lexers.Get(".txt") - } - - style := styles.Get(d.c.Meta.SyntaxHighlight) - if style == nil { - style = styles.Get("monokailight") - } - - formatter := html.New( - html.WithLineNumbers(true), - html.WithLinkableLineNumbers(true, "L"), - ) - - iterator, err := lexer.Tokenise(nil, content) - if err != nil { - d.Write500(w) - - return - } - - var code bytes.Buffer - err = formatter.Format(&code, style, iterator) - if err != nil { - d.Write500(w) - - return - } - - pageData := templates.PageData{ - Meta: d.c.Meta, - DisplayName: getDisplayName(data["name"].(string)), - Content: code.String(), - Name: data["name"].(string), - Ref: data["ref"].(string), - Description: data["desc"].(string), - Path: data["path"].(string), - } - - if err := templates.FilePage(pageData, true).Render(w); err != nil { - log.Println(err) - - return - } -} - func (d *deps) showFile(content string, data map[string]any, w http.ResponseWriter) { lc, err := countLines(strings.NewReader(content)) if err != nil {
@@ -169,7 +114,7 @@ Description: data["desc"].(string),
Path: data["path"].(string), } - if err := templates.FilePage(pageData, false).Render(w); err != nil { + if err := templates.FilePage(pageData).Render(w); err != nil { log.Println(err) return
M static/style.cssstatic/style.css
@@ -304,13 +304,6 @@ background: var(--panel-background-color);
overflow-x: auto; } -.chroma-file-wrapper { - display: flex; - flex-direction: row; - grid-template-columns: 1rem minmax(0, 1fr); - overflow-x: auto; -} - .file-content { background: var(--panel-background-color); overflow-y: hidden;
M templates/file.gotemplates/file.go
@@ -8,32 +8,29 @@ . "alin.ovh/gomponents/html"
) // FilePage renders a file view page -func FilePage(data PageData, chroma bool) g.Node { +func FilePage(data PageData) g.Node { return Page(data, []g.Node{ RepoHeader(data), RenderNav(data), Main( P(g.Text(data.Path), g.Text(" ("), A(Href("?raw=true"), g.Text("view raw")), g.Text(")")), - g.If(chroma, - Div(Class("chroma-file-wrapper"), g.Raw(data.Content)), - Div(Class("file-wrapper"), - Table( - TBody( - Tr( - Td(Class("line-numbers"), - Pre(g.Map(data.LineCount, func(line int) g.Node { - return g.Group([]g.Node{ - g.Text("\n"), - A( - ID(fmt.Sprintf("L%d", line)), - Href(fmt.Sprintf("#L%d", line)), - g.Text(fmt.Sprintf("%d", line)), - )}) - })), - ), - Td(Class("file-content"), - Pre(g.Text(data.Content)), - ), + Div(Class("file-wrapper"), + Table( + TBody( + Tr( + Td(Class("line-numbers"), + Pre(g.Map(data.LineCount, func(line int) g.Node { + return g.Group([]g.Node{ + g.Text("\n"), + A( + ID(fmt.Sprintf("L%d", line)), + Href(fmt.Sprintf("#L%d", line)), + g.Text(fmt.Sprintf("%d", line)), + )}) + })), + ), + Td(Class("file-content"), + Pre(g.Text(data.Content)), ), ), ),