From a78eea9dce19e333b290ff1b41366a6ec7dfca27 Mon Sep 17 00:00:00 2001 From: Zed Date: Mon, 21 Oct 2019 07:59:22 +0200 Subject: [PATCH] Fix 404 page --- src/nitter.nim | 4 ++-- src/routes/list.nim | 2 +- src/routes/media.nim | 2 +- src/routes/rss.nim | 2 +- src/routes/search.nim | 2 +- src/routes/status.nim | 2 +- src/routes/timeline.nim | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/nitter.nim b/src/nitter.nim index 0f82ccb..9df8309 100644 --- a/src/nitter.nim +++ b/src/nitter.nim @@ -40,11 +40,11 @@ routes: get "/i/redirect": let url = decodeUrl(@"url") - if url.len == 0: halt Http404 + if url.len == 0: resp Http404 redirect(replaceUrl(url, cookiePrefs())) error Http404: - resp showError("Page not found", cfg) + resp Http404, showError("Page not found", cfg) extend unsupported, "" extend preferences, "" diff --git a/src/routes/list.nim b/src/routes/list.nim index 0a15755..855fe9b 100644 --- a/src/routes/list.nim +++ b/src/routes/list.nim @@ -8,7 +8,7 @@ import ../views/[general, timeline, list] template respList*(list, timeline: typed) = 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 rss = "/$1/lists/$2/rss" % [@"name", @"list"] resp renderMain(html, request, cfg, rss=rss) diff --git a/src/routes/media.nim b/src/routes/media.nim index 3adb245..49b80a3 100644 --- a/src/routes/media.nim +++ b/src/routes/media.nim @@ -51,7 +51,7 @@ proc createMediaRouter*(cfg: Config) = discard if content.len == 0: - halt Http404 + resp Http404 resp content, settings.mimes.getMimetype(url.split(".")[^1]) diff --git a/src/routes/rss.nim b/src/routes/rss.nim index 75fc433..cf5ab89 100644 --- a/src/routes/rss.nim +++ b/src/routes/rss.nim @@ -15,7 +15,7 @@ proc showRss*(name, hostname: string; query: Query): Future[string] {.async.} = template respRss*(rss: typed) = 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" proc createRssRouter*(cfg: Config) = diff --git a/src/routes/search.nim b/src/routes/search.nim index f349a0d..67a91ea 100644 --- a/src/routes/search.nim +++ b/src/routes/search.nim @@ -29,7 +29,7 @@ proc createSearchRouter*(cfg: Config) = resp renderMain(renderTweetSearch(tweets, prefs, getPath()), request, cfg, rss=rss) else: - halt Http404, showError("Invalid search", cfg) + resp Http404, showError("Invalid search", cfg) get "/hashtag/@hash": redirect("/search?q=" & encodeUrl("#" & @"hash")) diff --git a/src/routes/status.nim b/src/routes/status.nim index 4d942b8..305df38 100644 --- a/src/routes/status.nim +++ b/src/routes/status.nim @@ -22,7 +22,7 @@ proc createStatusRouter*(cfg: Config) = var error = "Tweet not found" if conversation != nil and conversation.tweet.tombstone.len > 0: error = conversation.tweet.tombstone - halt Http404, showError(error, cfg) + resp Http404, showError(error, cfg) let title = pageTitle(conversation.tweet.profile) diff --git a/src/routes/timeline.nim b/src/routes/timeline.nim index 16cdc32..08632f7 100644 --- a/src/routes/timeline.nim +++ b/src/routes/timeline.nim @@ -72,7 +72,7 @@ proc showTimeline*(request: Request; query: Query; cfg: Config; rss: string): Fu template respTimeline*(timeline: typed) = if timeline.len == 0: - halt Http404, showError("User \"" & @"name" & "\" not found", cfg) + resp Http404, showError("User \"" & @"name" & "\" not found", cfg) resp timeline proc createTimelineRouter*(cfg: Config) =