[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Re: Fully featured Web publishing

From: Carsten Dominik
Subject: Re: [Orgmode] Re: Fully featured Web publishing
Date: Sat, 18 Apr 2009 13:04:07 +0200

Hi Tomas,

if you have or will sign a copyright assignment, I'd be happy to accept
a patch to this effect.

- Carsten

On Apr 18, 2009, at 11:23 AM, Tomas Hlavaty wrote:

Hi all,

thanks for the excelent org-mode;-)

Automatical computing of navigations is not possible (yet).

There is a way of achieving this:

1. define and use function my-org-publish-org-to-html which determines
  what directory level we are on and then calls the original
  org-publish-org-to-html function

2. define and use my-org-preamble which inserts the preamble based on
  the directory level computed above

3. patch org-export-as-html so that the config parameters :style and
  :preamble can be functions as well as strings.

Here is rough code.


        :publishing-function my-org-publish-org-to-html
        :style my-org-style
        :preamble my-org-preamble

The "user" code:

(defun my-org-publish-org-to-html (plist filename pubdir)
 (let* ((dir (file-name-as-directory
              (file-truename (plist-get plist :base-directory))))
        (fname (file-truename filename))
        (rel (substring fname (length dir)))
           (loop for x in (split-string rel "")
              count (and (stringp x) (string= "/" x)))))
   (org-publish-org-to-html plist filename pubdir)))

(defun my-org-preamble ()
 (let ((pre (apply 'concat
(loop for i from 1 upto *org-publish-level* collect "../"))))
   (insert "
<div id=\"menu\">
<a href=\"" pre "index.html\">Home</a>
| <a href=\"" pre "sw/index.html\">Software</a>
| <a href=\"" pre "blog/index.html\">Blog</a>
| <a href=\"" pre "contact.html\">Contact</a>
| <a href=\"" pre "sitemap.html\">Site Map</a>

(defun my-org-style ()
 (let ((pre (apply 'concat
(loop for i from 1 upto *org-publish-level* collect "../"))))
   (concat "
<link rel=\"stylesheet\" href=\"" pre "style.css\" type=\"text/css\"/>
<link rel=\"icon\" href=\"" pre "favicon.ico\" type=\"image/x-icon\"/>
<link rel=\"shortcut icon\" href=\"" pre "favicon.ico\" type=\"image/ x-icon\"/>")))

The "patched" code in org-export-as-html:

@@ -465,7 +465,12 @@ PUB-DIR is set, use this as the publishing directory."
         (style (concat (if (plist-get opt-plist :style-include-default)
-                       (plist-get opt-plist :style)
+            ;;; THL Changed !!!
+                       (let ((s (plist-get opt-plist :style)))
+              (cond
+               ((and s (stringp s)) s)
+               (s (funcall s))))
+            ;;;(plist-get opt-plist :style)
                        (plist-get opt-plist :style-extra)
                        (if (plist-get opt-plist :style-include-scripts)
@@ -664,7 +669,12 @@ lang=\"%s\" xml:lang=\"%s\">
                 date author description keywords

-       (insert (or (plist-get opt-plist :preamble) ""))
+    ;; THL Changed !!!
+    (let ((preamble (plist-get opt-plist :preamble)))
+      (cond
+       ((and preamble (stringp preamble)) (insert preamble))
+       (preamble (funcall preamble))))
+       ;;(insert (or (plist-get opt-plist :preamble) ""))

        (when (plist-get opt-plist :auto-preamble)
          (if title (insert (format org-export-html-title-format

I think that in general, the org-mode configuration
(org-publish-project-alist) would be more flexible/user programable if
the config parameters could also be functions (i.e. not limited to
strings only).  Any ideas whether and how to improve and make the
above functionality available in the official release?

Thank you,


Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]