Add experimental version of muse-blosxom.el to project
[muse-el.git] / examples / muse-johnw.el
blob40bdb2d656190780ed459477f72357ba284d1585
1 (require 'muse)
2 (require 'muse-mode)
3 (require 'muse-colors)
4 (require 'muse-project)
5 (require 'muse-book)
7 (require 'muse-html)
8 (require 'muse-latex)
9 (require 'muse-texinfo)
11 (require 'muse-journal)
12 (require 'muse-poem)
13 (require 'muse-message)
15 (require 'muse-http)
17 ;;(require 'muse-arabic)
18 ;;(require 'muse-cite)
20 (eval-after-load "whitespace"
21 '(add-to-list 'whitespace-modes 'muse-mode))
23 (defun muse-maybe-convert-poem ()
24 (if (string-match "/poems" muse-publishing-current-file)
25 (muse-poem-prepare-buffer)))
27 (defun muse-insert-reset-chapter ()
28 (insert "\n\\setcounter{chapter}{1}\n"))
30 (defun muse-insert-all-poems-header ()
31 (insert "\n\\renewcommand{\\poemtoc}{chapter}
32 \\settocdepth{chapter}\n"))
34 ;; I use my own sectioning commands in conjunction with memoir.cls
35 (setcdr (assq 'chapter muse-latex-markup-strings) "\\mychapter{")
36 (setcdr (assq 'section muse-latex-markup-strings) "\\mysection{")
37 (setcdr (assq 'subsection muse-latex-markup-strings) "\\mysubsection{")
38 (setcdr (assq 'subsubsection muse-latex-markup-strings) "\\mysubsubsection{")
40 ;; Relocate the images directory
41 ;(setcdr (assq 'image-with-desc muse-latex-markup-strings)
42 ; "\\includegraphics[width=\\textwidth]{../%s}")
43 (setcdr (assq 'image-with-desc muse-latex-markup-strings)
44 "\\includegraphics[scale=0.6]{../%s}")
45 (setcdr (assq 'image-link muse-latex-markup-strings)
46 "\\includegraphics[scale=0.6]{../%s}")
47 (setcdr (assq 'url-with-image muse-latex-markup-strings)
48 "%% %s\n\\includegraphics[scale=0.6]{../%s}")
50 (unless (assoc "site-html" muse-publishing-styles)
51 (muse-derive-style "site-html" "html"
52 :maintainer "jwiegley@hotmail.com"
53 :before 'muse-maybe-convert-poem
54 :after 'muse-my-html-finalize-buffer
55 :header "~/Documents/site/header.html"
56 :footer "~/Documents/site/footer.html")
57 (muse-derive-style "site-journal-html" "journal-html"
58 :maintainer "jwiegley@hotmail.com"
59 :before 'muse-my-journal-find-entries
60 :after 'muse-my-journal-insert-contents
61 :header "~/Documents/site/header.html"
62 :footer "~/Documents/site/footer.html"))
64 (custom-set-variables
65 '(muse-project-alist
66 (quote
67 (("website" ; my various writings
68 (:book-part "Essays"
69 :book-funcall muse-insert-reset-chapter
70 "~/Documents/essays"
71 :book-part "Stories"
72 :book-funcall muse-insert-reset-chapter
73 "~/Documents/stories"
74 :book-part "Journal"
75 :book-style "journal-book-pdf"
76 :book-funcall muse-insert-reset-chapter
77 "~/Documents/journal/early"
78 "~/Documents/journal/summer2003"
79 "~/Documents/journal/j2003"
80 "~/Documents/journal/j2004"
81 "~/Documents/journal/journal"
82 :book-part "Poems"
83 :book-style "chapbook-pdf"
84 :book-funcall muse-insert-all-poems-header
85 :book-funcall muse-insert-reset-chapter
86 :nochapters t ; do automatically add chapters
87 :book-chapter "Mystical"
88 "~/Documents/poems/mystical"
89 :book-chapter "Romance"
90 "~/Documents/poems/romantic"
91 :book-chapter "Nature"
92 "~/Documents/poems/natural"
93 :book-chapter "Melancholoy"
94 "~/Documents/poems/melancholy"
95 :book-chapter "Commentary"
96 "~/Documents/poems/commentary"
97 :book-end t
98 "~/Documents/contents"
99 :default "journal")
101 (:base "html" :path "~/Sites/johnw"
102 :include "/contents/recent")
103 (:base "pdf" :path "~/Sites/johnw/pdf"
104 :include "/\\(essays\\|stories\\)/")
105 (:base "poem-pdf" :path "~/Sites/johnw/pdf"
106 :include "/poems/")
107 (:base "site-html" :path "~/Sites/johnw"
108 :exclude "/journal/")
109 (:base "journal-pdf" :path "~/Sites/johnw/pdf"
110 :include "/journal/")
111 (:base "site-journal-html" :path "~/Sites/johnw"
112 :include "/journal/")
113 (:base "journal-rdf" :path "~/Sites/johnw"
114 :include "/journal/journal")))))
115 '(muse-mode-highlight-p t nil (muse-colors))
116 '(muse-mode-auto-p t nil (muse-project))
117 '(muse-latex-header "~/Documents/site/header.tex")
118 '(muse-latex-footer "~/Documents/site/footer.tex")
119 '(muse-book-latex-header "~/Documents/site/book-header.tex")
120 '(muse-poem-latex-header "~/Documents/site/poem-header.tex")
121 '(muse-poem-latex-footer "~/Documents/site/poem-footer.tex")
122 '(muse-chapbook-latex-header "~/Documents/site/chapbook-header.tex")
123 '(muse-journal-rdf-base-url "http://www.newartisans.com/johnw/")
124 ;;'(muse-before-publish-hook (quote (muse-cite-munge-footnotes)))
125 '(muse-mode-hook (quote (list footnote-mode turn-on-auto-fill flyspell-mode))))
127 (defun muse-publish-my-books (&optional force)
128 (interactive "P")
129 (muse-book-publish-project
130 '("essays" ("~/Documents/essays"))
131 "essays" "Collected Essays" "book-pdf" "~/Sites/johnw/pdf" force)
132 (muse-book-publish-project
133 '("stories" ("~/Documents/stories"))
134 "stories" "Collected Stories" "book-pdf" "~/Sites/johnw/pdf" force)
135 (muse-book-publish-project
136 '("journal"
137 ("~/Documents/journal/early"
138 "~/Documents/journal/summer2003"
139 "~/Documents/journal/j2003"
140 "~/Documents/journal/j2004"
141 "~/Documents/journal/journal"
142 :book-end t
143 "~/Documents/poems/mystical"
144 "~/Documents/poems/romantic"
145 "~/Documents/poems/natural"
146 "~/Documents/poems/melancholy"
147 "~/Documents/poems/commentary"))
148 "thoughts" "Thought Journal" "journal-book-pdf" "~/Sites/johnw/pdf" force)
149 (muse-book-publish-project
150 '("poems"
151 (:nochapters t ; do automatically add chapters
152 :book-chapter "Mystical"
153 "~/Documents/poems/mystical"
154 :book-chapter "Romance"
155 "~/Documents/poems/romantic"
156 :book-chapter "Nature"
157 "~/Documents/poems/natural"
158 :book-chapter "Melancholoy"
159 "~/Documents/poems/melancholy"
160 :book-chapter "Commentary"
161 "~/Documents/poems/commentary"))
162 "poems" "Collected Poems" "chapbook-pdf" "~/Sites/johnw/pdf" force)
163 (muse-book-publish-project
164 "website" "writings" "Collected Writings" "book-pdf"
165 "~/Sites/johnw/pdf" force))
167 (defun modules-get-version-and-date (module)
168 (let (version date)
169 (with-temp-buffer
170 (insert-file-contents-literally module nil 0 1000)
171 (if (re-search-forward "Version:\\s-+\\(.*\\)" nil t)
172 (setq version (match-string 1))))
173 (setq date (format-time-string "%Y-%m-%d"
174 (nth 5 (file-attributes module))))
175 (concat (and muse-publishing-p "<span class=\"version\">")
176 (if version
177 (format "%s (%s)" date version)
178 date)
179 (and muse-publishing-p "</span>"))))
181 (defun muse-blog-add-entry ()
182 (interactive)
183 (muse-project-find-file "journal" "website")
184 (goto-char (point-min))
185 (forward-line 2)
186 (insert "* " (format-time-string "%Y%m%d: ")
187 (read-string "Journal entry title: ")
188 "\n\n\n\n")
189 (forward-line -2))
191 (defun muse-my-html-insert-contents (&optional ignore)
192 (let ((index 1)
193 base contents l)
194 (save-excursion
195 (goto-char (point-min))
196 (search-forward "Page published by Emacs Muse begins here" nil t)
197 (catch 'done
198 (while (re-search-forward "^<h\\([0-9]+\\)>\\(.+?\\)</h\\1>" nil t)
199 (unless (get-text-property (point) 'read-only)
200 (setq l (1- (string-to-int (match-string 1))))
201 (if (null base)
202 (setq base l)
203 (if (< l base)
204 (throw 'done t)))
205 (when (<= l 1)
206 (setq contents (cons (cons l (match-string-no-properties 2))
207 contents))
208 (goto-char (match-beginning 2))
209 (muse-html-insert-anchor (concat "sec" (int-to-string index)))
210 (setq index (1+ index)))))))
211 (setq index 1 contents (reverse contents))
212 (when (> (length contents) 0)
213 (goto-char (point-min))
214 (search-forward "<h2>Recent Work</h2>")
215 (beginning-of-line)
216 (insert "<h2>Contents</h2>\n\n<ul>\n")
217 (dolist (item contents)
218 (insert "<li><a href=\"" (muse-publish-output-name)
219 "#sec" (int-to-string index) "\">"
220 (muse-publish-strip-tags (cdr item))
221 "</a></li>\n")
222 (setq index (1+ index)))
223 (insert "</ul>\n"))))
225 (defun muse-my-html-finalize-buffer ()
226 (when muse-publish-generate-contents
227 (muse-my-html-insert-contents (cdr muse-publish-generate-contents))
228 (setq muse-publish-generate-contents nil)))
230 (defvar muse-my-journal-entries nil)
232 (defun muse-my-journal-find-entries ()
233 (goto-char (point-min))
234 (let ((heading-regexp (concat "^\\* " muse-journal-heading-regexp "$"))
235 (inhibit-read-only t)
236 entries)
237 (while (re-search-forward heading-regexp nil t)
238 (let ((date (match-string 1))
239 (title (match-string-no-properties 2))
240 qotd desc)
241 (save-match-data
242 (when (and date
243 (string-match
244 (concat "\\([1-9][0-9][0-9][0-9]\\)[./]?"
245 "\\([0-1][0-9]\\)[./]?\\([0-3][0-9]\\)") date))
246 (setq date (encode-time 0 0 0
247 (string-to-int (match-string 3 date))
248 (string-to-int (match-string 2 date))
249 (string-to-int (match-string 1 date))
250 (current-time-zone)))))
251 (when title
252 (while (string-match "\\*" title)
253 (setq title (replace-match "" nil nil title)))
254 (set (make-local-variable 'muse-my-journal-entries)
255 (cons (cons title date)
256 muse-my-journal-entries)))))))
258 (defun muse-my-journal-insert-contents ()
259 (goto-char (point-min))
260 (search-forward "<h2>Recent Work</h2>")
261 (beginning-of-line)
262 (if (string= "journal" (muse-page-name))
263 (insert "<h2>Recent Entries</h2>\n\n<ul>\n")
264 (insert "<h2>Contents</h2>\n\n<ul>\n"))
265 (dolist (entry (nreverse muse-my-journal-entries))
266 ;;(setq date (format-time-string "%m/%d" date))
267 ;;(if (= ?0 (aref date 0))
268 ;; (setq date (substring date 1)))
269 (insert (format "<li><a href=\"%s#%s\">%s</a></li>\n"
270 (muse-publish-output-name)
271 (muse-journal-anchorize-title (car entry))
272 (car entry))))
273 (insert "</ul>\n\n"))
275 (eval-when-compile
276 (defvar muse-current-project))
278 (defvar muse-essay-tag '("essay" nil t muse-essay-markup-tag))
280 (defun muse-essay-markup-tag (beg end attrs)
281 "This markup tag allows a poem to be included from another project page.
282 The form of usage is:
283 <essay title=\"page.name\">"
284 (let ((page (cdr (assoc (cdr (assoc "title" attrs))
285 (muse-project-file-alist))))
286 beg start end text)
287 (if (null page)
288 (insert " *Reference to\n unknown essay \""
289 (cdr (assoc "title" attrs)) "\".*\n")
290 (setq beg (point))
291 (insert
292 (with-temp-buffer
293 (insert-file-contents page)
294 (goto-char (point-min))
295 (forward-paragraph)
296 (forward-line)
297 (buffer-substring-no-properties (point) (point-max)))))))
299 (add-to-list 'muse-publish-markup-tags muse-essay-tag)
301 (when (and window-system (load "httpd" t))
302 (require 'muse-http)
303 ;;(add-hook 'after-init-hook 'httpd-start)
304 (setq httpd-document-root (expand-file-name "~/Sites/johnw")))
306 ;;(setq
307 ;; muse-cite-titles
308 ;; '(("Bahá'u'lláh"
309 ;; ("Kitáb-i-Íqán"
310 ;; "http://bahai-library.com/?file=bahaullah_kitab_iqan.html"
311 ;; "http://bahai-library.com/?file=bahaullah_kitab_iqan.html#%d"))
312 ;; ("`Abdu'l-Bahá"
313 ;; ("Promulgation of Universal Peace"
314 ;; "http://bahai-library.com/?file=abdulbaha_promulgation_universal_peace.html"
315 ;; "http://www.bahai-library.com/writings/abdulbaha/pup/pup.html#%d"))))
317 (provide 'muse-init)