Compare commits

...

2 Commits

Author SHA1 Message Date
Daylin Morgan 86c5c0a786
build: add flake.nix for direnv use 2024-02-07 15:03:04 -06:00
Daylin Morgan f2d39c58dc
feat: add hyperlinks to version table 2024-02-07 15:02:55 -06:00
6 changed files with 82 additions and 5 deletions

View File

@ -9,4 +9,9 @@ task build, "build":
exec "pnpm run build"
task watch, "rebuild on change":
exec "watchexec -w src nim js -d:packagesHash:master -o:site/app.js src/app.nim"
exec (
"watchexec " &
"--project-origin . -w src " &
"nim js -d:packagesHash:master -o:site/app.js src/app.nim"
)

27
flake.lock Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1707205916,
"narHash": "sha256-fmRJilYGlB7VCt3XsdYxrA0u8e/K84O5xYucerUY0iM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8cc79aa39bbc6eaedaf286ae655b224c71e02907",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

26
flake.nix Normal file
View File

@ -0,0 +1,26 @@
{
description = "nimpkgs website";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};
outputs = inputs @ {
self,
nixpkgs,
}: let
inherit (nixpkgs.lib) genAttrs;
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
forAllSystems = f: genAttrs supportedSystems (system: f nixpkgs.legacyPackages.${system});
in {
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
buildInputs = with pkgs; [
nim
nim-atlas
watchexec
nodePackages.pnpm
];
};
});
};
}

View File

@ -1,10 +1,11 @@
import std/[
algorithm, asyncjs,
strutils, sugar, tables, times
strutils, sugar, tables, times, uri
]
import karax/[kbase]
import jsony
import ./utils
export algorithm, tables, times, asyncjs, sugar
proc parseHook*(s: string, i: var int, v: var kstring) =
@ -69,3 +70,14 @@ proc sortVersion*(a, b: NimPackage): int =
proc isAlias*(p: NimPackage): bool {.inline.} = p.alias != ""
proc canonicalUrl*(p: NimPackage): kstring =
var uri = parseUri($p.url)
uri.path = uri.path.replace(".git")
# NOTE: why do I use this?
if uri.path[^1] == '/':
uri.path = uri.path[0..^2]
uri.query = ""
return uri.jss

View File

@ -1,11 +1,15 @@
import std/[algorithm, sugar]
import karax/[kbase, karaxdsl, vdom, jstrutils]
import karax/[kbase, karax, karaxdsl, kdom, vdom, jstrutils, ]
import ../[context, packages, style]
import ../components/[tag, package]
import ../utils
import notfound
proc openLink(link: kstring): proc() =
result = proc() =
discard open(window, link, "_self")
proc versionTable(pkg: NimPackage): VNode =
var versions = pkg.versions
versions.sort((a, b: Version) => cmp(a.time, b.time), order = Descending)
@ -17,7 +21,10 @@ proc versionTable(pkg: NimPackage): VNode =
th: text "released"
th: text "hash"
for version in versions:
tr:
tr(
onClick = openLink(pkg.canonicalUrl & "/tree/" & version.tag.jss),
class = "link"
):
td: text version.tag
td: text version.time.format("yyyy-MM-dd")
td: text ($version.hash)[0..8]

View File

@ -43,7 +43,7 @@ export default defineConfig({
color: ${catppuccinColors.mauve};
cursor: pointer;
}
// loading animation
/* loading animation */
.lds-dual-ring {
display: inline-block;
width: 80px;