Minor cleanups to sitemap plugin.

This commit is contained in:
Brit Butler 2013-04-28 10:11:38 -04:00
parent e6c6bcbe26
commit dd027db409
4 changed files with 19 additions and 21 deletions

View file

@ -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)```

View file

@ -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 ())

View file

@ -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.

View file

@ -5,7 +5,7 @@
<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>
{foreach $url in $urls}
<url>
<loc>{$domain}/{$url}</loc>
<loc>{$config.domain}/{$url}</loc>
<lastmod>{$pubdate}</lastmod>
</url>
{/foreach}