emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tomas Hlavaty <kvietaag@seznam.cz>
To: emacs-orgmode@gnu.org
Subject: Re: Re: Fully featured Web publishing
Date: Sat, 18 Apr 2009 10:23:07 +0100	[thread overview]
Message-ID: <87d4ba71tw.fsf@logand.com> (raw)

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 "
<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>
</div>
<div>
")))

(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."
 			       (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

             reply	other threads:[~2009-04-18  9:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-18  9:23 Tomas Hlavaty [this message]
2009-04-18 11:04 ` Re: Fully featured Web publishing Carsten Dominik
  -- strict thread matches above, loose matches on Subject: below --
2009-03-18 16:04 Sébastien Vauban
2009-03-18 16:57 ` Sebastian Rose
2009-03-18 21:20   ` Sébastien Vauban
2009-03-18 22:38     ` Sebastian Rose
2009-03-18 22:56       ` Rasmus Pank Roulund
2009-03-18 23:19         ` Richard Riley
2009-03-19  7:46           ` Rasmus Pank Roulund
2009-03-19  8:28             ` Richard Riley
2009-03-19 10:37           ` Sebastian Rose
2009-03-19 13:38             ` Richard Riley
2009-03-19 15:03               ` Sebastian Rose
2009-03-19 16:12               ` Matthew Lundin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d4ba71tw.fsf@logand.com \
    --to=kvietaag@seznam.cz \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).