Make RSS and ATOM templates theme-independent.
This commit is contained in:
parent
b72eb5b03a
commit
9bc2e55d58
6 changed files with 17 additions and 11 deletions
4
NEWS.md
4
NEWS.md
|
@ -1,3 +1,7 @@
|
|||
## Changes for 0.9.1 (2013-04-xx):
|
||||
|
||||
* Make ATOM and RSS templates a separate "generic" theme. (thanks @woudshoo!)
|
||||
|
||||
## Changes for 0.9 (2013-02-20):
|
||||
|
||||
* INCOMPATIBLE CHANGE: All :plugins in .coleslawrc must be lists. (i.e. (mathjax) not mathjax)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
(defun render-page (content &optional theme-fn &rest render-args)
|
||||
"Render the given CONTENT to disk using THEME-FN if supplied.
|
||||
Additional args to render CONTENT can be passed via RENDER-ARGS."
|
||||
(funcall (theme-fn (or theme-fn 'base))
|
||||
(funcall (or theme-fn (theme-fn 'base))
|
||||
(list :config *config*
|
||||
:content content
|
||||
:raw (apply 'render content render-args)
|
||||
|
|
|
@ -11,11 +11,13 @@
|
|||
(let* ((by-date (by-date (find-all 'post)))
|
||||
(posts (first-10 by-date))
|
||||
(rss (make-instance 'index :id "rss.xml" :posts posts))
|
||||
(atom (make-instance 'index :id "feed.atom" :posts posts)))
|
||||
(write-page (page-path rss) (render-page rss :rss-feed))
|
||||
(write-page (page-path atom) (render-page atom :atom-feed))
|
||||
(atom (make-instance 'index :id "feed.atom" :posts posts))
|
||||
(rss-template (theme-fn :rss-feed "feeds"))
|
||||
(atom-template (theme-fn :atom-feed "feeds")))
|
||||
(write-page (page-path rss) (render-page rss rss-template))
|
||||
(write-page (page-path atom) (render-page atom atom-template))
|
||||
(dolist (feed feeds)
|
||||
(let ((index (index-by-tag feed by-date)))
|
||||
(setf (index-id index) (format nil "~a-rss.xml" feed)
|
||||
(index-posts index) (first-10 (index-posts index)))
|
||||
(write-page (page-path index) (render-page index :rss-feed)))))))
|
||||
(write-page (page-path index) (render-page index rss-template)))))))
|
||||
|
|
|
@ -22,13 +22,13 @@ any return value other than nil indicates the injection should be added."
|
|||
(list :head (injections-for :head)
|
||||
:body (injections-for :body))))
|
||||
|
||||
(defun theme-package (&key (name (theme *config*)))
|
||||
(defun theme-package (name)
|
||||
"Find the package matching the theme NAME."
|
||||
(find-package (string-upcase (concatenate 'string "coleslaw.theme." name))))
|
||||
|
||||
(defun theme-fn (name)
|
||||
"Find the symbol NAME inside the current theme's package."
|
||||
(find-symbol (princ-to-string name) (theme-package)))
|
||||
(defun theme-fn (name &optional (package (theme *config*)))
|
||||
"Find the symbol NAME inside PACKAGE which defaults to the theme package."
|
||||
(find-symbol (princ-to-string name) (theme-package package)))
|
||||
|
||||
(defun compile-theme (theme)
|
||||
"Locate and compile the templates for the given THEME."
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{namespace coleslaw.theme.hyde}
|
||||
{namespace coleslaw.theme.feeds}
|
||||
|
||||
{template atom-feed}
|
||||
<?xml version="1.0"?>{\n}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{namespace coleslaw.theme.hyde}
|
||||
{namespace coleslaw.theme.feeds}
|
||||
|
||||
{template rss-feed}
|
||||
<?xml version="1.0"?>{\n}
|
||||
|
|
Loading…
Add table
Reference in a new issue