Add list support
This commit is contained in:
@@ -71,5 +71,5 @@ proc renderError*(error: string): VNode =
|
||||
tdiv(class="error-panel"):
|
||||
span: text error
|
||||
|
||||
proc showError*(error, title: string): string =
|
||||
renderMain(renderError(error), Request(), title, "Error")
|
||||
template showError*(error, title: string): string =
|
||||
renderMain(renderError(error), request, title, "Error")
|
||||
|
||||
20
src/views/list.nim
Normal file
20
src/views/list.nim
Normal file
@@ -0,0 +1,20 @@
|
||||
import strformat
|
||||
import karax/[karaxdsl, vdom]
|
||||
|
||||
import renderutils
|
||||
import ".."/[types]
|
||||
|
||||
proc renderListTabs*(query: Query; path: string): VNode =
|
||||
buildHtml(ul(class="tab")):
|
||||
li(class=query.getTabClass(posts)):
|
||||
a(href=(path)): text "Tweets"
|
||||
li(class=query.getTabClass(users)):
|
||||
a(href=(path & "/members")): text "Members"
|
||||
|
||||
proc renderList*(body: VNode; query: Query; name, list: string): VNode =
|
||||
buildHtml(tdiv(class="timeline-container")):
|
||||
tdiv(class="timeline-header"):
|
||||
text &"\"{list}\" by @{name}"
|
||||
|
||||
renderListTabs(query, &"/{name}/lists/{list}")
|
||||
body
|
||||
@@ -30,10 +30,6 @@ proc linkUser*(profile: Profile, class=""): VNode =
|
||||
text " "
|
||||
icon "lock-circled", title="Protected account"
|
||||
|
||||
proc genImg*(url: string; class=""): VNode =
|
||||
buildHtml():
|
||||
img(src=getPicUrl(url), class=class, alt="Image")
|
||||
|
||||
proc linkText*(text: string; class=""): VNode =
|
||||
let url = if "http" notin text: "http://" & text else: text
|
||||
buildHtml():
|
||||
@@ -91,3 +87,12 @@ proc genDate*(pref, state: string): VNode =
|
||||
else:
|
||||
verbatim &"<input name={pref} type=\"date\"/>"
|
||||
icon "calendar"
|
||||
|
||||
proc genImg*(url: string; class=""): VNode =
|
||||
buildHtml():
|
||||
img(src=getPicUrl(url), class=class, alt="Image")
|
||||
|
||||
proc getTabClass*(query: Query; tab: QueryKind): string =
|
||||
result = "tab-item"
|
||||
if query.kind == tab:
|
||||
result &= " active"
|
||||
|
||||
@@ -71,3 +71,29 @@
|
||||
</channel>
|
||||
</rss>
|
||||
#end proc
|
||||
#
|
||||
#proc renderListRss*(tweets: seq[Tweet]; name, list: string): string =
|
||||
#let prefs = Prefs(replaceTwitter: hostname)
|
||||
#result = ""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
|
||||
<channel>
|
||||
<atom:link href="https://${hostname}/${name}/lists/${list}/rss" rel="self" type="application/rss+xml" />
|
||||
<title>${list} / @${name}</title>
|
||||
<link>https://${hostname}/${name}/lists/${list}</link>
|
||||
<description>Twitter feed for: ${list} by @${name}. Generated by ${hostname}</description>
|
||||
<language>en-us</language>
|
||||
<ttl>40</ttl>
|
||||
#for tweet in tweets:
|
||||
<item>
|
||||
<title>${getTitle(tweet, prefs)}</title>
|
||||
<dc:creator>@${tweet.profile.username}</dc:creator>
|
||||
<description><![CDATA[${renderRssTweet(tweet, prefs).strip(chars={'\n'})}]]></description>
|
||||
<pubDate>${getRfc822Time(tweet)}</pubDate>
|
||||
<guid>https://${hostname}${getLink(tweet)}</guid>
|
||||
<link>https://${hostname}${getLink(tweet)}</link>
|
||||
</item>
|
||||
#end for
|
||||
</channel>
|
||||
</rss>
|
||||
#end proc
|
||||
|
||||
@@ -23,15 +23,10 @@ proc renderSearch*(): VNode =
|
||||
buildHtml(tdiv(class="panel-container")):
|
||||
tdiv(class="search-bar"):
|
||||
form(`method`="get", action="/search"):
|
||||
hiddenField("kind", "users")
|
||||
hiddenField("kind", "userSearch")
|
||||
input(`type`="text", name="text", autofocus="", placeholder="Enter username...")
|
||||
button(`type`="submit"): icon "search"
|
||||
|
||||
proc getTabClass(query: Query; tab: QueryKind): string =
|
||||
result = "tab-item"
|
||||
if query.kind == tab:
|
||||
result &= " active"
|
||||
|
||||
proc renderProfileTabs*(query: Query; username: string): VNode =
|
||||
let link = "/" & username
|
||||
buildHtml(ul(class="tab")):
|
||||
@@ -50,8 +45,8 @@ proc renderSearchTabs*(query: Query): VNode =
|
||||
li(class=query.getTabClass(custom)):
|
||||
q.kind = custom
|
||||
a(href=("?" & genQueryUrl(q))): text "Tweets"
|
||||
li(class=query.getTabClass(users)):
|
||||
q.kind = users
|
||||
li(class=query.getTabClass(userSearch)):
|
||||
q.kind = userSearch
|
||||
a(href=("?" & genQueryUrl(q))): text "Users"
|
||||
|
||||
proc isPanelOpen(q: Query): bool =
|
||||
@@ -114,7 +109,7 @@ proc renderUserSearch*(users: Result[Profile]; prefs: Prefs): VNode =
|
||||
buildHtml(tdiv(class="timeline-container")):
|
||||
tdiv(class="timeline-header"):
|
||||
form(`method`="get", action="/search", class="search-field"):
|
||||
hiddenField("kind", "users")
|
||||
hiddenField("kind", "userSearch")
|
||||
genInput("text", "", users.query.text, "Enter username...", class="pref-inline")
|
||||
button(`type`="submit"): icon "search"
|
||||
|
||||
|
||||
@@ -64,7 +64,8 @@ proc renderTimelineUsers*(results: Result[Profile]; prefs: Prefs; path=""): VNod
|
||||
if results.content.len > 0:
|
||||
for user in results.content:
|
||||
renderUser(user, prefs)
|
||||
renderMore(results.query, results.minId)
|
||||
if results.minId != "0":
|
||||
renderMore(results.query, results.minId)
|
||||
elif results.beginning:
|
||||
renderNoneFound()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user