Document publishing directives.
[muse-el.git] / examples / mwolson / muse-init.el
blobe8ddc9825286b5ae5eec1f2036a20dcc3e644db5
1 ;;; muse-init.el --- Initialize muse-mode.
3 ;; Hacked on by Michael Olson
5 ;; In order to see the scripts that I use to publish my website to a
6 ;; remote webserver, check out
7 ;; http://www.mwolson.org/projects/SiteScripts.html.
9 ;;; Setup
11 ;; Add to load path
12 (when (fboundp 'debian-pkg-add-load-path-item)
13 (debian-pkg-add-load-path-item "/stuff/proj/emacs/muse/mwolson/lisp")
14 (debian-pkg-add-load-path-item "/stuff/proj/emacs/muse/mwolson/experimental"))
16 ;; Initialize
17 (require 'outline) ; I like outline-style faces
18 (require 'muse) ; load generic module
19 (require 'muse-colors) ; load coloring/font-lock module
20 (require 'muse-mode) ; load authoring mode
21 (require 'muse-blosxom) ; load blosxom module
22 (require 'muse-docbook) ; load DocBook publishing style
23 (require 'muse-html) ; load (X)HTML publishing style
24 (require 'muse-wiki) ; load Wiki support
25 (require 'muse-xml) ; load experimental XML support
26 ;;(require 'muse-message) ; load message support (experimental)
28 ;; Setup projects
30 ;; Here is an example of making a customized version of your favorite
31 ;; publisher. All this does is run `my-muse-blosoxm-finalize' on the
32 ;; published file immediately after saving it.
34 (unless (assoc "my-blosxom" muse-publishing-styles)
35 (muse-derive-style "my-blosxom" "blosxom-xhtml"
36 :final 'my-muse-blosxom-finalize)
38 (muse-derive-style "my-xhtml" "xhtml"
39 :header "~/personal-site/muse/header.html"
40 :footer "~/personal-site/muse/footer.html"))
42 ;; Here is my master project listing.
44 ;; Note that I not do anything useful with the ProjectsWiki and
45 ;; WebWiki projects; only the BlogWiki project is published.
47 (setq muse-project-alist
49 ("Website"
50 ("~/proj/wiki/web/"
51 :force-publish ("WikiIndex")
52 :default "WelcomePage")
53 (:base "my-xhtml"
54 :path "~/personal-site/site/web"))
56 ("Projects"
57 ("~/proj/wiki/projects/"
58 :force-publish ("WikiIndex")
59 :default "WelcomePage")
60 (:base "my-xhtml"
61 :path "~/personal-site/site/projects"))
63 ("Blog"
64 (,@(muse-project-alist-dirs "~/proj/wiki/blog")
65 :default "guestbook")
67 ,@(muse-project-alist-styles "~/proj/wiki/blog"
68 "~/personal-site/site/blog"
69 "my-blosxom"))
71 ("Plans"
72 ("~/proj/wiki/plans/"
73 :default "TaskPool"
74 :major-mode planner-mode
75 :visit-link planner-visit-link)
77 (:base "xhtml"
78 :path "~/proj/notmine/planner-out"))
81 ;; Wiki settings
82 (setq muse-wiki-interwiki-alist
83 '(("PlugWiki" . "http://plug.student-orgs.purdue.edu/plugwiki/")
84 ("PLUG" . "http://plug.student-orgs.purdue.edu/plugwiki/")
85 ("TheEmacsWiki" . "http://www.emacswiki.org/cgi-bin/wiki/")
86 ("ArchWiki" . "http://wiki.gnuarch.org/")))
88 ;;; Functions
90 ;; Make the current file display correctly in Xanga
92 (defun my-muse-blosxom-finalize (file output-path target)
93 ;; (my-muse-prepare-entry-for-xanga output-path)
94 ;; For now, do nothing.
97 ;; I call this using C-c p x now.
99 (defun my-muse-prepare-entry-for-xanga (file)
100 "Mangle FILE so that Xanga doesn't bug out, saving to X clipboard.
102 If FILE is not specified, use the published version of the current file."
103 (interactive
104 (list
105 (expand-file-name (concat (muse-page-name) muse-blosxom-extension)
106 (muse-style-element
107 :path (car (muse-project-applicable-styles
108 buffer-file-name
109 (cddr (muse-project-of-file))))))))
110 (save-match-data
111 (muse-with-temp-buffer
112 (insert-file-contents file)
113 ;; Surround first line in <h3></h3>
114 (goto-char (point-min))
115 (insert "<h3>")
116 (end-of-line)
117 (insert "</h3>")
118 ;; Treat example regions properly
119 (let (beg end)
120 (while (re-search-forward "<pre[^>]*>" nil t)
121 (setq beg (match-end 0))
122 (setq end (if (re-search-forward "</pre>" nil 1)
123 (match-beginning 0)
124 (point)))
125 (save-restriction
126 (narrow-to-region beg end)
127 ;; Change spaces to &nbsp;
128 (goto-char (point-min))
129 (while (re-search-forward "^ +" nil t)
130 (replace-match (apply 'concat (make-list
131 (length (match-string 0))
132 "&nbsp;"))))
133 ;; Change newline to <br />
134 (goto-char (point-min))
135 (while (re-search-forward "\n" nil t)
136 (replace-match "<br />")))))
137 ;; Get rid of 2 spaces together and merge lines
138 (goto-char (point-min))
139 (while (re-search-forward (concat "["
140 muse-regexp-space
141 "]+") nil t)
142 (replace-match " "))
143 ;; Remove trailing space
144 (goto-char (point-min))
145 (while (re-search-forward " *</p> *" nil t)
146 (replace-match "</p>"))
147 ;; Make relative links work
148 (goto-char (point-min))
149 (while (re-search-forward "href=\"[/.]+" nil t)
150 (replace-match "href=\"http://www.mwolson.org/" nil t))
151 ;; Copy entry to clipboard
152 (clipboard-kill-ring-save (point-min) (point-max)))))
154 ;;; Key customizations
156 (global-set-key "\C-cpl" 'muse-blosxom-new-entry)
157 (global-set-key "\C-cpL"
158 #'(lambda ()
159 (interactive)
160 (let ((muse-current-project (muse-project "Blog")))
161 (call-interactively 'muse-project-find-file))))
162 (global-set-key "\C-cpx" 'my-muse-prepare-entry-for-xanga)
164 ;;; Custom variables
166 (custom-set-variables
167 '(muse-blosxom-base-directory "~/proj/wiki/blog/")
168 '(muse-blosxom-publishing-directory "~/personal-site/site/blog")
169 '(muse-colors-autogen-headings (quote outline))
170 '(muse-file-extension "muse")
171 '(muse-html-charset-default "utf-8")
172 '(muse-html-encoding-default (quote utf-8))
173 '(muse-html-meta-content-encoding (quote utf-8))
174 '(muse-html-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"all\" href=\"/common.css\" />
175 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"screen\" href=\"/screen.css\" />
176 <link rel=\"stylesheet\" type=\"text/css\" charset=\"utf-8\" media=\"print\" href=\"/print.css\" />")
177 '(muse-mode-auto-p nil)
178 '(muse-mode-hook (quote (footnote-mode muse-wiki-update-custom-values)))
179 '(muse-publish-desc-transforms (quote (muse-wiki-publish-pretty-title muse-wiki-publish-pretty-interwiki muse-publish-escape-specials-in-string)))
180 '(muse-wiki-publish-small-title-words (quote ("the" "and" "at" "on" "of" "for" "in" "an" "a" "page" "anime")))
181 '(muse-xhtml-footer "~/personal-site/muse/generic-footer.html")
182 '(muse-xhtml-header "~/personal-site/muse/generic-header.html"))
183 (custom-set-faces
184 '(muse-bad-link-face ((t (:foreground "DeepPink" :underline "DeepPink" :weight bold))))
185 '(muse-link-face ((t (:foreground "blue" :underline "blue" :weight bold)))))
187 ;;; muse-init.el ends here