general.nim 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import karax/[karaxdsl, vdom]
  2. import ../utils
  3. const doctype = "<!DOCTYPE html>\n"
  4. proc renderMain*(body: VNode; title="Nitter"; titleText=""; desc="";
  5. `type`="article"; video=""; images: seq[string] = @[]): string =
  6. let node = buildHtml(html(lang="en")):
  7. head:
  8. link(rel="stylesheet", `type`="text/css", href="/style.css")
  9. title:
  10. if titleText.len > 0:
  11. text titleText & " | " & title
  12. else:
  13. text title
  14. meta(property="og:type", content=`type`)
  15. meta(property="og:title", content=titleText)
  16. meta(property="og:url", content="https://t.co/VOkeVRgJgc")
  17. meta(property="og:description", content=desc)
  18. meta(property="og:site_name", content="Twitter")
  19. for url in images:
  20. meta(property="og:image", content=getSigUrl(url, "pic"))
  21. if video.len > 0:
  22. meta(property="og:video:url", content=video)
  23. meta(property="og:video:secure_url", content=video)
  24. body:
  25. nav(id="nav", class="nav-bar container"):
  26. tdiv(class="inner-nav"):
  27. tdiv(class="item"):
  28. a(href="/", class="site-name"): text title
  29. tdiv(id="content", class="container"):
  30. body
  31. result = doctype & $node
  32. proc renderSearch*(): VNode =
  33. buildHtml(tdiv(class="panel")):
  34. tdiv(class="search-panel"):
  35. form(`method`="post", action="search"):
  36. input(`type`="text", name="query", placeholder="Enter usernames...")
  37. button(`type`="submit"): text "🔎"
  38. proc renderError*(error: string): VNode =
  39. buildHtml(tdiv(class="panel")):
  40. tdiv(class="error-panel"):
  41. span: text error
  42. proc showError*(error: string; title: string): string =
  43. renderMain(renderError(error), title=title, titleText="Error")