emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sander Boer <sanboer@gmail.com>
To: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: org-publish: Best practice to generate a html header on a per-file basis ?
Date: Mon, 18 Jul 2011 23:19:13 +0200	[thread overview]
Message-ID: <BA158CCC-AC04-4E8C-B8B4-2D8FE4DEF6F5@gmail.com> (raw)


Hi all,

I've been investigating a viable way to generate for every exported html file in an org-publish project a list of links to all the other html files in the directory-tree and I'm stuck.
I want this list to be inserted as a header, nicely css-ed into a navigation bar.

The idea is to graft a function that is either passed to :html-preamble or is added as a hook to org-export-html-final-hook.
Incidently, it took a long time to figure out that one cannot pass mere functions to html-preamble like this:
:html-preamble 'my-cool-function-that-returns-a-string
nor like this:
:html-preamble 'my-cool-function-that-*inserts*-a-string

instead it needs to be:
:html-preamble (lambda(x) (insert (my-cool-function-that-returns-a-string x)))
or,
:html-preamble (lambda(x) (my-cool-function-that-inserts-a-string x))


Anyway, with that out of the way, now I am left with the challenge of figuring out how to determine the position of this file with regard to the other files in the project, file-relative-name really comes in handy here. The issue for me is that the html-preamble and the ....-final-hook are called in the html buffer. It is easier to graft a link list based on the original org-tree than on the exported html-tree, as path-changes would cause issues.
So the idea is now to find the path to the original org-file and construct a link list based on the original org-publish tree (cunningly renaming .org into .html)
Alternatively, how about extending the sitemap generator to generate a link-list for every file like so:
file.org-> file.inc file.html
file.inc would only consist of:
<div id="linklist">
<a href=../projects/randomproject.html>cool project</a>
<a href=../contact/about.html>all me</a>
<a href=../../index.html>home</a>
</div>
(hmm bad example, it also needs some form of ul/li grouping based on subdirectory, but you get the idea)

Any and all tips and pointers are appreciated.

sndr

             reply	other threads:[~2011-07-18 21:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18 21:19 Sander Boer [this message]
2011-07-19 16:36 ` org-publish: Best practice to generate a html header on a per-file basis ? Bastien

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=BA158CCC-AC04-4E8C-B8B4-2D8FE4DEF6F5@gmail.com \
    --to=sanboer@gmail.com \
    --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).