Use Karax html rendering instead of source filters (#2)

* Use Karax html rendering instead of source filters
This commit is contained in:
Zed
2019-07-11 00:42:31 +02:00
committed by GitHub
parent fad2575d93
commit ab36664ad2
21 changed files with 482 additions and 507 deletions

21
src/views/renderutils.nim Normal file
View File

@@ -0,0 +1,21 @@
import karax/[karaxdsl, vdom, vstyles]
import ../types, ../utils
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:
span(class="icon verified-icon", title="Verified account"): text ""
if isName and profile.protected:
span(class="icon protected-icon", title="Protected account"): text "🔒"
proc genImg*(url: string; class=""): VNode =
buildHtml():
img(src=url.getSigUrl("pic"), class=class, alt="Image")