Browse Source

css styling

master
Wesley Kerfoot 4 years ago
parent
commit
ae591e9122
  1. 38
      src/twit2blogpkg/templates.nim
  2. 2
      src/twit2blogpkg/twitter.nim

38
src/twit2blogpkg/templates.nim

@ -1,24 +1,34 @@
import strformat import strformat
import karax / [karaxdsl, vdom] import karax / [karaxdsl, vdom]
proc layout(inner : VNode) : string =
let vnode = buildHtml(html):
head:
meta(charset="utf-8")
link(href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css", rel="stylesheet")
body:
tdiv(class="text-center appearance-none"):
inner
"<!DOCTYPE html>\n" & $vnode
proc tweetThread*(author : string, proc tweetThread*(author : string,
tweets : seq[string]): string = tweets : seq[string]): string =
let title = fmt"Thread by {author}" let title = fmt"Thread by {author}"
let vnode = buildHtml(tdiv): let vnode = buildHtml(tdiv(class="")):
h4: text title h4: text title
ul: ul:
li: a(href="/"): text "Main Page" li: a(href="/"): text "Main Page"
li: a(href=fmt"/author/{author}/threads"): text (fmt"See all of {author}'s threads") li: a(href=fmt"/author/{author}/threads"): text (fmt"See all of {author}'s threads")
ul: ul(class="m-auto max-w-md list-decimal text-left"):
for tweet in tweets: for tweet in tweets:
li: text tweet li: text tweet
result = $vnode result = $vnode.layout
proc checkBack*() : string = proc checkBack*() : string =
let vnode = buildHtml(tdiv): let vnode = buildHtml(tdiv):
h4: text "Check back later please" h4: text "Check back later please"
result = $vnode result = $vnode.layout
proc listThreads*(author : string, proc listThreads*(author : string,
threads : seq[string]) : string = threads : seq[string]) : string =
@ -28,31 +38,33 @@ proc listThreads*(author : string,
h4: text title h4: text title
ul: ul:
for thread in threads: for thread in threads:
li: a(href = fmt"/thread/{author}/status/{thread}"): text thread li: a(href=fmt"/thread/{author}/status/{thread}"): text thread
result = $vnode result = $vnode.layout
# Main page # Main page
proc listAuthors*(authors : seq[string]) : VNode = proc listAuthors*(authors : seq[string]) : VNode =
let title = "Authors" let title = "Authors"
let vnode = buildHtml(tdiv): let vnode = buildHtml(tdiv):
h4: text title h1(class="uppercase text-center"): text title
ul: ul(class="text-center"):
for author in authors: for author in authors:
li: a(href = fmt"/author/{author}/threads"): text author li:
a(href = fmt"/author/{author}/threads"):
text author
result = vnode result = vnode
proc submitThread() : VNode = proc submitThread() : VNode =
let vnode = buildHtml(tdiv): let vnode = buildHtml(tdiv):
form(action = "/thread", `method`="POST", class="submit-thread"): form(action = "/thread", `method`="POST", class="appearance-none"):
tdiv: tdiv(class="text-center"):
label(`for`="tweetUrl"): label(`for`="tweetUrl"):
text "Tweet URL" text "Tweet URL"
input(`type`="text", name="tweetURL", id="tweeturl", required="true") input(class="bg-teal-100", `type`="text", name="tweetURL", id="tweeturl", required="true")
result = vnode result = vnode
proc mainPage*(authors : seq[string]) : string = proc mainPage*(authors : seq[string]) : string =
let vnode = buildHtml(tdiv): let vnode = buildHtml(tdiv):
listAuthors(authors) listAuthors(authors)
submitThread() submitThread()
result = $vnode result = $vnode.layout

2
src/twit2blogpkg/twitter.nim

@ -79,7 +79,7 @@ proc convertWords(tweet : string) : string =
let url = xmltree.escape(fmt"{scheme}://{hostname}{path}") let url = xmltree.escape(fmt"{scheme}://{hostname}{path}")
stripped &= url stripped &= url
elif word.len > 0 and word[0] != '@': elif word.len > 0 and word[0] != '@':
stripped &= xmltree.escape(word) stripped &= word
else: else:
continue continue
stripped.join(" ") stripped.join(" ")

Loading…
Cancel
Save