From 656cc2d0c9fb1042fc4bd19cf51b7b441e5f4a10 Mon Sep 17 00:00:00 2001 From: lacarmen Date: Sat, 3 Jan 2015 20:36:30 -0500 Subject: [PATCH] Added curated RSS generation based on :rss-filters in the config --- project.clj | 2 +- src/cryogen_core/compiler.clj | 5 ++++- src/cryogen_core/rss.clj | 11 +++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/project.clj b/project.clj index 203f126..7dfa9bf 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject cryogen-core "0.1.11" +(defproject cryogen-core "0.1.12" :description "Cryogen's compiler" :url "https://github.com/lacarmen/cryogen-core" :license {:name "Eclipse Public License" diff --git a/src/cryogen_core/compiler.clj b/src/cryogen_core/compiler.clj index 6893fb2..b1bf47e 100644 --- a/src/cryogen_core/compiler.clj +++ b/src/cryogen_core/compiler.clj @@ -257,6 +257,7 @@ read-string (update-in [:blog-prefix] (fnil str "")) (update-in [:rss-name] (fnil str "rss.xml")) + (update-in [:rss-filters] (fnil seq [])) (update-in [:sass-src] (fnil str "css")) (update-in [:sass-dest] (fnil str "css")) (update-in [:post-date-format] (fnil str "yyyy-MM-dd")) @@ -299,8 +300,10 @@ (compile-archives default-params posts config) (println (blue "generating site map")) (spit (str public blog-prefix "/sitemap.xml") (sitemap/generate site-url ignored-files)) - (println (blue "generating rss")) + (println (blue "generating main rss")) (spit (str public blog-prefix "/" rss-name) (rss/make-channel config posts)) + (println (blue "generating filtered rss")) + (rss/make-filtered-channels public config posts-by-tag) (println (blue "compiling sass")) (sass/compile-sass->css! (str "resources/templates/" sass-src) diff --git a/src/cryogen_core/rss.clj b/src/cryogen_core/rss.clj index 26856fa..eca46fe 100644 --- a/src/cryogen_core/rss.clj +++ b/src/cryogen_core/rss.clj @@ -1,6 +1,7 @@ (ns cryogen-core.rss (:require [clj-rss.core :as rss] - [clojure.xml :refer [emit]]) + [clojure.xml :refer [emit]] + [text-decoration.core :refer :all]) (:import java.util.Date)) @@ -25,4 +26,10 @@ :description (:description config) :lastBuildDate (Date.) :author (:author config)}) - (posts-to-items (:site-url config) (:author config) posts))) \ No newline at end of file + (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)))))) \ No newline at end of file