Compare commits
No commits in common. "4c5ad1e9235b262b275a36e17cd0f79fe750906e" and "6c825bcaaaf848d228ebf0cafbe1d9d5017ed267" have entirely different histories.
4c5ad1e923
...
6c825bcaaa
4 changed files with 20 additions and 33 deletions
|
@ -1,4 +1,4 @@
|
||||||
(defproject rss-thread-watch "0.4.4-SNAPSHOT"
|
(defproject rss-thread-watch "0.4.3-SNAPSHOT"
|
||||||
:description "RSS based thread watcher"
|
:description "RSS based thread watcher"
|
||||||
:url "http://example.com/FIXME"
|
:url "http://example.com/FIXME"
|
||||||
:license {:name "AGPL-3.0-only"
|
:license {:name "AGPL-3.0-only"
|
||||||
|
|
|
@ -14,12 +14,14 @@
|
||||||
:starting-page 7
|
:starting-page 7
|
||||||
;; Default ChOD to use if none is specified by the user
|
;; Default ChOD to use if none is specified by the user
|
||||||
:default-chod 94
|
:default-chod 94
|
||||||
;; This is target for Catalog API requests
|
;; If you want to do some preprocessing beforehand, you can override
|
||||||
;; {board} will be substitued for board
|
;; target URL for the board, but the response must be same the 4chan API would return
|
||||||
:target "https://api.4chan.org/{board}/catalog.json"
|
;; /$board/catalog.json will be appended to this link
|
||||||
;; This is where threads actually reside if different from :target
|
;; This is target for API requests
|
||||||
;; you can use {board} and {threadnum} for substitutions
|
:target "https://api.4chan.org"
|
||||||
:host "https://boards.4chan.org/{board}/thread/{threadnum}"
|
;; This host that has the actual threads, /board/thread-no will be appeneded
|
||||||
|
;; to this
|
||||||
|
:host "https://boards.4chan.org"
|
||||||
;; Commented parts bellow are still unimplemented
|
;; Commented parts bellow are still unimplemented
|
||||||
;; ------
|
;; ------
|
||||||
;; Only download catalog when someone requests feed and cache is old
|
;; Only download catalog when someone requests feed and cache is old
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
(ns rss-thread-watch.core
|
(ns rss-thread-watch.core
|
||||||
(:require [clojure.java.io :as io]
|
(:require [clojure.java.io :as io]
|
||||||
[clojure.edn :as edn]
|
[clojure.edn :as edn]
|
||||||
[clojure.string :as s]
|
|
||||||
[clojure.tools.cli :refer [parse-opts]]
|
[clojure.tools.cli :refer [parse-opts]]
|
||||||
[ring.adapter.jetty :as jetty]
|
[ring.adapter.jetty :as jetty]
|
||||||
[ring.middleware.params :as rp]
|
[ring.middleware.params :as rp]
|
||||||
|
@ -24,7 +23,7 @@
|
||||||
[rss-thread-watch.utils :as u])
|
[rss-thread-watch.utils :as u])
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
(def VERSION "0.4.4")
|
(def VERSION "0.4.3")
|
||||||
|
|
||||||
;; Internal default config
|
;; Internal default config
|
||||||
(def CONFIG-DEFAULT
|
(def CONFIG-DEFAULT
|
||||||
|
@ -36,8 +35,8 @@
|
||||||
:boards-defaults {:refresh-rate 300
|
:boards-defaults {:refresh-rate 300
|
||||||
:starting-page 7
|
:starting-page 7
|
||||||
:default-chod 94
|
:default-chod 94
|
||||||
:target "https://api.4chan.org/{board}/catalog.json"
|
:target "https://api.4chan.org"
|
||||||
:host "https://boards.4chan.org/{board}/thread/{threadnum}"
|
:host "https://boards.4chan.org"
|
||||||
:lazy-load true}
|
:lazy-load true}
|
||||||
:boards-enabled {"/mlp/" {:lazy-load false}
|
:boards-enabled {"/mlp/" {:lazy-load false}
|
||||||
"/g/" {:starting-page 7}
|
"/g/" {:starting-page 7}
|
||||||
|
@ -77,31 +76,17 @@
|
||||||
(with-open [r (io/reader fl)]
|
(with-open [r (io/reader fl)]
|
||||||
(edn/read (java.io.PushbackReader. r))))))
|
(edn/read (java.io.PushbackReader. r))))))
|
||||||
|
|
||||||
(defn config-url-expand
|
|
||||||
"Expands substitution in :target and :host fields"
|
|
||||||
[filled-config]
|
|
||||||
(let [boards (get filled-config :boards-enabled)
|
|
||||||
selecting '(:target :host)
|
|
||||||
pattern "{board}"]
|
|
||||||
(u/fmap (fn [board confs]
|
|
||||||
(->> (select-keys confs selecting)
|
|
||||||
(u/fmap (fn [k v]
|
|
||||||
(s/replace v pattern (s/replace board "/" ""))))
|
|
||||||
(merge confs)))
|
|
||||||
boards)))
|
|
||||||
|
|
||||||
(defn config-fill-board-defaults
|
(defn config-fill-board-defaults
|
||||||
"Fills every enabled board with default config values"
|
"Fills every enabled board with default config values"
|
||||||
[config]
|
[config]
|
||||||
(let [defaults (:boards-defaults config)]
|
(let [defaults (:boards-defaults config)]
|
||||||
(-> config
|
(dissoc (update-in config
|
||||||
(update-in '(:boards-enabled)
|
'(:boards-enabled)
|
||||||
(fn [mp]
|
(fn [mp]
|
||||||
(u/fmap (fn [k v]
|
(u/fmap (fn [k v]
|
||||||
(assoc (u/map-apply-defaults v defaults) :name k))
|
(assoc (u/map-apply-defaults v defaults) :name k))
|
||||||
mp)))
|
mp)))
|
||||||
(dissoc :boards-defaults)
|
:boards-defaults)))
|
||||||
(config-url-expand))))
|
|
||||||
|
|
||||||
(defn get-some-config
|
(defn get-some-config
|
||||||
"Attempts to get config somehow,
|
"Attempts to get config somehow,
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
"Generates feed from matching items"
|
"Generates feed from matching items"
|
||||||
[query-vec chod-treshold repeat? cache board-config]
|
[query-vec chod-treshold repeat? cache board-config]
|
||||||
(let [items (filter-chod-posts query-vec chod-treshold repeat? cache)
|
(let [items (filter-chod-posts query-vec chod-treshold repeat? cache)
|
||||||
head {:title "RSS Thread watcher v0.4.4" ;TODO: hardcoded string here, remake to reference to config.clj
|
head {:title "RSS Thread watcher v0.4.3" ;TODO: hardcoded string here, remake to reference to config.clj
|
||||||
:link "https://tools.treebrary.org/thread-watcher/feed.xml"
|
:link "https://tools.treebrary.org/thread-watcher/feed.xml"
|
||||||
:feed-url "https://tools.treebrary.org/thread-watcher/feed.xml"
|
:feed-url "https://tools.treebrary.org/thread-watcher/feed.xml"
|
||||||
:description "RSS based thread watcher"}
|
:description "RSS based thread watcher"}
|
||||||
|
|
Loading…
Reference in a new issue