Compare string length instead of empty string
This commit is contained in:
parent
abe21e3ebf
commit
89b6cfdf98
3 changed files with 6 additions and 6 deletions
|
@ -74,7 +74,7 @@ proc getTimeline*(username: string; after=""): Future[Tweets] {.async.} =
|
||||||
})
|
})
|
||||||
|
|
||||||
var url = timelineUrl % username
|
var url = timelineUrl % username
|
||||||
if after != "":
|
if after.len > 0:
|
||||||
url &= "&max_position=" & after
|
url &= "&max_position=" & after
|
||||||
|
|
||||||
let html = await client.fetchHtml(base / url, jsonKey="items_html")
|
let html = await client.fetchHtml(base / url, jsonKey="items_html")
|
||||||
|
|
|
@ -81,7 +81,7 @@ proc linkUser*(profile: Profile; h: string; username=true; class=""): string =
|
||||||
if username: "@" & profile.username
|
if username: "@" & profile.username
|
||||||
else: formatName(profile)
|
else: formatName(profile)
|
||||||
|
|
||||||
if h == "":
|
if h.len == 0:
|
||||||
return htmlgen.a(text, href = &"/{profile.username}", class=class)
|
return htmlgen.a(text, href = &"/{profile.username}", class=class)
|
||||||
|
|
||||||
let element = &"<{h} class=\"{class}\">{text}</{h}>"
|
let element = &"<{h} class=\"{class}\">{text}</{h}>"
|
||||||
|
|
|
@ -11,10 +11,10 @@ proc showTimeline(name: string; num=""): Future[string] {.async.} =
|
||||||
tweetsFut = getTimeline(username, after=num)
|
tweetsFut = getTimeline(username, after=num)
|
||||||
|
|
||||||
let profile = await profileFut
|
let profile = await profileFut
|
||||||
if profile.username == "":
|
if profile.username.len == 0:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
return renderMain(renderProfile(profile, await tweetsFut, num == ""))
|
return renderMain(renderProfile(profile, await tweetsFut, num.len == 0))
|
||||||
|
|
||||||
routes:
|
routes:
|
||||||
get "/":
|
get "/":
|
||||||
|
@ -29,7 +29,7 @@ routes:
|
||||||
get "/@name/?":
|
get "/@name/?":
|
||||||
cond '.' notin @"name"
|
cond '.' notin @"name"
|
||||||
let timeline = await showTimeline(@"name", @"after")
|
let timeline = await showTimeline(@"name", @"after")
|
||||||
if timeline == "":
|
if timeline.len == 0:
|
||||||
resp Http404, showError("User \"" & @"name" & "\" not found")
|
resp Http404, showError("User \"" & @"name" & "\" not found")
|
||||||
|
|
||||||
resp timeline
|
resp timeline
|
||||||
|
@ -37,7 +37,7 @@ routes:
|
||||||
get "/@name/status/@id":
|
get "/@name/status/@id":
|
||||||
cond '.' notin @"name"
|
cond '.' notin @"name"
|
||||||
let conversation = await getTweet(@"id")
|
let conversation = await getTweet(@"id")
|
||||||
if conversation.tweet.id == "":
|
if conversation.tweet.id.len == 0:
|
||||||
resp Http404, showError("Tweet not found")
|
resp Http404, showError("Tweet not found")
|
||||||
|
|
||||||
resp renderMain(renderConversation(conversation))
|
resp renderMain(renderConversation(conversation))
|
||||||
|
|
Loading…
Reference in a new issue