From 31654d6f0ac30de88afaf4bea1ab83e4e00ba662 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Mon, 21 Jul 2008 22:14:25 -0700 Subject: [PATCH] muse-ikiwiki: Move publishing function and style here. --- examples/ikiwiki/muse | 2 +- examples/ikiwiki/muse-init-project.el | 24 ++------- examples/ikiwiki/muse-init-simple.el | 37 +------------- lisp/Makefile | 2 + lisp/muse-ikiwiki.el | 93 +++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 58 deletions(-) create mode 100644 lisp/muse-ikiwiki.el diff --git a/examples/ikiwiki/muse b/examples/ikiwiki/muse index 446ce8a..f0411af 100644 --- a/examples/ikiwiki/muse +++ b/examples/ikiwiki/muse @@ -28,7 +28,7 @@ sub htmlize (@) { eval { system qw( emacs -q --no-site-file -batch -l muse-init-simple.el --eval ), - qq{(muse-ikiwiki-publish "$qfile" "$qname")}; + qq{(muse-ikiwiki-publish-file "$qfile" "$qname")}; { open my $ifh, '<', $filename; local $/; diff --git a/examples/ikiwiki/muse-init-project.el b/examples/ikiwiki/muse-init-project.el index 8e058d1..ee2c3ed 100644 --- a/examples/ikiwiki/muse-init-project.el +++ b/examples/ikiwiki/muse-init-project.el @@ -1,4 +1,4 @@ -;;; muse-init.el --- Use Emacs Muse to publish ikiwiki documents +;;; muse-init-project.el --- Use Emacs Muse to publish ikiwiki documents ;; The code in this file may be used, distributed, and modified ;; without restriction. @@ -10,16 +10,12 @@ ;; Initialize (require 'muse) ; load generic module (require 'muse-html) ; load (X)HTML publishing style +(require 'muse-ikiwiki) ; load Ikiwiki integration (require 'muse-project) ; load support for projects (require 'muse-wiki) ; load Wiki support ;;; Settings -;; Styles -(muse-derive-style "ikiwiki" "xhtml" - :header "" - :footer "") - ;; New variables (defvar muse-ikiwiki-project "HCoopWiki" "Name of the project to publish using ikiwiki.") @@ -73,20 +69,6 @@ ;; Don't allow dangerous tags to be published (setq muse-publish-enable-dangerous-tags nil) -;;; Functions - -(defun muse-ikiwiki-publish (file &optional force) - "Publish a single file for ikiwiki." - (if (not (stringp file)) - (message "Error: No file given to publish") - (let* ((project (muse-project muse-ikiwiki-project)) - (styles (and project (cddr project))) - (muse-current-project project) - (muse-batch-publishing-p t)) - (if (not project) - (message "Error: project `%s' does not exist" muse-ikiwiki-project) - (muse-project-publish-file file styles force))))) - ;;; Custom variables (custom-set-variables @@ -103,4 +85,4 @@ (require 'server) (server-start) -;;; muse-init.el ends here +;;; muse-init-project.el ends here diff --git a/examples/ikiwiki/muse-init-simple.el b/examples/ikiwiki/muse-init-simple.el index 04f08e4..edca3f6 100644 --- a/examples/ikiwiki/muse-init-simple.el +++ b/examples/ikiwiki/muse-init-simple.el @@ -10,14 +10,10 @@ ;; Initialize (require 'muse) ; load generic module (require 'muse-html) ; load (X)HTML publishing style +(require 'muse-ikiwiki) ; load Ikiwiki integration ;;; Settings -;; Styles -(muse-derive-style "ikiwiki" "xhtml" - :header "" - :footer "") - ;; Permitted modes for to colorize (setq muse-html-src-allowed-modes '("ada" "apache" "asm" "awk" "c++" "c" "cc" "change-log" "context" @@ -38,37 +34,6 @@ ;; Don't allow dangerous tags to be published (setq muse-publish-enable-dangerous-tags nil) -;;; Functions - -(defun muse-ikiwiki-publish (file name) - "Publish a single file for ikiwiki. -The name of the real file is NAME, and the name of the temporary -file containing the content is FILE." - (if (not (stringp file)) - (message "Error: No file given to publish") - (let ((muse-batch-publishing-p t) - (title (muse-page-name name)) - (style "ikiwiki") - (output-path file) - (target file) - (muse-publishing-current-file file) - (muse-publishing-current-output-path file) - muse-current-output-style) - ;; don't activate VC when publishing files - (setq vc-handled-backends nil) - (setq muse-current-output-style (list :base style :path file)) - (setq auto-mode-alist - (delete (cons (concat "\\." muse-file-extension "\\'") - 'muse-mode-choose-mode) - auto-mode-alist)) - (muse-with-temp-buffer - (muse-insert-file-contents file) - (run-hooks 'muse-before-publish-hook) - (let ((muse-inhibit-before-publish-hook t)) - (muse-publish-markup-buffer title style)) - (when (muse-write-file output-path) - (muse-style-run-hooks :final style file output-path target)))))) - ;;; Custom variables (custom-set-variables diff --git a/lisp/Makefile b/lisp/Makefile index bfea6e3..abee058 100644 --- a/lisp/Makefile +++ b/lisp/Makefile @@ -63,6 +63,8 @@ muse-html.elc: muse-publish.elc muse-regexps.elc muse-xml-common.elc muse-http.elc: muse-html.elc muse-project.elc +muse-ikiwiki.elc: muse-html.elc muse-publish.elc muse.elc + muse-import-docbook.elc: muse-import-xml.elc muse-import-latex.elc: muse-regexps.elc muse.elc diff --git a/lisp/muse-ikiwiki.el b/lisp/muse-ikiwiki.el new file mode 100644 index 0000000..2efe140 --- /dev/null +++ b/lisp/muse-ikiwiki.el @@ -0,0 +1,93 @@ +;;; muse-ikiwiki.el --- integrate with Ikiwiki + +;; Copyright (C) 2008 Free Software Foundation, Inc. + +;; This file is part of Emacs Muse. It is not part of GNU Emacs. + +;; Emacs Muse is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published +;; by the Free Software Foundation; either version 3, or (at your +;; option) any later version. + +;; Emacs Muse is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with Emacs Muse; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;;; Contributors: + +;;; Code: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Muse Ikiwiki Integration +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(require 'muse) +(require 'muse-html) +(require 'muse-publish) + +(defgroup muse-ikiwiki nil + "Options controlling the behavior of Muse integration with Ikiwiki." + :group 'muse-publish) + +(defcustom muse-ikiwiki-header + "" + "Header used for publishing Ikiwiki output files. +This may be text or a filename." + :type 'string + :group 'muse-ikiwiki) + +(defcustom muse-ikiwiki-footer "" + "Footer used for publishing Ikiwiki output files. +This may be text or a filename." + :type 'string + :group 'muse-ikiwiki) + +(defun muse-ikiwiki-publish-file (file name &optional style) + "Publish a single file for ikiwiki. +The name of the style is given by STYLE. It defaults to \"ikiwiki\". +The name of the real file is NAME, and the name of the temporary +file containing the content is FILE." + (if (not (stringp file)) + (message "Error: No file given to publish") + (unless style + (setq style "ikiwiki")) + (let ((muse-batch-publishing-p t) + (title (muse-page-name name)) + (output-path file) + (target file) + (muse-publishing-current-file file) + (muse-publishing-current-output-path file) + muse-current-output-style) + ;; don't activate VC when publishing files + (setq vc-handled-backends nil) + (setq muse-current-output-style (list :base style :path file)) + (setq auto-mode-alist + (delete (cons (concat "\\." muse-file-extension "\\'") + 'muse-mode-choose-mode) + auto-mode-alist)) + (muse-with-temp-buffer + (muse-insert-file-contents file) + (run-hooks 'muse-before-publish-hook) + (let ((muse-inhibit-before-publish-hook t)) + (muse-publish-markup-buffer title style)) + (when (muse-write-file output-path) + (muse-style-run-hooks :final style file output-path target)))))) + +;; Styles +(muse-derive-style "ikiwiki" "xhtml" + :header 'muse-ikiwiki-header + :footer 'muse-ikiwiki-footer) + +(provide 'muse-ikiwiki) + +;;; muse-ikiwiki.el ends here -- 2.11.4.GIT