Fix 404 page
This commit is contained in:
parent
4104bfcba9
commit
a78eea9dce
7 changed files with 8 additions and 8 deletions
|
@ -40,11 +40,11 @@ routes:
|
||||||
|
|
||||||
get "/i/redirect":
|
get "/i/redirect":
|
||||||
let url = decodeUrl(@"url")
|
let url = decodeUrl(@"url")
|
||||||
if url.len == 0: halt Http404
|
if url.len == 0: resp Http404
|
||||||
redirect(replaceUrl(url, cookiePrefs()))
|
redirect(replaceUrl(url, cookiePrefs()))
|
||||||
|
|
||||||
error Http404:
|
error Http404:
|
||||||
resp showError("Page not found", cfg)
|
resp Http404, showError("Page not found", cfg)
|
||||||
|
|
||||||
extend unsupported, ""
|
extend unsupported, ""
|
||||||
extend preferences, ""
|
extend preferences, ""
|
||||||
|
|
|
@ -8,7 +8,7 @@ import ../views/[general, timeline, list]
|
||||||
|
|
||||||
template respList*(list, timeline: typed) =
|
template respList*(list, timeline: typed) =
|
||||||
if list.minId.len == 0:
|
if list.minId.len == 0:
|
||||||
halt Http404, showError("List \"" & @"list" & "\" not found", cfg)
|
resp Http404, showError("List \"" & @"list" & "\" not found", cfg)
|
||||||
let html = renderList(timeline, list.query, @"name", @"list")
|
let html = renderList(timeline, list.query, @"name", @"list")
|
||||||
let rss = "/$1/lists/$2/rss" % [@"name", @"list"]
|
let rss = "/$1/lists/$2/rss" % [@"name", @"list"]
|
||||||
resp renderMain(html, request, cfg, rss=rss)
|
resp renderMain(html, request, cfg, rss=rss)
|
||||||
|
|
|
@ -51,7 +51,7 @@ proc createMediaRouter*(cfg: Config) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
if content.len == 0:
|
if content.len == 0:
|
||||||
halt Http404
|
resp Http404
|
||||||
|
|
||||||
resp content, settings.mimes.getMimetype(url.split(".")[^1])
|
resp content, settings.mimes.getMimetype(url.split(".")[^1])
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ proc showRss*(name, hostname: string; query: Query): Future[string] {.async.} =
|
||||||
|
|
||||||
template respRss*(rss: typed) =
|
template respRss*(rss: typed) =
|
||||||
if rss.len == 0:
|
if rss.len == 0:
|
||||||
halt Http404, showError("User \"" & @"name" & "\" not found", cfg)
|
resp Http404, showError("User \"" & @"name" & "\" not found", cfg)
|
||||||
resp rss, "application/rss+xml;charset=utf-8"
|
resp rss, "application/rss+xml;charset=utf-8"
|
||||||
|
|
||||||
proc createRssRouter*(cfg: Config) =
|
proc createRssRouter*(cfg: Config) =
|
||||||
|
|
|
@ -29,7 +29,7 @@ proc createSearchRouter*(cfg: Config) =
|
||||||
resp renderMain(renderTweetSearch(tweets, prefs, getPath()),
|
resp renderMain(renderTweetSearch(tweets, prefs, getPath()),
|
||||||
request, cfg, rss=rss)
|
request, cfg, rss=rss)
|
||||||
else:
|
else:
|
||||||
halt Http404, showError("Invalid search", cfg)
|
resp Http404, showError("Invalid search", cfg)
|
||||||
|
|
||||||
get "/hashtag/@hash":
|
get "/hashtag/@hash":
|
||||||
redirect("/search?q=" & encodeUrl("#" & @"hash"))
|
redirect("/search?q=" & encodeUrl("#" & @"hash"))
|
||||||
|
|
|
@ -22,7 +22,7 @@ proc createStatusRouter*(cfg: Config) =
|
||||||
var error = "Tweet not found"
|
var error = "Tweet not found"
|
||||||
if conversation != nil and conversation.tweet.tombstone.len > 0:
|
if conversation != nil and conversation.tweet.tombstone.len > 0:
|
||||||
error = conversation.tweet.tombstone
|
error = conversation.tweet.tombstone
|
||||||
halt Http404, showError(error, cfg)
|
resp Http404, showError(error, cfg)
|
||||||
|
|
||||||
let
|
let
|
||||||
title = pageTitle(conversation.tweet.profile)
|
title = pageTitle(conversation.tweet.profile)
|
||||||
|
|
|
@ -72,7 +72,7 @@ proc showTimeline*(request: Request; query: Query; cfg: Config; rss: string): Fu
|
||||||
|
|
||||||
template respTimeline*(timeline: typed) =
|
template respTimeline*(timeline: typed) =
|
||||||
if timeline.len == 0:
|
if timeline.len == 0:
|
||||||
halt Http404, showError("User \"" & @"name" & "\" not found", cfg)
|
resp Http404, showError("User \"" & @"name" & "\" not found", cfg)
|
||||||
resp timeline
|
resp timeline
|
||||||
|
|
||||||
proc createTimelineRouter*(cfg: Config) =
|
proc createTimelineRouter*(cfg: Config) =
|
||||||
|
|
Loading…
Reference in a new issue