From dd027db409523dd9576acda3c483ceec713a82ff Mon Sep 17 00:00:00 2001 From: Brit Butler Date: Sun, 28 Apr 2013 10:11:38 -0400 Subject: [PATCH] Minor cleanups to sitemap plugin. --- docs/plugin-use.md | 12 ++++++------ plugins/sitemap.lisp | 16 +++++++--------- src/coleslaw.lisp | 10 +++++----- themes/sitemap.tmpl | 2 +- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/docs/plugin-use.md b/docs/plugin-use.md index 025112a..0b9b674 100644 --- a/docs/plugin-use.md +++ b/docs/plugin-use.md @@ -50,14 +50,14 @@ **Example**: ```(s3 :auth-file "/home/redline/.aws_creds" :bucket "blog.redlinernotes.com")``` +## Sitemap generator + +**Description**: This plugin generates a sitemap.xml under the page root, which is useful if you want google to crawl your site. + +**Example**: ```(sitemap)``` + ## Wordpress Importer **Description**: Import blog posts from Wordpress using their export tool. Blog entries will be read from the XML and converted into .post files. Afterwards the XML file will be deleted to prevent reimporting. Optionally an ```:output``` argument may be supplied to the plugin. If provided, it should be a directory in which to store the .post files. Otherwise, the value of ```:repo``` in your .coleslawrc will be used. **Example**: ```(import :filepath "/home/redline/redlinernotes-export.timestamp.xml" :output "/home/redlinernotes/blog/")``` - -## Sitemap generator - -**Description**: this plugin generates a sitemap.xml under the page root, which is useful if you want google to crawl your site. - -**Example**: ```(sitemap)``` diff --git a/plugins/sitemap.lisp b/plugins/sitemap.lisp index ef8cbaa..032e236 100644 --- a/plugins/sitemap.lisp +++ b/plugins/sitemap.lisp @@ -1,10 +1,10 @@ -(defpackage :coleslaw-sitemap +(defpackage :coleslaw-sitemap (:use :cl) (:import-from :coleslaw #:*config* #:deploy - #:domain #:find-all + #:make-pubdate #:page-url #:rel-path #:staging-dir @@ -12,18 +12,16 @@ #:write-page) (:export #:enable)) -(in-package :coleslaw-sitemap) +(in-package :coleslaw-sitemap) (defmethod deploy :before (staging) "Render sitemap.xml under document root" - (let* ((urls (append '("" "sitemap.xml") ; empty string is for root url - (mapcar #'page-url (find-all 'coleslaw:post))))) + (let ((urls (append '("" "sitemap.xml") ; empty string is for root url + (mapcar #'page-url (find-all 'coleslaw:post))))) (write-page (rel-path (staging-dir *config*) "sitemap.xml") (funcall (theme-fn :sitemap "feeds") - (list :domain (domain *config*) + (list :config *config* :urls urls - :pubdate (local-time:format-rfc3339-timestring - nil - (local-time:now))))))) + :pubdate (make-pubdate)))))) (defun enable ()) diff --git a/src/coleslaw.lisp b/src/coleslaw.lisp index 25c6b73..940d9fb 100644 --- a/src/coleslaw.lisp +++ b/src/coleslaw.lisp @@ -13,17 +13,17 @@ (3bmd:parse-string-and-print-to-stream text str))))) (defgeneric page-url (object) - (:documentation "The url to the object, without the domain")) + (:documentation "The url to the object, without the domain.")) (defmethod page-url :around ((object t)) (let ((result (call-next-method))) - (namestring (if (pathname-type result) - result - (make-pathname :type "html" :defaults result))))) + (if (pathname-type result) + result + (make-pathname :type "html" :defaults result)))) (defun page-path (object) "The path to store OBJECT at once rendered." - (rel-path (staging-dir *config*) (page-url object))) + (rel-path (staging-dir *config*) (namestring (page-url object)))) (defun render-page (content &optional theme-fn &rest render-args) "Render the given CONTENT to disk using THEME-FN if supplied. diff --git a/themes/sitemap.tmpl b/themes/sitemap.tmpl index 89b77bb..b94bf8a 100644 --- a/themes/sitemap.tmpl +++ b/themes/sitemap.tmpl @@ -5,7 +5,7 @@ {foreach $url in $urls} - {$domain}/{$url} + {$config.domain}/{$url} {$pubdate} {/foreach}