Fix wrong URL for dying threads and refactor cache format
This commit is contained in:
parent
9c7bae3712
commit
8224eab460
3 changed files with 9 additions and 7 deletions
|
@ -83,7 +83,7 @@
|
||||||
'(:boards-enabled)
|
'(:boards-enabled)
|
||||||
(fn [mp]
|
(fn [mp]
|
||||||
(u/fmap (fn [k v]
|
(u/fmap (fn [k v]
|
||||||
(assoc :name (u/map-apply-defaults v defaults)))
|
(assoc (u/map-apply-defaults v defaults) :name k))
|
||||||
mp)))
|
mp)))
|
||||||
:boards-defaults)))
|
:boards-defaults)))
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,8 @@
|
||||||
|
|
||||||
(defn thread-to-rss-item
|
(defn thread-to-rss-item
|
||||||
"Converts cached thread item to feed item which can be serialized into RSS"
|
"Converts cached thread item to feed item which can be serialized into RSS"
|
||||||
[t host board] ;;NOW2 ;TODO: oh Luna the hardcodes ;;RESUME
|
[t host board]
|
||||||
(let [link-url (str "https://boards.4chan.org/mlp/thread/" (:no t))] ; jesus, well I said only /mlp/ is supported now so fuck it
|
(let [link-url (str host board (:no t))]
|
||||||
{:title (format "%.2f%% - %s" (:chod t) (:title t)) ;TODO: Generate link from the target somehow, or just include it from API response
|
{:title (format "%.2f%% - %s" (:chod t) (:title t)) ;TODO: Generate link from the target somehow, or just include it from API response
|
||||||
;; :url link-url <- this is supposed to be for images according to: https://cyber.harvard.edu/rss/rss.html
|
;; :url link-url <- this is supposed to be for images according to: https://cyber.harvard.edu/rss/rss.html
|
||||||
:description (format "The thread: '%s' has %.2f%% chance of dying" (:title t) (:chod t))
|
:description (format "The thread: '%s' has %.2f%% chance of dying" (:title t) (:chod t))
|
||||||
|
@ -101,7 +101,10 @@
|
||||||
: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"}
|
||||||
body (map thread-to-rss-item items)]
|
body (map #(thread-to-rss-item
|
||||||
|
%1
|
||||||
|
(get board-config :target)
|
||||||
|
(get board-config :name)) items)]
|
||||||
(rss/channel-xml head body)))
|
(rss/channel-xml head body)))
|
||||||
|
|
||||||
(defn http-handler
|
(defn http-handler
|
||||||
|
@ -129,7 +132,7 @@
|
||||||
60 (Integer/parseInt chod))
|
60 (Integer/parseInt chod))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
94)))
|
94)))
|
||||||
board-config (get )
|
board-config (get-in @watcher/GLOBAL-CONFIG [:boards-enabled board])
|
||||||
cache @watcher/chod-threads-cache]
|
cache @watcher/chod-threads-cache]
|
||||||
(println "\n\nRCVD: " rqst)
|
(println "\n\nRCVD: " rqst)
|
||||||
;; (println rqst)
|
;; (println rqst)
|
||||||
|
@ -166,7 +169,7 @@
|
||||||
;; There shouldn't be any problems with this mime type but if there are
|
;; There shouldn't be any problems with this mime type but if there are
|
||||||
;; replace with "text/xml", or even better, get RSS reader that is not utter shit
|
;; replace with "text/xml", or even better, get RSS reader that is not utter shit
|
||||||
:header {"Content-Type" "application/rss+xml"}
|
:header {"Content-Type" "application/rss+xml"}
|
||||||
:body (generate-feed queries real-chod repeat? (watcher/get-thread-data board @watcher/GLOBAL-CONFIG))}) ;NOW3 give board specific config here
|
:body (generate-feed queries real-chod repeat? (watcher/get-thread-data board @watcher/GLOBAL-CONFIG) board-config)})
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
;; Ex-info has been crafted to match HTTP response body so we can send it
|
;; Ex-info has been crafted to match HTTP response body so we can send it
|
||||||
(if-let [caught (ex-data e)]
|
(if-let [caught (ex-data e)]
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
(recur (rest remaining-threads)
|
(recur (rest remaining-threads)
|
||||||
threads-total
|
threads-total
|
||||||
(inc index)
|
(inc index)
|
||||||
;; NOW: Cache fomrat here
|
|
||||||
;; We have to somehow include URL which is a problem since the catalog does not contain any
|
;; We have to somehow include URL which is a problem since the catalog does not contain any
|
||||||
;; I of course know how to craft it but the result will be kind of 4chan specific
|
;; I of course know how to craft it but the result will be kind of 4chan specific
|
||||||
(conj! ret {:title (or (:sub thread) ;We use thread title if thread has it
|
(conj! ret {:title (or (:sub thread) ;We use thread title if thread has it
|
||||||
|
|
Loading…
Reference in a new issue