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