Release this as Muse 3.00.90 (RC1).
[muse-el.git] / muse-blosxom.el
blob0f4b9cf1bc676efe2cef5abc2706dfa1f55019a7
1 ;;; muse-blosxom.el --- Publish a document tree for serving by (py)Blosxom
3 ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 ;; Date: Wed, 23 March 2005
6 ;; Author: Michael Olson (mwolson AT gnu DOT org)
7 ;; Maintainer: Michael Olson (mwolson AT gnu DOT org)
9 ;; This file is not part of GNU Emacs.
11 ;; This is free software; you can redistribute it and/or modify it under
12 ;; the terms of the GNU General Public License as published by the Free
13 ;; Software Foundation; either version 2, or (at your option) any later
14 ;; version.
16 ;; This is distributed in the hope that it will be useful, but WITHOUT
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 ;; for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; Blosxom publishes a tree of categorised files to a mirrored tree of
29 ;; blosxom stories to be served by blosxom.cgi or pyblosxom.cgi.
31 ;; Serving your entries with (py)blosxom
32 ;; -------------------------------------
34 ;; Each Blosxom file must include `#date yyyy-mm-dd', or optionally
35 ;; the longer `#date yyyy-mm-dd-hh-mm', plus whatever normal content
36 ;; is desired.
38 ;; This date directive is not used directly by (py)blosxom or this
39 ;; program. You need to find two additional items to make use of this
40 ;; feature.
42 ;; 1. A script to gather date directives from the entire blog tree
43 ;; into a single file. The file must associate a blog entry with
44 ;; a date.
46 ;; 2. A plugin for (py)blosxom that reads this file.
48 ;; These 2 things are provided for pyblosxom in the contrib/pyblosxom
49 ;; subdirectory. `getstamps.py' provides the 1st service, while
50 ;; `hardcodedates.py' provides the second service. Eventually it is
51 ;; hoped that a blosxom plugin and script will be found/written.
53 ;; Creating new blog entries
54 ;; -------------------------
56 ;; There is a function called `muse-blosxom-new-entry' that will
57 ;; automate the process of making a new blog entry. To make use of
58 ;; it, do the following.
60 ;; - Customize `muse-blosxom-base-directory' to the location that
61 ;; your blog entries are stored.
63 ;; - Assign the `muse-blosxom-base-directory' function to a key
64 ;; sequence. I use the following code to assign this function to
65 ;; `C-c p l'.
67 ;; (global-set-key "\C-cpl" 'muse-blosxom-new-entry)
69 ;; - You should create your directory structure ahead of time under
70 ;; your base directory. These directories, which correspond with
71 ;; category names, may be nested.
73 ;; - When you enter this key sequence, you will be prompted for the
74 ;; category of your entry and its title. Upon entering this
75 ;; information, a new file will be created that corresponds with
76 ;; the title, but in lowercase letters and having special
77 ;; characters converted to underscores. The title and date
78 ;; directives will be inserted automatically.
80 ;;; Contributors:
82 ;; Gary Vaughan (gary AT gnu DOT org) is the original author of
83 ;; `emacs-wiki-blosxom.el', which is the ancestor of this file.
85 ;; Brad Collins (brad AT chenla DOT org) ported this file to Muse.
87 ;; Michael Olson (mwolson AT gnu DOT org) further adapted this file to
88 ;; Muse and continues to maintain it.
90 ;;; Code:
92 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
94 ;; Muse Blosxom Publishing
96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
98 (require 'muse-project)
99 (require 'muse-publish)
100 (require 'muse-html)
102 (defgroup muse-blosxom nil
103 "Options controlling the behavior of Muse BLOSXOM publishing.
104 See `muse-blosxom' for more information."
105 :group 'muse-publish)
107 (defcustom muse-blosxom-extension ".txt"
108 "Default file extension for publishing BLOSXOM files."
109 :type 'string
110 :group 'muse-blosxom)
112 (defcustom muse-blosxom-header
113 "<lisp>(muse-publishing-directive \"title\")</lisp>\n"
114 "Header used for publishing BLOSXOM files."
115 :type '(choice string file)
116 :group 'muse-blosxom)
118 (defcustom muse-blosxom-footer ""
119 "Footer used for publishing BLOSXOM files."
120 :type '(choice string file)
121 :group 'muse-blosxom)
123 ;; Maintain (published-file . date) alist
125 (defvar muse-blosxom-page-date-alist nil)
127 ;; This isn't really used for anything, but it may be someday
128 (defun muse-blosxom-markup-date-directive ()
129 "Add a date entry to `muse-blosxom-page-date-alist' for this page."
130 (let ((date (match-string 1)))
131 (save-match-data
132 (add-to-list
133 'muse-blosxom-page-date-alist
134 `(,buffer-file-name . ,date))))
137 ;; Enter a new blog entry
139 (defcustom muse-blosxom-base-directory "~/Blog"
140 "Base directory of blog entries, used by `muse-blosxom-new-entry'."
141 :type 'directory
142 :group 'muse-blosxom)
144 (defun muse-blosxom-get-categories (&optional base)
145 "Retrieve all of the categories from a Blosxom project.
146 The base directory is specified by BASE, and defaults to
147 `muse-blosxom-base-directory'.
149 Directories starting with \".\" will be ignored."
150 (unless base (setq base muse-blosxom-base-directory))
151 (let (list dir)
152 (dolist (file (directory-files base t "^[^.]"))
153 (when (file-directory-p file) ; must be a directory
154 (setq dir (file-name-nondirectory file))
155 (push dir list)
156 (nconc list (mapcar #'(lambda (item)
157 (concat dir "/" item))
158 (muse-blosxom-get-categories file)))))
159 list))
161 (defun muse-blosxom-title-to-file (title)
162 "Derive a file name from the given TITLE.
164 Feel free to overwrite this if you have a different concept of what
165 should be allowed in a filename."
166 (replace-regexp-in-string (concat "[^-." muse-regexp-alnum "]")
167 "_" (downcase title)))
169 (defun muse-blosxom-new-entry (category title)
170 "Start a new blog entry with given CATEGORY.
171 The filename of the blog entry is derived from TITLE.
172 The page will be initialized with the current date and TITLE."
173 (interactive
174 (list
175 (completing-read "Category: " (muse-blosxom-get-categories))
176 (read-string "Title: ")))
177 (let ((file (muse-blosxom-title-to-file title)))
178 (muse-project-find-file
179 file "blosxom" nil
180 (concat (directory-file-name muse-blosxom-base-directory)
181 "/" category)))
182 (goto-char (point-min))
183 (insert "#date " (format-time-string "%4Y-%2m-%2d-%2H-%2M")
184 "\n#title " title
185 "\n\n")
186 (forward-line 2))
188 ;; Register the BLOSXOM Publisher
190 (unless (assoc "blosxom-html" muse-publishing-styles)
191 (muse-derive-style "blosxom-html" "html"
192 :suffix 'muse-blosxom-extension
193 :header 'muse-blosxom-header
194 :footer 'muse-blosxom-footer)
196 (muse-derive-style "blosxom-xhtml" "xhtml"
197 :suffix 'muse-blosxom-extension
198 :header 'muse-blosxom-header
199 :footer 'muse-blosxom-footer))
201 (provide 'muse-blosxom)
203 ;;; muse-blosxom.el ends here