muse-journal: Publish <qotd> properly for journal-rss and journal-rdf
[muse-el.git] / lisp / muse-journal.el
blobfc79dc2fef1cbc790bf09bba08b48734976ba78f
1 ;;; muse-journal.el --- keep and publish a journal
3 ;; Copyright (C) 2004, 2005, 2006, 2007 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 2, 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 ;; The module facilitates the keeping and publication of a journal.
25 ;; When publishing to HTML, it assumes the form of a web log, or blog.
27 ;; The input format for each entry is as follows:
29 ;; * 20040317: Title of entry
31 ;; Text for the entry.
33 ;; <qotd>
34 ;; "You know who you are. It comes down to a simple gut check: You
35 ;; either love what you do or you don't. Period." -- P. Bronson
36 ;; </qotd>
38 ;; The "qotd", or Quote of the Day, is entirely optional. When
39 ;; generated to HTML, this entry is rendered as:
41 ;; <div class="entry">
42 ;; <div class="entry-qotd">
43 ;; <h3>Quote of the Day:</h3>
44 ;; <p>"You know who you are. It comes down to a simple gut
45 ;; check: You either love what you do or you don't. Period."
46 ;; -- P. Bronson</p>
47 ;; </div>
48 ;; <div class="entry-body">
49 ;; <div class="entry-head">
50 ;; <div class="entry-date">
51 ;; <span class="date">March 17, 2004</span>
52 ;; </div>
53 ;; <div class="entry-title">
54 ;; <h2>Title of entry</h2>
55 ;; </div>
56 ;; </div>
57 ;; <div class="entry-text">
58 ;; <p>Text for the entry.</p>
59 ;; </div>
60 ;; </div>
61 ;; </div>
63 ;; The plurality of "div" tags makes it possible to display the
64 ;; entries in any form you wish, using a CSS style.
66 ;; Also, an .RDF file can be generated from your journal by publishing
67 ;; it with the "rdf" style. It uses the first two sentences of the
68 ;; first paragraph of each entry as its "description", and
69 ;; autogenerates tags for linking to the various entries.
71 ;;; Contributors:
73 ;; René Stadler (mail AT renestadler DOT de) provided a patch that
74 ;; causes dates in RSS feeds to be generated in a format that RSS
75 ;; readers can parse.
77 ;;; Code:
79 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
81 ;; Muse Journal Publishing
83 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
85 (require 'muse-publish)
86 (require 'muse-html)
87 (require 'muse-latex)
88 (require 'muse-book)
90 (defgroup muse-journal nil
91 "Rules for transforming a journal into its final form."
92 :group 'muse-publish)
94 (defcustom muse-journal-heading-regexp
95 "\\(?:\\([0-9]+\\)\\(?:: \\)?\\)?\\(.+?\\)?"
96 "A regexp that matches a journal heading.
97 Paren group 1 is the ISO date, group 2 is the optional category,
98 and group 3 is the optional heading for the entry."
99 :type 'regexp
100 :group 'muse-journal)
102 (defcustom muse-journal-date-format "%a, %e %b %Y"
103 "Date format to use for journal entries."
104 :type 'string
105 :group 'muse-journal)
107 (defcustom muse-journal-html-heading-regexp
108 (concat "^<h2[^>\n]*>" muse-journal-heading-regexp "</h2>$")
109 "A regexp that matches a journal heading from an HTML document.
110 Paren group 1 is the ISO date, group 2 is the optional category,
111 and group 3 is the optional heading for the entry."
112 :type 'regexp
113 :group 'muse-journal)
115 (defcustom muse-journal-rss-heading-regexp
116 (concat "^\\* " muse-journal-heading-regexp "$")
117 "A regexp that matches a journal heading from an HTML document.
118 Paren group 1 is the ISO date, group 2 is the optional category,
119 and group 3 is the optional heading for the entry."
120 :type 'regexp
121 :group 'muse-journal)
123 (defcustom muse-journal-html-entry-template
124 "<div class=\"entry\">
125 <a name=\"%anchor%\" style=\"text-decoration: none\">&nbsp;</a>
126 <div class=\"entry-body\">
127 <div class=\"entry-head\">
128 <div class=\"entry-date\">
129 <span class=\"date\">%date%</span>
130 </div>
131 <div class=\"entry-title\">
132 <h2>%title%</h2>
133 </div>
134 </div>
135 <div class=\"entry-text\">
136 <div class=\"entry-qotd\">
137 <p>%qotd%</p>
138 </div>
139 %text%
140 </div>
141 </div>
142 </div>\n\n"
143 "Template used to publish individual journal entries as HTML.
144 This may be text or a filename."
145 :type 'string
146 :group 'muse-journal)
148 (defcustom muse-journal-latex-section
149 "\\section*{%title% \\hfill {\\normalsize %date%}}
150 \\addcontentsline{toc}{chapter}{%title%}"
151 "Template used to publish a LaTeX section."
152 :type 'string
153 :group 'muse-journal)
155 (defcustom muse-journal-latex-subsection
156 "\\subsection*{%title%}
157 \\addcontentsline{toc}{section}{%title%}"
158 "Template used to publish a LaTeX subsection."
159 :type 'string
160 :group 'muse-journal)
162 (defcustom muse-journal-markup-tags
163 '(("qotd" t nil nil muse-journal-qotd-tag))
164 "A list of tag specifications, for specially marking up Journal entries.
165 See `muse-publish-markup-tags' for more info.
167 This is used by journal-latex and its related styles, as well as
168 the journal-rss-entry style, which both journal-rdf and
169 journal-rss use."
170 :type '(repeat (list (string :tag "Markup tag")
171 (boolean :tag "Expect closing tag" :value t)
172 (boolean :tag "Parse attributes" :value nil)
173 (boolean :tag "Nestable" :value nil)
174 function))
175 :group 'muse-journal)
177 ;; FIXME: This doesn't appear to be used.
178 (defun muse-journal-generate-pages ()
179 (let ((output-dir (muse-style-element :path)))
180 (goto-char (point-min))
181 (while (re-search-forward muse-journal-heading-regexp nil t)
182 (let* ((date (match-string 1))
183 (category (match-string 1))
184 (category-file (concat output-dir category "/index.html"))
185 (heading (match-string 1)))
186 t))))
188 (defcustom muse-journal-rdf-extension ".rdf"
189 "Default file extension for publishing RDF (RSS 1.0) files."
190 :type 'string
191 :group 'muse-journal)
193 (defcustom muse-journal-rdf-base-url ""
194 "The base URL of the website referenced by the RDF file."
195 :type 'string
196 :group 'muse-journal)
198 (defcustom muse-journal-rdf-header
199 "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
200 xmlns=\"http://purl.org/rss/1.0/\"
201 xmlns:dc=\"http://purl.org/dc/elements/1.1/\">
202 <channel rdf:about=\"<lisp>(concat (muse-style-element :base-url)
203 (muse-publish-link-name))</lisp>\">
204 <title><lisp>(muse-publishing-directive \"title\")</lisp></title>
205 <link><lisp>(concat (muse-style-element :base-url)
206 (concat (muse-page-name)
207 muse-html-extension))</lisp></link>
208 <description><lisp>(muse-publishing-directive \"desc\")</lisp></description>
209 <items>
210 <rdf:Seq>
211 <rdf:li resource=\"<lisp>
212 (concat (muse-style-element :base-url)
213 (concat (muse-page-name)
214 muse-html-extension))</lisp>\"/>
215 </rdf:Seq>
216 </items>
217 </channel>\n"
218 "Header used for publishing RDF (RSS 1.0) files.
219 This may be text or a filename."
220 :type 'string
221 :group 'muse-journal)
223 (defcustom muse-journal-rdf-footer
224 "</rdf:RDF>\n"
225 "Footer used for publishing RDF (RSS 1.0) files.
226 This may be text or a filename."
227 :type 'string
228 :group 'muse-journal)
230 (defcustom muse-journal-rdf-date-format
231 "%Y-%m-%dT%H:%M:%S"
232 "Date format to use for RDF entries."
233 :type 'string
234 :group 'muse-journal)
236 (defcustom muse-journal-rdf-entry-template
237 "\n <item rdf:about=\"%link%#%anchor%\">
238 <title>%title%</title>
239 <description>
240 %desc%
241 </description>
242 <link>%link%#%anchor%</link>
243 <dc:date>%date%</dc:date>
244 <dc:creator>%maintainer%</dc:creator>
245 </item>\n"
246 "Template used to publish individual journal entries as RDF.
247 This may be text or a filename."
248 :type 'string
249 :group 'muse-journal)
251 (defcustom muse-journal-rdf-summarize-entries t
252 "If non-nil, include only summaries in the RDF file, not the full data."
253 :type 'boolean
254 :group 'muse-journal)
256 (defcustom muse-journal-rss-extension ".xml"
257 "Default file extension for publishing RSS 2.0 files."
258 :type 'string
259 :group 'muse-journal)
261 (defcustom muse-journal-rss-base-url ""
262 "The base URL of the website referenced by the RSS file."
263 :type 'string
264 :group 'muse-journal)
266 (defcustom muse-journal-rss-header
267 "<\?xml version=\"1.0\" encoding=\"<lisp>
268 (muse-html-encoding)</lisp>\"?>
269 <rss version=\"2.0\">
270 <channel>
271 <title><lisp>(muse-publishing-directive \"title\")</lisp></title>
272 <link><lisp>(concat (muse-style-element :base-url)
273 (concat (muse-page-name)
274 muse-html-extension))</lisp></link>
275 <description><lisp>(muse-publishing-directive \"desc\")</lisp></description>
276 <language>en-us</language>
277 <generator>Emacs Muse</generator>\n\n"
278 "Header used for publishing RSS 2.0 files. This may be text or a filename."
279 :type 'string
280 :group 'muse-journal)
282 (defcustom muse-journal-rss-footer
283 "\n\n </channel>
284 </rss>\n"
285 "Footer used for publishing RSS 2.0 files. This may be text or a filename."
286 :type 'string
287 :group 'muse-journal)
289 (defcustom muse-journal-rss-date-format
290 "%a, %d %b %Y %H:%M:%S %Z"
291 "Date format to use for RSS 2.0 entries."
292 :type 'string
293 :group 'muse-journal)
295 (defcustom muse-journal-rss-entry-template
296 "\n <item>
297 <title>%title%</title>
298 <link>%link%#%anchor%</link>
299 <description>%desc%</description>
300 <author><lisp>(muse-publishing-directive \"author\")</lisp></author>
301 <pubDate>%date%</pubDate>
302 <guid>%link%#%anchor%</guid>
303 %enclosure%
304 </item>\n"
305 "Template used to publish individual journal entries as RSS 2.0.
306 This may be text or a filename."
307 :type 'string
308 :group 'muse-journal)
310 (defcustom muse-journal-rss-enclosure-types-alist
311 '(("mp3" . "audio/mpeg"))
312 "File types that are accepted as RSS enclosures.
313 This is an alist that maps file extension to content type.
314 Useful for podcasting."
315 :type '(alist :key-type string :value-type string)
316 :group 'muse-journal)
318 (defcustom muse-journal-rss-summarize-entries nil
319 "If non-nil, include only summaries in the RSS file, not the full data.
320 Many RSS subscribers find this annoying."
321 :type 'boolean
322 :group 'muse-journal)
324 (defcustom muse-journal-rss-markup-regexps
325 '((10000 muse-explicit-link-regexp 0 "\\2"))
326 "List of markup rules for publishing a Muse journal page to RSS 2.0.
327 For more information on the structure of this list, see
328 `muse-publish-markup-regexps'."
329 :type '(repeat (choice
330 (list :tag "Markup rule"
331 integer
332 (choice regexp symbol)
333 integer
334 (choice string function symbol))
335 function))
336 :group 'muse-journal)
338 (defcustom muse-journal-rss-markup-functions
339 '((email . ignore)
340 (link . ignore)
341 (url . ignore))
342 "An alist of style types to custom functions for that kind of text.
343 For more on the structure of this list, see
344 `muse-publish-markup-functions'."
345 :type '(alist :key-type symbol :value-type function)
346 :group 'muse-journal)
348 (defun muse-journal-anchorize-title (title)
349 (save-match-data
350 (if (string-match "(" title)
351 (setq title (substring title 0 (match-beginning 0))))
352 (if (string-match "<[^>]+>" title)
353 (setq title (replace-match "" nil nil title)))
354 (downcase (muse-replace-regexp-in-string "[^a-zA-Z0-9_]" "" title))))
356 (defun muse-journal-sort-entries (&optional direction)
357 (interactive "P")
358 (sort-subr
359 direction
360 (function
361 (lambda ()
362 (if (re-search-forward "^\\* [0-9]+" nil t)
363 (goto-char (match-beginning 0))
364 (goto-char (point-max)))))
365 (function
366 (lambda ()
367 (if (re-search-forward "^\\* [0-9]+" nil t)
368 (goto-char (1- (match-beginning 0)))
369 (goto-char (point-max)))))
370 (function
371 (lambda ()
372 (forward-char 2)))
373 (function
374 (lambda ()
375 (end-of-line)))))
377 (defun muse-journal-qotd-tag (beg end)
378 (muse-publish-ensure-block beg)
379 (muse-insert-markup (muse-markup-text 'begin-quote))
380 (muse-insert-markup (muse-markup-text 'begin-quote-item))
381 (goto-char end)
382 (muse-insert-markup (muse-markup-text 'end-quote-item))
383 (muse-insert-markup (muse-markup-text 'end-quote)))
385 (defun muse-journal-html-munge-buffer ()
386 (goto-char (point-min))
387 (let ((heading-regexp muse-journal-html-heading-regexp)
388 (inhibit-read-only t))
389 (while (re-search-forward heading-regexp nil t)
390 (let* ((date (match-string 1))
391 (orig-date date)
392 (title (match-string 2))
393 (clean-title title)
394 datestamp qotd text)
395 (delete-region (match-beginning 0) (match-end 0))
396 (if clean-title
397 (save-match-data
398 (while (string-match "\\(^<[^>]+>\\|<[^>]+>$\\)" clean-title)
399 (setq clean-title (replace-match "" nil nil clean-title)))))
400 (save-match-data
401 (when (and date
402 (string-match
403 (concat "\\`\\([1-9][0-9][0-9][0-9]\\)[./]?"
404 "\\([0-1][0-9]\\)[./]?\\([0-3][0-9]\\)") date))
405 (setq datestamp
406 (encode-time
407 0 0 0
408 (string-to-number (match-string 3 date))
409 (string-to-number (match-string 2 date))
410 (string-to-number (match-string 1 date))
411 (current-time-zone))
412 date (concat (format-time-string
413 muse-journal-date-format datestamp)
414 (substring date (match-end 0))))))
415 (save-restriction
416 (narrow-to-region
417 (point) (if (re-search-forward
418 (concat "\\(^<hr>$\\|"
419 heading-regexp "\\)") nil t)
420 (match-beginning 0)
421 (point-max)))
422 (goto-char (point-max))
423 (while (and (not (bobp))
424 (eq ?\ (char-syntax (char-before))))
425 (delete-char -1))
426 (goto-char (point-min))
427 (while (and (not (eobp))
428 (eq ?\ (char-syntax (char-after))))
429 (delete-char 1))
430 (save-excursion
431 (when (search-forward "<qotd>" nil t)
432 (let ((tag-beg (match-beginning 0))
433 (beg (match-end 0))
434 end)
435 (re-search-forward "</qotd>\n*")
436 (setq end (point-marker))
437 (save-restriction
438 (narrow-to-region beg (match-beginning 0))
439 (muse-publish-escape-specials (point-min) (point-max)
440 nil 'document)
441 (setq qotd (buffer-substring-no-properties
442 (point-min) (point-max))))
443 (delete-region tag-beg end))))
444 (setq text (buffer-string))
445 (delete-region (point-min) (point-max))
446 (let ((entry muse-journal-html-entry-template))
447 (muse-insert-file-or-string entry)
448 (muse-publish-mark-read-only (point-min) (point-max))
449 (goto-char (point-min))
450 (while (search-forward "%date%" nil t)
451 (remove-text-properties (match-beginning 0) (match-end 0)
452 '(read-only nil rear-nonsticky nil))
453 (replace-match (or date "") nil t))
454 (goto-char (point-min))
455 (while (search-forward "%title%" nil t)
456 (remove-text-properties (match-beginning 0) (match-end 0)
457 '(read-only nil rear-nonsticky nil))
458 (replace-match (or title "&nbsp;") nil t))
459 (goto-char (point-min))
460 (while (search-forward "%anchor%" nil t)
461 (replace-match (muse-journal-anchorize-title
462 (or clean-title orig-date))
463 nil t))
464 (goto-char (point-min))
465 (while (search-forward "%qotd%" nil t)
466 (save-restriction
467 (narrow-to-region (match-beginning 0) (match-end 0))
468 (delete-region (point-min) (point-max))
469 (when qotd (muse-insert-markup qotd))))
470 (goto-char (point-min))
471 (while (search-forward "%text%" nil t)
472 (remove-text-properties (match-beginning 0) (match-end 0)
473 '(read-only nil rear-nonsticky nil))
474 (replace-match text nil t))
475 (when (null qotd)
476 (goto-char (point-min))
477 (when (search-forward "<div class=\"entry-qotd\">" nil t)
478 (let ((beg (match-beginning 0)))
479 (re-search-forward "</div>\n*" nil t)
480 (delete-region beg (point))))))))))
481 ;; indicate that we are to continue the :before-end processing
482 nil)
484 (defun muse-journal-latex-munge-buffer ()
485 (goto-char (point-min))
486 (let ((heading-regexp
487 (concat "^" (regexp-quote (muse-markup-text 'section))
488 muse-journal-heading-regexp
489 (regexp-quote (muse-markup-text 'section-end)) "$"))
490 (inhibit-read-only t))
491 (when (re-search-forward heading-regexp nil t)
492 (goto-char (match-beginning 0))
493 (sort-subr nil
494 (function
495 (lambda ()
496 (if (re-search-forward heading-regexp nil t)
497 (goto-char (match-beginning 0))
498 (goto-char (point-max)))))
499 (function
500 (lambda ()
501 (if (re-search-forward heading-regexp nil t)
502 (goto-char (1- (match-beginning 0)))
503 (goto-char (point-max)))))
504 (function
505 (lambda ()
506 (forward-char 2)))
507 (function
508 (lambda ()
509 (end-of-line)))))
510 (while (re-search-forward heading-regexp nil t)
511 (let ((date (match-string 1))
512 (title (match-string 2))
513 ;; FIXME: Nothing is done with qotd
514 qotd section)
515 (save-match-data
516 (when (and date
517 (string-match
518 (concat "\\([1-9][0-9][0-9][0-9]\\)[./]?"
519 "\\([0-1][0-9]\\)[./]?\\([0-3][0-9]\\)") date))
520 (setq date (encode-time
521 0 0 0
522 (string-to-number (match-string 3 date))
523 (string-to-number (match-string 2 date))
524 (string-to-number (match-string 1 date))
525 (current-time-zone))
526 date (format-time-string
527 muse-journal-date-format date))))
528 (save-restriction
529 (narrow-to-region (match-beginning 0) (match-end 0))
530 (delete-region (point-min) (point-max))
531 (muse-insert-markup muse-journal-latex-section)
532 (goto-char (point-min))
533 (while (search-forward "%title%" nil t)
534 (replace-match (or title "Untitled") nil t))
535 (goto-char (point-min))
536 (while (search-forward "%date%" nil t)
537 (replace-match (or date "") nil t))))))
538 (goto-char (point-min))
539 (let ((subheading-regexp
540 (concat "^" (regexp-quote (muse-markup-text 'subsection))
541 "\\([^\n}]+\\)"
542 (regexp-quote (muse-markup-text 'subsection-end)) "$"))
543 (inhibit-read-only t))
544 (while (re-search-forward subheading-regexp nil t)
545 (let ((title (match-string 1)))
546 (save-restriction
547 (narrow-to-region (match-beginning 0) (match-end 0))
548 (delete-region (point-min) (point-max))
549 (muse-insert-markup muse-journal-latex-subsection)
550 (goto-char (point-min))
551 (while (search-forward "%title%" nil t)
552 (replace-match title nil t))))))
553 ;; indicate that we are to continue the :before-end processing
554 nil)
556 (defun muse-journal-rss-munge-buffer ()
557 (goto-char (point-min))
558 (let ((heading-regexp muse-journal-rss-heading-regexp)
559 (inhibit-read-only t))
560 (while (re-search-forward heading-regexp nil t)
561 (let* ((date (match-string 1))
562 (orig-date date)
563 (title (match-string 2))
564 ;; FIXME: Nothing is done with qotd
565 enclosure qotd desc)
566 (if title
567 (save-match-data
568 (if (string-match muse-explicit-link-regexp title)
569 (setq enclosure (muse-get-link title)
570 title (muse-get-link-desc title)))))
571 (save-match-data
572 (when (and date
573 (string-match
574 (concat "\\([1-9][0-9][0-9][0-9]\\)[./]?"
575 "\\([0-1][0-9]\\)[./]?\\([0-3][0-9]\\)") date))
576 (setq date (encode-time 0 0 0
577 (string-to-number (match-string 3 date))
578 (string-to-number (match-string 2 date))
579 (string-to-number (match-string 1 date))
580 (current-time-zone))
581 ;; make sure that date is in a format that RSS
582 ;; readers can handle
583 date (let ((system-time-locale "C"))
584 (format-time-string
585 (muse-style-element :date-format) date)))))
586 (save-restriction
587 (narrow-to-region
588 (match-beginning 0)
589 (if (re-search-forward heading-regexp nil t)
590 (match-beginning 0)
591 (if (re-search-forward "^Footnotes:" nil t)
592 (match-beginning 0)
593 (point-max))))
594 (goto-char (point-min))
595 (delete-region (point) (muse-line-end-position))
596 (re-search-forward "</qotd>\n+" nil t)
597 (while (and (char-after)
598 (eq ?\ (char-syntax (char-after))))
599 (delete-char 1))
600 (let ((beg (point)))
601 (if (muse-style-element :summarize)
602 (progn
603 (forward-sentence 2)
604 (setq desc (concat (buffer-substring beg (point)) "...")))
605 (save-restriction
606 (muse-publish-markup-buffer "rss-entry" "journal-rss-entry")
607 (goto-char (point-min))
608 (if (re-search-forward "Page published by Emacs Muse" nil t)
609 (goto-char (muse-line-end-position))
610 (muse-display-warning
611 (concat
612 "Cannot find 'Page published by Emacs Muse begins here'.\n"
613 "You will probably need this text in your header."))
614 (goto-char (point-min)))
615 (setq beg (point))
616 (if (re-search-forward "Page published by Emacs Muse" nil t)
617 (goto-char (muse-line-beginning-position))
618 (muse-display-warning
619 (concat
620 "Cannot find 'Page published by Emacs Muse ends here'.\n"
621 "You will probably need this text in your footer."))
622 (goto-char (point-max)))
623 (setq desc (concat "<![CDATA[" (buffer-substring beg (point))
624 "]]>")))))
625 (delete-region (point-min) (point-max))
626 (let ((entry (muse-style-element :entry-template)))
627 (muse-insert-file-or-string entry)
628 (goto-char (point-min))
629 (while (search-forward "%date%" nil t)
630 (replace-match (or date "") nil t))
631 (goto-char (point-min))
632 (while (search-forward "%title%" nil t)
633 (replace-match "")
634 (save-restriction
635 (narrow-to-region (point) (point))
636 (insert (or title "Untitled"))
637 (remove-text-properties (match-beginning 0) (match-end 0)
638 '(read-only nil rear-nonsticky nil))
639 (let ((muse-publishing-current-style (muse-style "html")))
640 (muse-publish-escape-specials (point-min) (point-max)
641 nil 'document))))
642 (goto-char (point-min))
643 (while (search-forward "%desc%" nil t)
644 (replace-match desc nil t))
645 (goto-char (point-min))
646 (while (search-forward "%enclosure%" nil t)
647 (replace-match
648 (if (null enclosure)
650 (save-match-data
651 (format
652 "<enclosure url=\"%s\" %stype=\"%s\"/>"
653 (if (string-match "//" enclosure)
654 enclosure
655 (concat (muse-style-element :base-url)
656 enclosure))
657 (let ((file
658 (expand-file-name enclosure
659 (muse-style-element :path))))
660 (if (file-readable-p file)
661 (format "length=\"%d\" "
662 (nth 7 (file-attributes file)))
663 ""))
664 (if (string-match "\\.\\([^.]+\\)$" enclosure)
665 (let* ((ext (match-string 1 enclosure))
666 (type
667 (assoc
668 ext muse-journal-rss-enclosure-types-alist)))
669 (if type
670 (cdr type)
671 "application/octet-stream"))))))
672 nil t))
673 (goto-char (point-min))
674 (while (search-forward "%link%" nil t)
675 (replace-match
676 (concat (muse-style-element :base-url)
677 (concat (muse-page-name)
678 muse-html-extension))
679 nil t))
680 (goto-char (point-min))
681 (while (search-forward "%anchor%" nil t)
682 (replace-match
683 (muse-journal-anchorize-title (or title orig-date))
684 nil t))
685 (goto-char (point-min))
686 (while (search-forward "%maintainer%" nil t)
687 (replace-match
688 (or (muse-style-element :maintainer)
689 (concat "webmaster@" (system-name)))
690 nil t)))))))
691 ;; indicate that we are to continue the :before-end processing
692 nil)
695 ;;; Register the Muse Journal Publishers
697 (muse-derive-style "journal-html" "html"
698 :before-end 'muse-journal-html-munge-buffer)
700 (muse-derive-style "journal-xhtml" "xhtml"
701 :before-end 'muse-journal-html-munge-buffer)
703 (muse-derive-style "journal-latex" "latex"
704 :tags 'muse-journal-markup-tags
705 :before-end 'muse-journal-latex-munge-buffer)
707 (muse-derive-style "journal-pdf" "pdf"
708 :tags 'muse-journal-markup-tags
709 :before-end 'muse-journal-latex-munge-buffer)
711 (muse-derive-style "journal-book-latex" "book-latex"
712 ;;:nochapters
713 :tags 'muse-journal-markup-tags
714 :before-end 'muse-journal-latex-munge-buffer)
716 (muse-derive-style "journal-book-pdf" "book-pdf"
717 ;;:nochapters
718 :tags 'muse-journal-markup-tags
719 :before-end 'muse-journal-latex-munge-buffer)
721 (muse-define-style "journal-rdf"
722 :suffix 'muse-journal-rdf-extension
723 :regexps 'muse-journal-rss-markup-regexps
724 :functions 'muse-journal-rss-markup-functions
725 :before 'muse-journal-rss-munge-buffer
726 :header 'muse-journal-rdf-header
727 :footer 'muse-journal-rdf-footer
728 :date-format 'muse-journal-rdf-date-format
729 :entry-template 'muse-journal-rdf-entry-template
730 :base-url 'muse-journal-rdf-base-url
731 :summarize 'muse-journal-rdf-summarize-entries)
733 (muse-define-style "journal-rss"
734 :suffix 'muse-journal-rss-extension
735 :regexps 'muse-journal-rss-markup-regexps
736 :functions 'muse-journal-rss-markup-functions
737 :before 'muse-journal-rss-munge-buffer
738 :header 'muse-journal-rss-header
739 :footer 'muse-journal-rss-footer
740 :date-format 'muse-journal-rss-date-format
741 :entry-template 'muse-journal-rss-entry-template
742 :base-url 'muse-journal-rss-base-url
743 :summarize 'muse-journal-rss-summarize-entries)
745 ;; Used by `muse-journal-rss-munge-buffer' to mark up individual entries
746 (muse-derive-style "journal-rss-entry" "html"
747 :tags 'muse-journal-markup-tags)
749 (provide 'muse-journal)
751 ;;; muse-journal.el ends here