Compare commits

...

6 commits

11 changed files with 940 additions and 825 deletions

View file

@ -38,7 +38,7 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-pnpm-store- ${{ runner.os }}-pnpm-store-
- uses: jiro4989/setup-nim-action@v1 - uses: jiro4989/setup-nim-action@v2
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
@ -47,8 +47,8 @@ jobs:
- name: Build Website - name: Build Website
run: | run: |
nimble install -Y 'https://github.com/nim-lang/atlas.git@#f7ade65f' nimble setup -l
nim setup nimble install -d -Y
nim build nim build
- name: Upload artifact - name: Upload artifact

3
.gitignore vendored
View file

@ -140,3 +140,6 @@ src/*.js
# for debugging # for debugging
site/nimpkgs.json site/nimpkgs.json
# nimble.develop
nimble.paths
nimbledeps

View file

@ -1,9 +1,5 @@
switch("backend","js") switch("backend","js")
task setup, "run atlas init":
exec "atlas init --deps=.workspace"
exec "atlas install"
task build, "build": task build, "build":
selfExec "js -o:site/app.js -d:release src/app.nim" selfExec "js -o:site/app.js -d:release src/app.nim"
exec "pnpm run build" exec "pnpm run build"
@ -15,3 +11,8 @@ task watch, "rebuild on change":
"nim js -d:packagesHash:master -o:site/app.js src/app.nim" "nim js -d:packagesHash:master -o:site/app.js src/app.nim"
) )
# begin Nimble config (version 2)
--noNimblePath
when withDir(thisDir(), system.fileExists("nimble.paths")):
include "nimble.paths"
# end Nimble config

View file

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1707205916, "lastModified": 1723703277,
"narHash": "sha256-fmRJilYGlB7VCt3XsdYxrA0u8e/K84O5xYucerUY0iM=", "narHash": "sha256-nk0RaUB5f68BwtXAYy3WAjqFhVKqIl9Z89RGycTa2vk=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8cc79aa39bbc6eaedaf286ae655b224c71e02907", "rev": "8b908192e64224420e2d59dfd9b2e4309e154c5d",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -4,9 +4,9 @@
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
}; };
outputs = inputs @ { outputs = {
self,
nixpkgs, nixpkgs,
...
}: let }: let
inherit (nixpkgs.lib) genAttrs; inherit (nixpkgs.lib) genAttrs;
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]; supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
@ -16,7 +16,7 @@
default = pkgs.mkShell { default = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
nim nim
nim-atlas nimble
watchexec watchexec
nodePackages.pnpm nodePackages.pnpm
]; ];

49
nimble.lock Normal file
View file

@ -0,0 +1,49 @@
{
"version": 2,
"packages": {
"dotenv": {
"version": "2.0.2",
"vcsRevision": "a3c6726147276ea1447dee292fd27bb036242b78",
"url": "https://github.com/euantorano/dotenv.nim",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "1e70fc63c286ca3da7592d61dbe501fcea35bc72"
}
},
"jsony": {
"version": "1.1.5",
"vcsRevision": "ea811bec7fa50f5abd3088ba94cda74285e93f18",
"url": "https://github.com/treeform/jsony",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "6aeb83e7481ca8686396a568096054bc668294df"
}
},
"ws": {
"version": "0.5.0",
"vcsRevision": "9536bf99ddf5948db221ccb7bb3663aa238a8e21",
"url": "https://github.com/treeform/ws",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "ae4daf4ae302d0431f3c2d385ae9d2fe767a3246"
}
},
"karax": {
"version": "1.3.3",
"vcsRevision": "d86349c63d8ece330d749eb037a9fa5ffca87c79",
"url": "https://github.com/karaxnim/karax/",
"downloadMethod": "git",
"dependencies": [
"ws",
"dotenv"
],
"checksums": {
"sha1": "6683189b4456437c2809be72e3404adde77f5c34"
}
}
},
"tasks": {}
}

View file

@ -11,16 +11,16 @@
"author": "Daylin Morgan", "author": "Daylin Morgan",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@catppuccin/palette": "^1.1.0", "@catppuccin/palette": "^1.2.0",
"@iconify-json/mdi": "^1.1.64", "@iconify-json/mdi": "^1.1.68",
"@iconify-json/simple-icons": "^1.1.92", "@iconify-json/simple-icons": "^1.1.113",
"@types/promise-fs": "^2.1.5", "@types/promise-fs": "^2.1.5",
"@unocss/cli": "^0.58.5", "@unocss/cli": "^0.62.2",
"@unocss/preset-icons": "^0.58.5", "@unocss/preset-icons": "^0.62.2",
"@unocss/reset": "^0.58.5", "@unocss/reset": "^0.62.2",
"concurrently": "^8.2.2", "concurrently": "^8.2.2",
"esbuild": "^0.20.1", "esbuild": "^0.23.1",
"http-server": "^14.1.1", "http-server": "^14.1.1",
"unocss": "^0.58.5" "unocss": "^0.62.2"
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
import std/[strutils, sequtils, dom, uri] import std/[strutils, uri]
import karax/[kbase, karax, karaxdsl, vdom, jstrutils, kdom] import karax/[kbase, karax, karaxdsl, vdom, jstrutils]
import ../[packages, style, context] import ../[packages, style, context]
# import ../components/package # import ../components/package
@ -23,31 +23,36 @@ proc parseQuery*(s: kstring): Query =
k = subparts[0] k = subparts[0]
v = subparts[1] v = subparts[1]
case k: case k:
of "name": of "name":
result.name = v result.name = v
of "tag": of "tag":
result.tag = v.replace("-") result.tag = v.replace("-")
of "license": of "license":
result.license = v result.license = v
else: discard else: discard
else: else:
result.all &= part result.all &= part
proc toLowerAscii(ks: kstring): kstring {.inline.} = ($ks).toLowerAscii().kstring
proc searchPackages*(q: Query): seq[NimPackage] = proc genericSearchString(p: NimPackage): kstring =
if q == Query(): (@[p.url, p.name, p.description, p.tags.join(" ").kstring].join(" ").kstring).toLowerAscii()
result = ctx.nimpkgs.packages.values.toSeq()
proc `~=`(q: Query, pkg: NimPackage): bool =
let searchStr = pkg.genericSearchString()
if (q.name notin pkg.name) or (q.license notin pkg.license) or
(q.tag != "".kstring and (q.tag notin pkg.tags)):
return return
for name, pkg in ctx.nimpkgs.packages: if q.all.toLowerAscii() in searchStr:
let searchStr = ((pkg.url & " " & pkg.name & " " & pkg.description & " " & ( return true
pkg.tags).join(" ").kstring))
if (q.name notin pkg.name) or
(q.license notin pkg.license) or
(q.tag != "".kstring and (q.tag notin pkg.tags)): continue
if q.all in searchStr: proc searchPackages*(q: Query): seq[NimPackage] =
result.add pkg if q == Query(): return nimpkgsList()
collect:
for _, pkg in ctx.nimpkgs.packages:
if q ~= pkg: pkg
proc getSearchFromUri*(): kstring = proc getSearchFromUri*(): kstring =
var url = currentUri() var url = currentUri()

View file

@ -1,5 +1,5 @@
import std/[ import std/[
asyncjs, jsconsole, jsfetch, sugar, tables asyncjs, jsconsole, jsfetch, sequtils, sugar, tables
] ]
import karax/[kbase, karax] import karax/[kbase, karax]
@ -14,6 +14,8 @@ type
nimpkgs*: NimPkgs nimpkgs*: NimPkgs
loaded*: bool loaded*: bool
var ctx* = Context()
let nimpkgsUrl = let nimpkgsUrl =
when defined(debug): "http://localhost:8080/nimpkgs.json" when defined(debug): "http://localhost:8080/nimpkgs.json"
else: "https://raw.githubusercontent.com/nimpkgs/nimpkgs/main/nimpkgs.json" else: "https://raw.githubusercontent.com/nimpkgs/nimpkgs/main/nimpkgs.json"
@ -29,5 +31,8 @@ proc fetchPackages*(ctx: var Context){.async.} =
) )
.catch((err: Error) => console.log err .catch((err: Error) => console.log err
) )
var ctx* = Context()
discard ctx.fetchPackages discard ctx.fetchPackages
proc nimpkgsList*(): seq[NimPackage] {.inline.} =
ctx.nimpkgs.packages.values.toSeq()

View file

@ -90,7 +90,7 @@ proc filteredPackagesDom(): VNode =
pkg.card pkg.card
proc update(pgCtx: var PageContext) = proc update(pgCtx: var PageContext) =
pgCtx.filteredPackages = ctx.nimpkgs.packages.values().toSeq() pgCtx.filteredPackages = nimpkgsList()
pgCtx.search = getSearchFromUri() pgCtx.search = getSearchFromUri()
pgCtx.filteredPackages = searchPackages(parseQuery(pgCtx.search)) pgCtx.filteredPackages = searchPackages(parseQuery(pgCtx.search))