diff --git a/appview/pages/pages.go b/appview/pages/pages.go index fd16a90..cc78da6 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -50,6 +50,9 @@ func funcMap() template.FuncMap { return pairs, nil }, "timeFmt": humanize.Time, + "length": func(v []string) int { + return len(v) + }, } } @@ -255,10 +258,12 @@ func (p *Pages) RepoTags(w io.Writer, params RepoTagsParams) error { type RepoBlobParams struct { LoggedInUser *auth.User RepoInfo RepoInfo + Active string types.RepoBlobResponse } func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error { + params.Active = "overview" return p.executeRepo("repo/blob", w, params) } diff --git a/appview/pages/templates/repo/blob.html b/appview/pages/templates/repo/blob.html index 345b944..3738a53 100644 --- a/appview/pages/templates/repo/blob.html +++ b/appview/pages/templates/repo/blob.html @@ -1,12 +1,9 @@ {{ define "repoContent" }} - - - - - -
- {{ range $i, $x := split .Contents }} - {{ add $i 1 }} {{ $x }}
- {{ end }} -
-{{end}} +{{ $lines := split .Contents }} +{{ $tot_lines := len $lines }} +{{ $tot_chars := len (printf "%d" $tot_lines) }} +{{ $code_number_style := "code-line-num text-gray-400 mr-2 px-1 sticky left-0 bg-white border-r border-black text-right w-[{{$tot_chars}}rem]" }} +
{{ range $idx, $line := $lines }}
+  {{ add $idx 1 }}
+  {{ $line }}{{ else }}this file is empty{{ end }}
+{{ end }} diff --git a/flake.nix b/flake.nix index d027ef8..2b84449 100644 --- a/flake.nix +++ b/flake.nix @@ -54,27 +54,19 @@ ${pkgs.tailwindcss}/bin/tailwindcss -i input.css -o appview/pages/static/tw.css ''; subPackages = ["cmd/appview"]; - vendorHash = "sha256-QgUPTOgAdKUTg+ztfs194G7pt3/qDtqTMkDRmMECxSo="; + vendorHash = "sha256-t7lWrCyFWCI7zjUcC6XNWzCrUPSCFnFu9gTmRTsYrz0="; env.CGO_ENABLED = 1; stdenv = pkgsStatic.stdenv; }; - - knotserver = with final; + knotserver = with final; final.pkgsStatic.buildGoModule { - pname = "knotserver"; - version = "0.1.0"; - src = gitignoreSource ./.; - subPackages = ["cmd/knotserver"]; - vendorHash = "sha256-QgUPTOgAdKUTg+ztfs194G7pt3/qDtqTMkDRmMECxSo="; - env.CGO_ENABLED = 1; - nativeBuildInputs = with pkgsMusl; [ pkg-config ]; - - # Add these ldflags for static compilation - ldflags = [ "-s" "-w" "-linkmode external" ''-extldflags "-static -L${pkgsStatic.musl}/lib"'' ]; - - # Use static stdenv - stdenv = pkgMusl.stdenv; - }; + pname = "knotserver"; + version = "0.1.0"; + src = gitignoreSource ./.; + subPackages = ["cmd/knotserver"]; + vendorHash = "sha256-t7lWrCyFWCI7zjUcC6XNWzCrUPSCFnFu9gTmRTsYrz0="; + env.CGO_ENABLED = 1; + }; }; packages = forAllSystems (system: { inherit (nixpkgsFor."${system}") indigo-lexgen appview knotserver; diff --git a/go.mod b/go.mod index a91ea93..68a1878 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/bluesky-social/indigo v0.0.0-20250123072624-9e3b84fdbb20 github.com/bluesky-social/jetstream v0.0.0-20241210005130-ea96859b93d1 github.com/casbin/casbin/v2 v2.103.0 + github.com/dustin/go-humanize v1.0.1 github.com/gliderlabs/ssh v0.3.5 github.com/go-chi/chi/v5 v5.2.0 github.com/go-git/go-git/v5 v5.12.0 @@ -37,7 +38,6 @@ require ( github.com/cloudflare/circl v1.4.0 // indirect github.com/cyphar/filepath-securejoin v0.3.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dustin/go-humanize v1.0.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect