nitter/src/views/general.nim

57 lines
1.7 KiB
Nim
Raw Normal View History

import karax/[karaxdsl, vdom]
2019-08-07 20:02:19 +00:00
import ../utils
const doctype = "<!DOCTYPE html>\n"
2019-08-07 20:02:19 +00:00
proc renderMain*(body: VNode; title="Nitter"; titleText=""; desc="";
`type`="article"; video=""; images: seq[string] = @[]): string =
let node = buildHtml(html(lang="en")):
head:
link(rel="stylesheet", `type`="text/css", href="/style.css")
2019-08-07 20:02:19 +00:00
title:
if titleText.len > 0:
text titleText & " | " & title
else:
text title
2019-08-07 20:27:24 +00:00
meta(property="og:type", content=`type`)
meta(property="og:title", content=titleText)
meta(property="og:url", content="https://t.co/VOkeVRgJgc")
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
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
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...")
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")