;; wiliki-sitemap.scm -- adds a sitemap action to WiLiKi ;; Copyright 2006 Evan Prodromou ;; Licensed under the Academic Free License version 3.0 (with-module wiliki (use srfi-13) (use srfi-19) (use sxml.tools) (define-wiliki-action sitemap :read (_) (define (format-time t) ; 'YYYY-MM-DDTHH:MI:SSZ' (date->string (time-utc->date (make-time 'time-utc 0 t) 0) "~Y-~m-~dT~H:~M:~S~z")) (define (format-item wikiname) (let* ((page (wiliki-db-get wikiname))) `(url (loc ,(string-append "http://evan.prodromou.name/" (uri-encode-string wikiname))) (lastmod ,(format-time (ref page 'mtime)))))) (let ((entries (sort (wiliki-db-map (lambda (k v) k)) string\n" (sxml:sxml->xml `((urlset (@ (xmlns "http://www.google.com/schemas/sitemap/0.84") (xmlns:xsi "http://www.w3.org/2001/XMLSchema-instance") (xsi:schemaLocation "http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd")) ,@(map format-item entries))))))))