muse-ikiwiki: Move publishing function and style here.
[muse-el.git] / lisp / muse-ikiwiki.el
blob2efe1408faa95c27d2b4bb055fd4d81ee9809d82
1 ;;; muse-ikiwiki.el --- integrate with Ikiwiki
3 ;; Copyright (C) 2008 Free Software Foundation, Inc.
5 ;; This file is part of Emacs Muse. It is not part of GNU Emacs.
7 ;; Emacs Muse is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
12 ;; Emacs Muse is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with Emacs Muse; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
22 ;;; Commentary:
24 ;;; Contributors:
26 ;;; Code:
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
30 ;; Muse Ikiwiki Integration
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34 (require 'muse)
35 (require 'muse-html)
36 (require 'muse-publish)
38 (defgroup muse-ikiwiki nil
39 "Options controlling the behavior of Muse integration with Ikiwiki."
40 :group 'muse-publish)
42 (defcustom muse-ikiwiki-header
44 "Header used for publishing Ikiwiki output files.
45 This may be text or a filename."
46 :type 'string
47 :group 'muse-ikiwiki)
49 (defcustom muse-ikiwiki-footer ""
50 "Footer used for publishing Ikiwiki output files.
51 This may be text or a filename."
52 :type 'string
53 :group 'muse-ikiwiki)
55 (defun muse-ikiwiki-publish-file (file name &optional style)
56 "Publish a single file for ikiwiki.
57 The name of the style is given by STYLE. It defaults to \"ikiwiki\".
58 The name of the real file is NAME, and the name of the temporary
59 file containing the content is FILE."
60 (if (not (stringp file))
61 (message "Error: No file given to publish")
62 (unless style
63 (setq style "ikiwiki"))
64 (let ((muse-batch-publishing-p t)
65 (title (muse-page-name name))
66 (output-path file)
67 (target file)
68 (muse-publishing-current-file file)
69 (muse-publishing-current-output-path file)
70 muse-current-output-style)
71 ;; don't activate VC when publishing files
72 (setq vc-handled-backends nil)
73 (setq muse-current-output-style (list :base style :path file))
74 (setq auto-mode-alist
75 (delete (cons (concat "\\." muse-file-extension "\\'")
76 'muse-mode-choose-mode)
77 auto-mode-alist))
78 (muse-with-temp-buffer
79 (muse-insert-file-contents file)
80 (run-hooks 'muse-before-publish-hook)
81 (let ((muse-inhibit-before-publish-hook t))
82 (muse-publish-markup-buffer title style))
83 (when (muse-write-file output-path)
84 (muse-style-run-hooks :final style file output-path target))))))
86 ;; Styles
87 (muse-derive-style "ikiwiki" "xhtml"
88 :header 'muse-ikiwiki-header
89 :footer 'muse-ikiwiki-footer)
91 (provide 'muse-ikiwiki)
93 ;;; muse-ikiwiki.el ends here