2014-12-05 15:56:40 +00:00
|
|
|
(ns cryogen-core.rss
|
2014-12-04 16:38:48 +00:00
|
|
|
(:require [clj-rss.core :as rss]
|
2015-01-04 01:36:30 +00:00
|
|
|
[clojure.xml :refer [emit]]
|
|
|
|
[text-decoration.core :refer :all])
|
2014-12-04 16:38:48 +00:00
|
|
|
(:import java.util.Date))
|
|
|
|
|
|
|
|
|
|
|
|
(defn posts-to-items [site-url author posts]
|
|
|
|
(map
|
|
|
|
(fn [{:keys [uri title content date]}]
|
|
|
|
(let [link (str (if (.endsWith site-url "/") (apply str (butlast site-url)) site-url) uri)]
|
|
|
|
{:guid link
|
|
|
|
:link link
|
|
|
|
:title title
|
|
|
|
:description content
|
|
|
|
:pubDate date
|
|
|
|
:author author}))
|
|
|
|
posts))
|
|
|
|
|
|
|
|
(defn make-channel [config posts]
|
|
|
|
(apply
|
|
|
|
(partial rss/channel-xml
|
|
|
|
false
|
|
|
|
{:title (:site-title config)
|
|
|
|
:link (:site-url config)
|
|
|
|
:description (:description config)
|
|
|
|
:lastBuildDate (Date.)
|
|
|
|
:author (:author config)})
|
2015-01-04 01:36:30 +00:00
|
|
|
(posts-to-items (:site-url config) (:author config) posts)))
|
|
|
|
|
|
|
|
(defn make-filtered-channels [public {:keys [rss-filters blog-prefix] :as config} posts-by-tag]
|
|
|
|
(doseq [filter rss-filters]
|
|
|
|
(let [uri (str public blog-prefix "/" (name filter) ".xml")]
|
|
|
|
(println "\t-->" (cyan uri))
|
|
|
|
(spit uri (make-channel config (get posts-by-tag filter))))))
|