diff --git a/res/ExampleConfig.edn b/res/ExampleConfig.edn index f379940..f94c566 100644 --- a/res/ExampleConfig.edn +++ b/res/ExampleConfig.edn @@ -3,6 +3,7 @@ {:port 6969 :default-board "/mlp/" ;Board to be used when no board=x param given :board-disabled-message "This board is not enabled for feed generation.\n\nYou can contact me here: [contact]" + :enable-board-listing true ;Whether to show list of enabled boards in /boards ;; /$board/catalog.json will be appended to this link :target "https://api.4chan.org" :boards-defaults {:refresh-rate 300 diff --git a/src/rss_thread_watch/core.clj b/src/rss_thread_watch/core.clj index a19555f..1d42065 100644 --- a/src/rss_thread_watch/core.clj +++ b/src/rss_thread_watch/core.clj @@ -13,20 +13,26 @@ ;; along with this program. If not, see . (ns rss-thread-watch.core - (:require [ring.adapter.jetty :as jetty] + (:require [clojure.java.io :As io] + [ring.adapter.jetty :as jetty] [ring.middleware.params :as rp] [rss-thread-watch.watcher :as watcher] [rss-thread-watch.feed-generator :as feed]) (:gen-class)) ;; Internal default config -(def CONFIG +(def CONFIG-DEFAULT "Internal default config" - {:target "https://api.4chan.org/mlp/catalog.json" ;Where to download catalog from - :starting-page 7 ;only monitor threads from this from this page and up - :refresh-delay (* 60 5) ;Redownload catalog every 5 mins - :port 6969 ;Listen on 6969 - }) + {:port 6969 + :default-board "/mlp/" + :enable-board-listing true + :board-disabled-message "This board is not enabled for feed generation.\n\nYou can contact me here: [contact]" + :target "https://api.4chan.org" + :boards-defaults {:refresh-rate 300 + :starting-page 7 + :default-chod 94} + :boards-enabled {"/mlp/" {} + "/g/" {}}}) (defn set-interval "Calls function every ms" @@ -36,14 +42,14 @@ (println "Recached") (catch Exception e (binding [*out* *err*] - (println "Error while updating cache: " e ", retrying in 5 minutes")))) + (println "Error while updating cache: " e ", retrying in " (/ ms 1000 60) " minutes")))) (Thread/sleep ms))))) (defn -main "Entry point, starts webserver" [& args] - (println "Starting on port: " (:port CONFIG) - "\nGonna recache every: " (:refresh-delay CONFIG) "s") + ;; Parse and validate config + ;; Think of a way to start repeated download for every catalog efficiently (set-interval (fn [] (println "Starting cache update") (watcher/update-thread-cache! (:target CONFIG) (:starting-page CONFIG)))