feat: update package info with commit age

This commit is contained in:
Daylin Morgan 2023-11-25 02:20:24 -06:00
parent 0175ac9548
commit 9c45cf8983
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F

View file

@ -1,5 +1,5 @@
import std/[algorithm, sugar] import std/[algorithm, sugar]
import karax/[karaxdsl, vdom, jstrutils] import karax/[kbase, karaxdsl, vdom, jstrutils]
import ../[context, packages, style] import ../[context, packages, style]
import ../components/[tag, package] import ../components/[tag, package]
@ -14,7 +14,7 @@ proc versionTable(pkg: NimPackage): VNode =
table(class = "table-auto w-full text-center"): table(class = "table-auto w-full text-center"):
tr: tr:
th: text "version" th: text "version"
th: text "release" th: text "released"
th: text "hash" th: text "hash"
for version in versions: for version in versions:
tr: tr:
@ -43,6 +43,11 @@ proc renderLinks(pkg: NimPackage): VNode = buildHtml(tdiv):
tdiv(class = "i-mdi-file-outline shrink-0") tdiv(class = "i-mdi-file-outline shrink-0")
span: text pkg.doc.noProtocol span: text pkg.doc.noProtocol
proc getTimeSinceCommit(pkg: NimPackage): kstring =
if pkg.lastCommitTime == fromUnix(0): "unknown".jss
else:
let d = getTime() - pkg.lastCommitTime
d.inDays.jss & " days ago"
proc renderPkgInfo(pkg: NimPackage): VNode = proc renderPkgInfo(pkg: NimPackage): VNode =
buildHtml: buildHtml:
@ -56,6 +61,9 @@ proc renderPkgInfo(pkg: NimPackage): VNode =
tdiv: tdiv:
tdiv: text "tags:" tdiv: text "tags:"
pkg.tags.renderTags pkg.tags.renderTags
tdiv:
tdiv: text "last commit:"
text pkg.getTimeSinceCommit
tdiv: tdiv:
tdiv: text "usage:" tdiv: text "usage:"
tdiv(class = "bg-ctp-surfacezero rounded my-2 mx-3 p-2 w-auto"): tdiv(class = "bg-ctp-surfacezero rounded my-2 mx-3 p-2 w-auto"):