From f33e9936922b6d3a36c25f62ee12ddd303dd2c0d Mon Sep 17 00:00:00 2001 From: mleku Date: Sun, 27 Apr 2025 12:24:00 -0106 Subject: [PATCH] fix missing files from legit --- cmd/legit/contrib/Dockerfile | 22 +++++++++ cmd/legit/flake.lock | 26 +++++++++++ cmd/legit/flake.nix | 62 +++++++++++++++++++++++++ cmd/legit/go.mod | 2 +- cmd/legit/license | 23 ++++++++++ cmd/legit/main.go | 4 +- cmd/legit/readme | 88 ++++++++++++++++++++++++++++++++++++ cmd/legit/routes/git.go | 2 +- cmd/legit/routes/handler.go | 2 +- cmd/legit/routes/routes.go | 4 +- cmd/legit/routes/template.go | 2 +- cmd/legit/routes/util.go | 2 +- 12 files changed, 230 insertions(+), 9 deletions(-) create mode 100644 cmd/legit/contrib/Dockerfile create mode 100644 cmd/legit/flake.lock create mode 100644 cmd/legit/flake.nix create mode 100644 cmd/legit/license create mode 100644 cmd/legit/readme diff --git a/cmd/legit/contrib/Dockerfile b/cmd/legit/contrib/Dockerfile new file mode 100644 index 0000000..c36cba0 --- /dev/null +++ b/cmd/legit/contrib/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.22-alpine AS builder + +WORKDIR /app + +COPY . . +RUN go mod download +RUN go mod verify + +RUN go build -o legit + +FROM scratch AS build-release-stage + +WORKDIR /app + +COPY static ./static +COPY templates ./templates +COPY config.yaml ./ +COPY --from=builder /app/legit ./ + +EXPOSE 5555 + +CMD ["./legit"] diff --git a/cmd/legit/flake.lock b/cmd/legit/flake.lock new file mode 100644 index 0000000..9841a94 --- /dev/null +++ b/cmd/legit/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1718558927, + "narHash": "sha256-PRqvkPqX5luuZ0WcUbz2zATGp4IzybDU0K33MxO9Sd0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f82fe275d98c521c051af4892cd8b3406cee67a3", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/cmd/legit/flake.nix b/cmd/legit/flake.nix new file mode 100644 index 0000000..178cce8 --- /dev/null +++ b/cmd/legit/flake.nix @@ -0,0 +1,62 @@ +{ + description = "web frontend for git"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs"; + + outputs = + { self + , nixpkgs + , + }: + let + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in + { + packages = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; + legit = self.packages.${system}.legit; + files = pkgs.lib.fileset.toSource { + root = ./.; + fileset = pkgs.lib.fileset.unions [ + ./config.yaml + ./static + ./templates + ]; + }; + in + { + legit = pkgs.buildGoModule { + name = "legit"; + rev = "master"; + src = ./.; + + vendorHash = "sha256-ynv0pBdVPIhTz7RvCwVWr0vUWwfw+PEjFXs9PdQMqm8="; + }; + docker = pkgs.dockerTools.buildLayeredImage { + name = "sini:5000/legit"; + tag = "latest"; + contents = [ files legit pkgs.git ]; + config = { + Entrypoint = [ "${legit}/bin/legit" ]; + ExposedPorts = { "5555/tcp" = { }; }; + }; + }; + }); + + defaultPackage = forAllSystems (system: self.packages.${system}.legit); + devShells = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; + in + { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + go + ]; + }; + }); + }; +} diff --git a/cmd/legit/go.mod b/cmd/legit/go.mod index 8e7dd68..516d7ef 100644 --- a/cmd/legit/go.mod +++ b/cmd/legit/go.mod @@ -1,4 +1,4 @@ -module git.icyphox.sh/legit +module realy.lol/cmd/legit go 1.22.0 diff --git a/cmd/legit/license b/cmd/legit/license new file mode 100644 index 0000000..fc9152a --- /dev/null +++ b/cmd/legit/license @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) Anirudh Oppiliappan + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/cmd/legit/main.go b/cmd/legit/main.go index 01b1e5d..2f716d5 100644 --- a/cmd/legit/main.go +++ b/cmd/legit/main.go @@ -6,8 +6,8 @@ import ( "log" "net/http" - "git.icyphox.sh/legit/config" - "git.icyphox.sh/legit/routes" + "realy.lol/cmd/legit/config" + "realy.lol/cmd/legit/routes" ) func main() { diff --git a/cmd/legit/readme b/cmd/legit/readme new file mode 100644 index 0000000..bc0ef0b --- /dev/null +++ b/cmd/legit/readme @@ -0,0 +1,88 @@ +legit +----- + +A git web frontend written in Go. + +Pronounced however you like; I prefer channeling my inner beret-wearing +Frenchman, and saying "Oui, il est le git!" + +But yeah it's pretty legit, no cap on god fr fr. + + +FEATURES + +• Fully customizable templates and stylesheets. +• Cloning over http(s). +• Less archaic HTML. +• Not CGI. + + +INSTALLING + +Clone it, 'go build' it. + + +CONFIG + +Uses yaml for configuration. Looks for a 'config.yaml' in the current +directory by default; pass the '--config' flag to point it elsewhere. + +Example config.yaml: + + repo: + scanPath: /var/www/git + readme: + - readme + - README + - readme.md + - README.md + mainBranch: + - master + - main + ignore: + - foo + - bar + dirs: + templates: ./templates + static: ./static + meta: + title: git good + description: i think it's a skill issue + syntaxHighlight: monokailight + server: + name: git.icyphox.sh + host: 127.0.0.1 + port: 5555 + +These options are fairly self-explanatory, but of note are: + +• repo.scanPath: where all your git repos live (or die). legit doesn't + traverse subdirs yet. +• dirs: use this to override the default templates and static assets. +• repo.readme: readme files to look for. +• repo.mainBranch: main branch names to look for. +• repo.ignore: repos to ignore, relative to scanPath. +• repo.unlisted: repos to hide, relative to scanPath. +• 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 + +• Run legit behind a TLS terminating proxy like relayd(8) or nginx. +• Cloning only works in bare repos -- this is a limitation inherent to git. You + can still view non-bare repos just fine in legit. +• Pushing over https, while supported, is disabled because auth is a + pain. Use ssh. +• Paths are unveil(2)'d on OpenBSD. +• Docker images are available ghcr.io/icyphox/legit:{master,latest,vX.Y.Z}. [2] + +LICENSE + +legit is licensed under MIT. + +[1]: https://swapoff.org/chroma/playground/ +[2]: https://github.com/icyphox/legit/pkgs/container/legit diff --git a/cmd/legit/routes/git.go b/cmd/legit/routes/git.go index d7c88c2..05a35a2 100644 --- a/cmd/legit/routes/git.go +++ b/cmd/legit/routes/git.go @@ -9,7 +9,7 @@ import ( securejoin "github.com/cyphar/filepath-securejoin" - "git.icyphox.sh/legit/git/service" + "realy.lol/cmd/legit/git/service" ) func (d *deps) InfoRefs(w http.ResponseWriter, r *http.Request) { diff --git a/cmd/legit/routes/handler.go b/cmd/legit/routes/handler.go index 2a35168..160ec31 100644 --- a/cmd/legit/routes/handler.go +++ b/cmd/legit/routes/handler.go @@ -3,7 +3,7 @@ package routes import ( "net/http" - "git.icyphox.sh/legit/config" + "realy.lol/cmd/legit/config" ) // Checks for gitprotocol-http(5) specific smells; if found, passes diff --git a/cmd/legit/routes/routes.go b/cmd/legit/routes/routes.go index 29caf4e..694e9a2 100644 --- a/cmd/legit/routes/routes.go +++ b/cmd/legit/routes/routes.go @@ -18,8 +18,8 @@ import ( "github.com/microcosm-cc/bluemonday" "github.com/russross/blackfriday/v2" - "git.icyphox.sh/legit/config" - "git.icyphox.sh/legit/git" + "realy.lol/cmd/legit/config" + "realy.lol/cmd/legit/git" ) type deps struct { diff --git a/cmd/legit/routes/template.go b/cmd/legit/routes/template.go index 1ff004a..46b9bd3 100644 --- a/cmd/legit/routes/template.go +++ b/cmd/legit/routes/template.go @@ -13,7 +13,7 @@ import ( "github.com/alecthomas/chroma/v2/lexers" "github.com/alecthomas/chroma/v2/styles" - "git.icyphox.sh/legit/git" + "realy.lol/cmd/legit/git" ) func (d *deps) Write404(w http.ResponseWriter) { diff --git a/cmd/legit/routes/util.go b/cmd/legit/routes/util.go index 464032f..c5b4655 100644 --- a/cmd/legit/routes/util.go +++ b/cmd/legit/routes/util.go @@ -8,7 +8,7 @@ import ( "path/filepath" "strings" - "git.icyphox.sh/legit/git" + "realy.lol/cmd/legit/git" ) func isGoModule(gr *git.GitRepo) bool {