Make self link Compliant, add config option to specify homepage for feed
This commit is contained in:
parent
1b8600c742
commit
389a3fa9ef
4 changed files with 18 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
(defproject rss-thread-watch "0.4.7-SNAPSHOT"
|
(defproject rss-thread-watch "0.4.8-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"
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
;; :enable-board-listing true ;Whether to show list of enabled boards in /boards UNIMPLEMENTED
|
;; :enable-board-listing true ;Whether to show list of enabled boards in /boards UNIMPLEMENTED
|
||||||
;; The watcher feed will be served by this url, everything else will be 404
|
;; The watcher feed will be served by this url, everything else will be 404
|
||||||
:served-filename "/feed"
|
:served-filename "/feed"
|
||||||
|
;; This is homepage for your feed, it should probably redirect somewhere where you mention
|
||||||
|
;; What things you have enabled and where to find full docs
|
||||||
|
:homepage "https://git.treebrary.org/Treebrary.org/rss-thread-watcher"
|
||||||
;; This map defines default values for all enabled boards, if you wish for some board
|
;; This map defines default values for all enabled boards, if you wish for some board
|
||||||
;; to use different values, specify them bellow in :borads-enabled
|
;; to use different values, specify them bellow in :borads-enabled
|
||||||
:boards-defaults {
|
:boards-defaults {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
;; Verification TODO: check if all required keys are included so we don't get nils
|
;; Verification TODO: check if all required keys are included so we don't get nils
|
||||||
|
|
||||||
(def VERSION "0.4.7")
|
(def VERSION "0.4.8")
|
||||||
|
|
||||||
(def GLOBAL-CONFIG
|
(def GLOBAL-CONFIG
|
||||||
"Global config with defaults for missing entires"
|
"Global config with defaults for missing entires"
|
||||||
|
@ -37,6 +37,7 @@
|
||||||
:default-board "/mlp/"
|
:default-board "/mlp/"
|
||||||
:enable-board-listing true
|
:enable-board-listing true
|
||||||
:served-filename "/feed"
|
:served-filename "/feed"
|
||||||
|
:homepage "https://git.treebrary.org/Treebrary.org/rss-thread-watcher"
|
||||||
:board-disabled-message "This board is not enabled for feed generation.\n\nYou can contact me here: [contact] and I may enable it for you"
|
:board-disabled-message "This board is not enabled for feed generation.\n\nYou can contact me here: [contact] and I may enable it for you"
|
||||||
:boards-defaults {:refresh-rate 300
|
:boards-defaults {:refresh-rate 300
|
||||||
:starting-page 7
|
:starting-page 7
|
||||||
|
|
|
@ -97,13 +97,14 @@
|
||||||
|
|
||||||
(defn generate-feed
|
(defn generate-feed
|
||||||
"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 self-link]
|
||||||
(let [items (filter-chod-posts query-vec chod-treshold repeat? cache)
|
(let [items (filter-chod-posts query-vec chod-treshold repeat? cache)
|
||||||
served-filename (get @conf/GLOBAL-CONFIG :served-filename)
|
served-filename (get @conf/GLOBAL-CONFIG :served-filename)
|
||||||
head {:title (str "RSS Thread watcher v" conf/VERSION)
|
head {:title (str "RSS Thread watcher v" conf/VERSION)
|
||||||
;; TODO: hardcoded homepage
|
;; :link is the homepage of the channel
|
||||||
:link (str "https://tools.treebrary.org/thread-watcher/" served-filename)
|
:link (get @conf/GLOBAL-CONFIG :homepage)
|
||||||
:feed-url (str "https://tools.treebrary.org/thread-watcher/" served-filename)
|
;; :feed-url is where you can get new items, must much the url this is served at
|
||||||
|
:feed-url self-link
|
||||||
:description "RSS based thread watcher"}
|
:description "RSS based thread watcher"}
|
||||||
body (map #(thread-to-rss-item
|
body (map #(thread-to-rss-item
|
||||||
%1
|
%1
|
||||||
|
@ -125,8 +126,13 @@
|
||||||
board (get @conf/GLOBAL-CONFIG :default-board)
|
board (get @conf/GLOBAL-CONFIG :default-board)
|
||||||
repeat? false}
|
repeat? false}
|
||||||
:as prms} :params
|
:as prms} :params
|
||||||
uri :uri} rqst
|
uri :uri
|
||||||
|
query :query-string
|
||||||
|
scheme :scheme
|
||||||
|
server-name :server-name} rqst
|
||||||
qrs (prms "q")
|
qrs (prms "q")
|
||||||
|
self-uri (str (s/replace-first scheme ":" "")
|
||||||
|
"://" server-name uri "?" query)
|
||||||
queries (if (vector? qrs) qrs [qrs]) ; to always return vector
|
queries (if (vector? qrs) qrs [qrs]) ; to always return vector
|
||||||
real-chod (if-let [ch (or (and (vector? chod)
|
real-chod (if-let [ch (or (and (vector? chod)
|
||||||
(first chod))
|
(first chod))
|
||||||
|
@ -175,7 +181,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 @conf/GLOBAL-CONFIG) board-config)})
|
:body (generate-feed queries real-chod repeat? (watcher/get-thread-data board @conf/GLOBAL-CONFIG) board-config self-uri)})
|
||||||
(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)]
|
||||||
|
|
Loading…
Reference in a new issue