Use staticDir to load about page

Fixes #414
Closes #406
This commit is contained in:
Zed 2022-01-09 23:48:25 +01:00
parent 8c2e0c66e2
commit 4ec2874008
2 changed files with 8 additions and 5 deletions

View file

@ -32,6 +32,7 @@ setHmacKey(cfg.hmacKey)
setProxyEncoding(cfg.base64Media)
setMaxHttpConns(cfg.httpMaxConns)
setHttpProxy(cfg.proxy, cfg.proxyAuth)
initAboutPage(cfg.staticDir)
waitFor initRedisPool(cfg)
stdout.write &"Connected to Redis at {cfg.redisHost}:{cfg.redisPort}\n"

View file

@ -8,16 +8,18 @@ const
link = "https://github.com/zedeus/nitter/commit/" & hash
version = &"{date}-{hash}"
let about =
var aboutHtml: string
proc initAboutPage*(dir: string) =
try:
readFile("public/md/about.html")
aboutHtml = readFile(&"{dir}/md/about.html")
except IOError:
stderr.write "public/md/about.html not found, please run `nimble md`\n"
"<h1>About page is missing</h1><br><br>"
stderr.write &"{dir}/about.html not found, please run `nimble md`\n"
aboutHtml = "<h1>About page is missing</h1><br><br>"
proc renderAbout*(): VNode =
buildHtml(tdiv(class="overlay-panel")):
verbatim about
verbatim aboutHtml
h2: text "Instance info"
p:
text "Version "