From a404687855e6dfbe4f3500f619cbea95891ad800 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sun, 20 Jul 2008 22:45:49 -0700 Subject: [PATCH] Initial version of ikiwiki plug-in. Start with simpler non-project publishing. --- examples/ikiwiki/muse | 32 +++++++++ .../ikiwiki/{muse-init.el => muse-init-project.el} | 0 examples/ikiwiki/muse-init-simple.el | 83 ++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 examples/ikiwiki/muse rename examples/ikiwiki/{muse-init.el => muse-init-project.el} (100%) create mode 100644 examples/ikiwiki/muse-init-simple.el diff --git a/examples/ikiwiki/muse b/examples/ikiwiki/muse new file mode 100644 index 0000000..762800c --- /dev/null +++ b/examples/ikiwiki/muse @@ -0,0 +1,32 @@ +#!/usr/bin/perl +# Ikiwiki plugin for Emacs Muse. +# Author: Michael Olson +# License: GPLv2 or later +package IkiWiki::Plugin::muse; + +use warnings; +use strict; +use IkiWiki 2.00; +use Encode; +use File::Temp; + +sub import { + hook(type => "htmlize", id => "muse", call => \&htmlize); +} + +sub htmlize (@) { + my %params=@_; + my $content = decode_utf8(encode_utf8($params{content})); + + my ($fh, $filename) = File::Temp::tempfile(); + my $quoted = $filename; + $quoted =~ s/"/\\"/g; + system "emacsclient", "--eval", qq{(muse-ikiwiki-publish "$quoted")}; + { + local $/; + $contents = <$fh>; + } + return $contents; +} + +1 diff --git a/examples/ikiwiki/muse-init.el b/examples/ikiwiki/muse-init-project.el similarity index 100% rename from examples/ikiwiki/muse-init.el rename to examples/ikiwiki/muse-init-project.el diff --git a/examples/ikiwiki/muse-init-simple.el b/examples/ikiwiki/muse-init-simple.el new file mode 100644 index 0000000..11ba81c --- /dev/null +++ b/examples/ikiwiki/muse-init-simple.el @@ -0,0 +1,83 @@ +;;; muse-init.el --- Use Emacs Muse to publish ikiwiki documents + +;; The code in this file may be used, distributed, and modified +;; without restriction. + +;;; Setup + +(add-to-list 'load-path (expand-file-name "~ikiwiki/elisp/muse/lisp")) + +;; Initialize +(require 'muse) ; load generic module +(require 'muse-html) ; load (X)HTML publishing style + +;;; 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" + "css" "diary" "diff" "dns" "domtool" "emacs-lisp" "f90" "fortran" + "fundamental" "html" "java" "jython" "latex" "lisp" "lua" "m4" + "makefile" "markdown" "matlab" "maxima" "message" "modula-2" "muse" + "nroff" "octave" "org" "outline" "pascal" "perl" "ps" "python" "rst" + "ruby" "scheme" "sgml" "sh" "slang" "sml" "sml-cm" "sml-lex" "sml-yacc" + "sql" "tcl" "tex" "texinfo" "xml" "zone")) +;; In case someone does +(setq muse-colors-evaluate-lisp-tags nil + muse-colors-inline-images nil) +;; In case someone does +(require 'org) +(setq org-inhibit-startup t + org-table-formula-evaluate-inline nil) + +;; Don't allow dangerous tags to be published +(setq muse-publish-enable-dangerous-tags nil) + +;;; Functions + +(defun muse-ikiwiki-publish (file) + "Publish a single file for ikiwiki." + (if (not (stringp file)) + (message "Error: No file given to publish") + (let ((muse-batch-publishing-p t) + (title "Unknown file from ikiwiki") + (style "ikiwiki") + (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 + '(muse-html-charset-default "utf-8") + '(muse-html-encoding-default (quote utf-8)) + '(muse-html-meta-content-encoding (quote utf-8)) + '(muse-publish-comments-p t) + '(muse-publish-date-format "%b. %e, %Y")) +(custom-set-faces) + +;;; Start server + +(require 'server) +(server-start) + +;;; muse-init.el ends here -- 2.11.4.GIT