From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomas Hlavaty Subject: Re: Re: Fully featured Web publishing Date: Sat, 18 Apr 2009 10:23:07 +0100 Message-ID: <87d4ba71tw.fsf@logand.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lv6ld-0002Xb-P3 for emacs-orgmode@gnu.org; Sat, 18 Apr 2009 05:23:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lv6lc-0002XM-RZ for emacs-orgmode@gnu.org; Sat, 18 Apr 2009 05:23:21 -0400 Received: from [199.232.76.173] (port=43018 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lv6lc-0002XJ-MO for emacs-orgmode@gnu.org; Sat, 18 Apr 2009 05:23:20 -0400 Received: from smtp.seznam.cz ([77.75.72.43]:51982) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lv6lc-0001ZK-0j for emacs-orgmode@gnu.org; Sat, 18 Apr 2009 05:23:20 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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. Configuration: :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))) (*org-publish-level* (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 "
"))) (defun my-org-style () (let ((pre (apply 'concat (loop for i from 1 upto *org-publish-level* collect "../")))) (concat " "))) The "patched" code in org-export-as-html: @@ -465,7 +465,12 @@ PUB-DIR is set, use this as the publishing directory." (org-infile-export-plist)))) (style (concat (if (plist-get opt-plist :style-include-default) org-export-html-style-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) "\n" (if (plist-get opt-plist :style-include-scripts) @@ -664,7 +669,12 @@ lang=\"%s\" xml:lang=\"%s\"> date author description keywords style)) - (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, Tomas