Added redirect on no params request

This commit is contained in:
Felisp 2023-12-24 02:41:53 +01:00
parent 6df7eedc78
commit 5d98da52e5
4 changed files with 11 additions and 3 deletions

1
.gitignore vendored
View file

@ -10,3 +10,4 @@ pom.xml.asc
/.nrepl-port
.hgignore
.hg/
/src/rss_thread_watch/ffs.clj

View file

@ -14,6 +14,8 @@ Get notifications from your feed reader when your favourite /mlp/ thread is abou
** Getting custom URL
URL without any params (just ~/feed.xml~) won't work. You must specify at least one ~q~. See bellow.
*** Crafting URL by hand
Right now there is no automated way to generate your feed url but making one by hand is fairly simple.
@ -59,10 +61,10 @@ This is an experimental project. There are several limitations:
** Feature set
- Planned/finnished features [15%]
- Planned/finnished features [23%]
- [X] [DONE] Super basic features done (feed, query, repeat)
- [X] Have proper sorting - The most likely to die threads first
- [ ] No params request should redirect to url generator or (for now) documentation
- [X] No params request should redirect to url generator or (for now) documentation
- [ ] Config file instead of hardcoding config values
- [ ] Include time of latest data fetch
- [ ] Make threads have preview images taken from the actuall thread OP

View file

@ -62,4 +62,3 @@
;; (repl-main)
;; Single cache update for repl
;; (watcher/update-thread-cache! (:target CONFIG) (:starting-page CONFIG))
;; (watcher/update-thread-cache! "/home/michal/Zdrojaky/Clojure/rss-thread-watch/resources/catalog-pts9.json" (:starting-page CONFIG))

View file

@ -15,6 +15,7 @@
(ns rss-thread-watch.feed-generator
"Generates feeds for requests"
(:require [ring.middleware.params :as rp]
[ring.util.response :as response]
[clj-rss.core :as rss]
[clojure.string :as s]
[rss-thread-watch.watcher :as watcher])
@ -119,6 +120,11 @@
(throw (ex-info "404" {:status 404
:header {"Content-Type" "text/plain"}
:body "404 This server has nothing but /feed.xml"})))
;; No url params -> we redirect to documentation about params
(when (empty? prms)
(throw (ex-info "302"
(response/redirect "https://git.treebrary.org/Treebrary.org/rss-thread-watcher#headline-4"))))
;; No querry specified - don't know what to search for
(when-not (prms "q")
(throw (ex-info "400" {:status 400