Router refactoring
This commit is contained in:
@@ -59,6 +59,7 @@ proc createRssRouter*(cfg: Config) =
|
||||
|
||||
get "/@name/@tab/rss":
|
||||
cond '.' notin @"name"
|
||||
cond @"tab" in ["with_replies", "media", "search"]
|
||||
let query =
|
||||
case @"tab"
|
||||
of "with_replies": getReplyQuery(@"name")
|
||||
|
||||
@@ -24,32 +24,25 @@ proc createStatusRouter*(cfg: Config) =
|
||||
error = conversation.tweet.tombstone
|
||||
resp Http404, showError(error, cfg)
|
||||
|
||||
let
|
||||
var
|
||||
title = pageTitle(conversation.tweet.profile)
|
||||
desc = conversation.tweet.text
|
||||
html = renderConversation(conversation, prefs, getPath() & "#m")
|
||||
images = conversation.tweet.photos
|
||||
video = ""
|
||||
|
||||
if conversation.tweet.video.isSome():
|
||||
let thumb = get(conversation.tweet.video).thumb
|
||||
let vidUrl = getVideoEmbed(cfg, conversation.tweet.id)
|
||||
resp renderMain(html, request, cfg, title, desc, images = @[thumb],
|
||||
`type`="video", video=vidUrl)
|
||||
images = @[get(conversation.tweet.video).thumb]
|
||||
video = getVideoEmbed(cfg, conversation.tweet.id)
|
||||
elif conversation.tweet.gif.isSome():
|
||||
let thumb = get(conversation.tweet.gif).thumb
|
||||
let vidUrl = getGifUrl(get(conversation.tweet.gif).url)
|
||||
resp renderMain(html, request, cfg, title, desc, images = @[thumb],
|
||||
`type`="video", video=vidUrl)
|
||||
else:
|
||||
resp renderMain(html, request, cfg, title, desc,
|
||||
images=conversation.tweet.photos, `type`="photo")
|
||||
images = @[get(conversation.tweet.gif).thumb]
|
||||
video = getGifUrl(get(conversation.tweet.gif).url)
|
||||
|
||||
get "/@name/status/@id/photo/@i":
|
||||
redirect("/$1/status/$2" % [@"name", @"id"])
|
||||
let html = renderConversation(conversation, prefs, getPath() & "#m")
|
||||
resp renderMain(html, request, cfg, title, desc, images=images, video=video)
|
||||
|
||||
get "/@name/status/@id/video/@i":
|
||||
redirect("/$1/status/$2" % [@"name", @"id"])
|
||||
|
||||
get "/@name/statuses/@id":
|
||||
get "/@name/@s/@id/@m/?@i?":
|
||||
cond @"s" in ["status", "statuses"]
|
||||
cond @"m" in ["video", "photo"]
|
||||
redirect("/$1/status/$2" % [@"name", @"id"])
|
||||
|
||||
get "/i/web/status/@id":
|
||||
|
||||
@@ -81,23 +81,15 @@ proc createTimelineRouter*(cfg: Config) =
|
||||
setProfileCacheTime(cfg.profileCacheTime)
|
||||
|
||||
router timeline:
|
||||
get "/@name/?":
|
||||
get "/@name/?@tab?":
|
||||
cond '.' notin @"name"
|
||||
let rss = "/$1/rss" % @"name"
|
||||
respTimeline(await showTimeline(request, Query(), cfg, rss))
|
||||
|
||||
get "/@name/with_replies":
|
||||
cond '.' notin @"name"
|
||||
let rss = "/$1/with_replies/rss" % @"name"
|
||||
respTimeline(await showTimeline(request, getReplyQuery(@"name"), cfg, rss))
|
||||
|
||||
get "/@name/media":
|
||||
cond '.' notin @"name"
|
||||
let rss = "/$1/media/rss" % @"name"
|
||||
respTimeline(await showTimeline(request, getMediaQuery(@"name"), cfg, rss))
|
||||
|
||||
get "/@name/search":
|
||||
cond '.' notin @"name"
|
||||
let query = initQuery(params(request), name=(@"name"))
|
||||
let rss = "/$1/search/rss?$2" % [@"name", genQueryUrl(query)]
|
||||
cond @"tab" in ["with_replies", "media", "search", ""]
|
||||
var rss = "/$1/$2/rss" % [@"name", @"tab"]
|
||||
let query =
|
||||
case @"tab"
|
||||
of "with_replies": getReplyQuery(@"name")
|
||||
of "media": getMediaQuery(@"name")
|
||||
of "search": initQuery(params(request), name=(@"name"))
|
||||
else: Query()
|
||||
if @"tab" == "search": rss &= "?" & genQueryUrl(query)
|
||||
respTimeline(await showTimeline(request, query, cfg, rss))
|
||||
|
||||
Reference in New Issue
Block a user