2019-07-10 22:42:31 +00:00
|
|
|
import karax/[karaxdsl, vdom]
|
|
|
|
|
2019-08-15 02:00:40 +00:00
|
|
|
import renderutils
|
2019-08-13 17:44:29 +00:00
|
|
|
import ../utils, ../types
|
2019-08-07 20:02:19 +00:00
|
|
|
|
2019-07-10 22:42:31 +00:00
|
|
|
const doctype = "<!DOCTYPE html>\n"
|
|
|
|
|
2019-09-05 20:40:36 +00:00
|
|
|
proc renderNavbar*(title, path: string): VNode =
|
2019-08-12 20:57:43 +00:00
|
|
|
buildHtml(nav(id="nav", class="nav-bar container")):
|
|
|
|
tdiv(class="inner-nav"):
|
|
|
|
tdiv(class="item"):
|
|
|
|
a(class="site-name", href="/"): text title
|
|
|
|
|
|
|
|
a(href="/"): img(class="site-logo", src="/logo.png")
|
|
|
|
|
|
|
|
tdiv(class="item right"):
|
2019-08-15 02:00:40 +00:00
|
|
|
icon "info-circled", title="About", href="/about"
|
2019-09-05 20:40:36 +00:00
|
|
|
iconReferer "cog", "/settings", path, title="Preferences"
|
2019-08-12 20:57:43 +00:00
|
|
|
|
2019-08-19 18:25:00 +00:00
|
|
|
proc renderMain*(body: VNode; prefs: Prefs; title="Nitter"; titleText=""; desc="";
|
2019-09-05 20:40:36 +00:00
|
|
|
path="/"; `type`="article"; video=""; images: seq[string] = @[]): string =
|
2019-07-10 22:42:31 +00:00
|
|
|
let node = buildHtml(html(lang="en")):
|
|
|
|
head:
|
2019-08-15 02:00:40 +00:00
|
|
|
link(rel="stylesheet", `type`="text/css", href="/css/style.css")
|
|
|
|
link(rel="stylesheet", `type`="text/css", href="/css/fontello.css")
|
2019-07-10 22:42:31 +00:00
|
|
|
|
2019-08-19 18:25:00 +00:00
|
|
|
if prefs.hlsPlayback:
|
|
|
|
script(src="/js/hls.light.min.js")
|
|
|
|
script(src="/js/hlsPlayback.js")
|
|
|
|
|
2019-08-07 20:02:19 +00:00
|
|
|
title:
|
|
|
|
if titleText.len > 0:
|
|
|
|
text titleText & " | " & title
|
|
|
|
else:
|
|
|
|
text title
|
|
|
|
|
2019-09-07 16:52:27 +00:00
|
|
|
meta(name="viewport", content="width=device-width, initial-scale=1.0")
|
2019-08-07 20:27:24 +00:00
|
|
|
meta(property="og:type", content=`type`)
|
|
|
|
meta(property="og:title", content=titleText)
|
|
|
|
meta(property="og:description", content=desc)
|
|
|
|
meta(property="og:site_name", content="Twitter")
|
2019-08-07 20:02:19 +00:00
|
|
|
|
|
|
|
for url in images:
|
2019-08-07 20:27:24 +00:00
|
|
|
meta(property="og:image", content=getSigUrl(url, "pic"))
|
2019-08-07 20:02:19 +00:00
|
|
|
|
|
|
|
if video.len > 0:
|
2019-08-07 20:27:24 +00:00
|
|
|
meta(property="og:video:url", content=video)
|
|
|
|
meta(property="og:video:secure_url", content=video)
|
2019-08-07 20:02:19 +00:00
|
|
|
|
2019-07-10 22:42:31 +00:00
|
|
|
body:
|
2019-09-05 20:40:36 +00:00
|
|
|
renderNavbar(title, path)
|
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"):
|
2019-08-22 21:44:22 +00:00
|
|
|
form(`method`="post", action="/search"):
|
2019-08-13 18:21:35 +00:00
|
|
|
input(`type`="text", name="query", autofocus="", placeholder="Enter usernames...")
|
2019-08-15 02:00:40 +00:00
|
|
|
button(`type`="submit"): icon "search"
|
2019-07-10 22:42:31 +00:00
|
|
|
|
|
|
|
proc renderError*(error: string): VNode =
|
|
|
|
buildHtml(tdiv(class="panel")):
|
|
|
|
tdiv(class="error-panel"):
|
|
|
|
span: text error
|
|
|
|
|
2019-08-15 21:17:13 +00:00
|
|
|
proc showError*(error, title: string): string =
|
2019-08-19 18:25:00 +00:00
|
|
|
renderMain(renderError(error), Prefs(), title, "Error")
|