* org-publish: Best practice to generate a html header on a per-file basis ?
@ 2011-07-18 21:19 Sander Boer
2011-07-19 16:36 ` Bastien
0 siblings, 1 reply; 2+ messages in thread
From: Sander Boer @ 2011-07-18 21:19 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: org-publish: Best practice to generate a html header on a per-file basis ?
2011-07-18 21:19 org-publish: Best practice to generate a html header on a per-file basis ? Sander Boer
@ 2011-07-19 16:36 ` Bastien
0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2011-07-19 16:36 UTC (permalink / raw)
To: Sander Boer; +Cc: emacs-orgmode@gnu.org
Hi Sander,
Sander Boer <sanboer@gmail.com> writes:
> 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.
Not tested: perhaps you can try to generate the sitemap.org file and
include it into your other Org files with #+INCLUDE?
> 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
You can use
:html-preamble my-cool-function-that-returns-a-string
with no "'"
Note that this function must take no argument and output a string
since the commit I just pushed.
Thanks,
--
Bastien
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-20 13:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-18 21:19 org-publish: Best practice to generate a html header on a per-file basis ? Sander Boer
2011-07-19 16:36 ` Bastien
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).