2019-09-05 20:40:36 +00:00
|
|
|
import strutils
|
2019-09-06 01:37:12 +00:00
|
|
|
import karax/[karaxdsl, vdom]
|
2019-07-10 22:42:31 +00:00
|
|
|
|
|
|
|
import ../types, ../utils
|
|
|
|
|
2019-08-15 02:00:40 +00:00
|
|
|
proc icon*(icon: string; text=""; title=""; class=""; href=""): VNode =
|
|
|
|
var c = "icon-" & icon
|
|
|
|
if class.len > 0: c = c & " " & class
|
|
|
|
buildHtml(tdiv(class="icon-container")):
|
|
|
|
if href.len > 0:
|
|
|
|
a(class=c, title=title, href=href)
|
|
|
|
else:
|
|
|
|
span(class=c, title=title)
|
|
|
|
|
|
|
|
if text.len > 0:
|
|
|
|
text " " & text
|
|
|
|
|
2019-07-10 22:42:31 +00:00
|
|
|
proc linkUser*(profile: Profile, class=""): VNode =
|
|
|
|
let
|
|
|
|
isName = "username" notin class
|
|
|
|
href = "/" & profile.username
|
|
|
|
nameText = if isName: profile.fullname
|
|
|
|
else: "@" & profile.username
|
|
|
|
|
|
|
|
buildHtml(a(href=href, class=class, title=nameText)):
|
|
|
|
text nameText
|
|
|
|
if isName and profile.verified:
|
2019-08-15 02:00:40 +00:00
|
|
|
icon "ok", class="verified-icon", title="Verified account"
|
2019-07-10 22:42:31 +00:00
|
|
|
if isName and profile.protected:
|
2019-08-15 02:00:40 +00:00
|
|
|
text " "
|
|
|
|
icon "lock-circled", title="Protected account"
|
2019-07-10 22:42:31 +00:00
|
|
|
|
|
|
|
proc genImg*(url: string; class=""): VNode =
|
|
|
|
buildHtml():
|
2019-09-13 10:27:04 +00:00
|
|
|
img(src=getPicUrl(url), class=class, alt="Image")
|
2019-08-12 01:32:27 +00:00
|
|
|
|
|
|
|
proc linkText*(text: string; class=""): VNode =
|
|
|
|
let url = if "http" notin text: "http://" & text else: text
|
|
|
|
buildHtml():
|
|
|
|
a(href=url, class=class): text text
|
2019-09-05 20:40:36 +00:00
|
|
|
|
2019-09-05 20:53:23 +00:00
|
|
|
proc refererField*(path: string): VNode =
|
|
|
|
buildHtml():
|
|
|
|
verbatim "<input name=\"referer\" style=\"display: none\" value=\"$1\"/>" % path
|
|
|
|
|
2019-09-05 20:40:36 +00:00
|
|
|
proc iconReferer*(icon, action, path: string, title=""): VNode =
|
|
|
|
buildHtml(form(`method`="get", action=action, class="icon-button")):
|
2019-09-05 20:53:23 +00:00
|
|
|
refererField path
|
2019-09-05 20:40:36 +00:00
|
|
|
button(`type`="submit"):
|
|
|
|
icon icon, title=title
|
2019-09-05 20:53:23 +00:00
|
|
|
|
|
|
|
proc buttonReferer*(action, text, path: string; class=""; `method`="post"): VNode =
|
|
|
|
buildHtml(form(`method`=`method`, action=action, class=class)):
|
|
|
|
refererField path
|
|
|
|
button(`type`="submit"):
|
|
|
|
text text
|