[[http://feeds.archive.org/validator/images/valid-rss.png][Producing valid RSS!]] See also: EmacsWiki / RssSyndication. * What it does This is a prototype of [[RssSyndication][RSS]] generation for EmacsWiki. You can check out the [[http://larve.net/people/hugo/2003/scratchpad/wiki.rdf][RSS feed generated automatically]] and [[http://feeds.archive.org/validator/check?url=http://larve.net/people/hugo/2003/scratchpad/wiki.rdf][validate it]]. Since I am a total newbie at TheEmacsWiki#EmacsLisp, the following code is probably awful, but it kind-of works. A few bugs: - the declared title of a page isn't really the one which appears; =#title= isn't used; I don't know how to do that. - I would like to add a description of each page, but I haven't figured if and how it is possible to do so. DamienElmes sent me a few pointers to fix those. #code * The code I have tried to extract some information so that some variables have the customizable information. Some things may be improved, such as writing functions instead of concatenating strings everywhere, using string formatting functions, etc. Feel free to use and improve this code. Please let me know if you make any improvements. I have sent this code to DamienElmes. ;;; Generate RSS for the Wiki ; Customization variables (defcustom emacs-wiki-online-target "http://larve.net/people/hugo/2003/scratchpad/" "Base URL where the files are published." :type 'string :group 'emacs-wiki-publish) (defcustom emacs-wiki-rss-filename "wiki.rdf" "Name for the RSS file." :type 'string :group 'emacs-wiki-publish) (defcustom emacs-wiki-rss-title "Hugo Haas's Scratchpad" "Title the RSS channel." :type 'string :group 'emacs-wiki-publish) (defcustom emacs-wiki-rss-description "Area where Hugo Haas takes random notes" "Description of the RSS channel." :type 'string :group 'emacs-wiki-publish) ; Redefine publication to include RSS generation (define-key emacs-wiki-mode-map [(control ?c) (control ?p)] 'my-emacs-wiki-publish) (defun my-emacs-wiki-publish () "Publishes pages and RSS." (interactive) (emacs-wiki-publish) (emacs-wiki-rss)) (defun emacs-wiki-generate-rss (&optional as-list exclude-private) "Generate RSS for all Wiki pages." (let ((project emacs-wiki-current-project)) (with-current-buffer (get-buffer-create "*Wiki RSS*") (erase-buffer) (if project (emacs-wiki-change-project project)) (insert " " emacs-wiki-rss-title " " emacs-wiki-online-target (emacs-wiki-published-name emacs-wiki-default-page) " " emacs-wiki-rss-description " ") ; Stolen from http://www.gohome.org/teranisi/EmacsWiki.html ; by Yuuichi Teranishi - http://www.gohome.org/teranisi/WelcomePage.html (let ((files (sort (mapcar (lambda (pair) (list (car pair) (cdr pair) (nth 5 (file-attributes (cdr pair))))) (emacs-wiki-file-alist)) (function (lambda (l r) (not (emacs-wiki-time-less-p (nth 2 l)(nth 2 r))))))) file) (setq f files) (insert " \n") (while files (unless (and exclude-private (emacs-wiki-private-p (caar files))) (insert "\n")) (setq files (cdr files))) (insert "") (setq files f) (while files (unless (and exclude-private (emacs-wiki-private-p (caar files))) (setq name (caar files)) (insert "\n" (emacs-wiki-page-title name) "\n" "" emacs-wiki-online-target (emacs-wiki-published-name name) "\n" "" (if as-list "- " "") (format-time-string "%Y-%m-%dT%T" (nth 2 (car files))) "\n" "" emacs-wiki-maintainer "\n" "\n")) (setq files (cdr files)))) (insert "") (current-buffer)))) (defun emacs-wiki-rss () "Display RSS for all known Wiki pages." (interactive) (message "Generating Wiki RSS...") (pop-to-buffer (emacs-wiki-generate-rss)) (goto-char (point-min)) (let ((backup-inhibited t)) (write-file (expand-file-name emacs-wiki-rss-filename emacs-wiki-publishing-directory))) (kill-buffer (current-buffer)) (delete-window) (message "Generating Wiki RSS...done"))