2019-07-10 22:42:31 +00:00
|
|
|
import karax/[karaxdsl, vdom]
|
|
|
|
|
|
|
|
const doctype = "<!DOCTYPE html>\n"
|
|
|
|
|
2019-07-31 00:15:43 +00:00
|
|
|
proc renderMain*(body: VNode; title="Nitter"; titleText=""): string =
|
2019-07-10 22:42:31 +00:00
|
|
|
let node = buildHtml(html(lang="en")):
|
|
|
|
head:
|
2019-07-31 00:15:43 +00:00
|
|
|
if titleText.len > 0:
|
|
|
|
title: text titleText & " | " & title
|
|
|
|
else:
|
|
|
|
title: text title
|
2019-07-10 22:42:31 +00:00
|
|
|
link(rel="stylesheet", `type`="text/css", href="/style.css")
|
|
|
|
|
|
|
|
body:
|
|
|
|
nav(id="nav", class="nav-bar container"):
|
|
|
|
tdiv(class="inner-nav"):
|
|
|
|
tdiv(class="item"):
|
2019-07-31 00:15:43 +00:00
|
|
|
a(href="/", class="site-name"): text title
|
2019-07-10 22:42:31 +00:00
|
|
|
|
|
|
|
tdiv(id="content", class="container"):
|
|
|
|
body
|
|
|
|
|
|
|
|
result = doctype & $node
|
|
|
|
|
|
|
|
proc renderSearch*(): VNode =
|
|
|
|
buildHtml(tdiv(class="panel")):
|
|
|
|
tdiv(class="search-panel"):
|
|
|
|
form(`method`="post", action="search"):
|
2019-08-06 15:41:06 +00:00
|
|
|
input(`type`="text", name="query", placeholder="Enter usernames...")
|
2019-07-10 22:42:31 +00:00
|
|
|
button(`type`="submit"): text "🔎"
|
|
|
|
|
|
|
|
proc renderError*(error: string): VNode =
|
|
|
|
buildHtml(tdiv(class="panel")):
|
|
|
|
tdiv(class="error-panel"):
|
|
|
|
span: text error
|
|
|
|
|
2019-07-31 00:15:43 +00:00
|
|
|
proc showError*(error: string; title: string): string =
|
|
|
|
renderMain(renderError(error), title=title, titleText="Error")
|