From 5d98da52e536adfaa0fe6e769c6c138714809638 Mon Sep 17 00:00:00 2001 From: Felisp Date: Sun, 24 Dec 2023 02:41:53 +0100 Subject: [PATCH] Added redirect on no params request --- .gitignore | 1 + README.org | 6 ++++-- src/rss_thread_watch/core.clj | 1 - src/rss_thread_watch/feed_generator.clj | 6 ++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d18f225..5401556 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ pom.xml.asc /.nrepl-port .hgignore .hg/ +/src/rss_thread_watch/ffs.clj diff --git a/README.org b/README.org index 46aa052..09f37da 100644 --- a/README.org +++ b/README.org @@ -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 diff --git a/src/rss_thread_watch/core.clj b/src/rss_thread_watch/core.clj index d80656b..a19555f 100644 --- a/src/rss_thread_watch/core.clj +++ b/src/rss_thread_watch/core.clj @@ -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)) diff --git a/src/rss_thread_watch/feed_generator.clj b/src/rss_thread_watch/feed_generator.clj index 39f9d62..6cdfe11 100644 --- a/src/rss_thread_watch/feed_generator.clj +++ b/src/rss_thread_watch/feed_generator.clj @@ -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