Re: [Orgmode] Re: Fully featured Web publishing

2009-04-18 Thread Carsten Dominik

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.

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 "

Home
| Software
| Blog
| Contact
| Site Map


")))

(defun my-org-style ()
 (let ((pre (apply 'concat
   (loop for i from 1 upto *org-publish-level* collect  
"../"

   (concat "


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


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode




___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Fully featured Web publishing

2009-04-18 Thread Tomas Hlavaty
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 "

Home
| Software
| Blog
| Contact
| Site Map


")))

(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


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: Fully featured Web publishing

2009-03-23 Thread Taru Karttunen
Hello

Here is a simple solution, have a menu like:

--8<---cut here---start->8---
   
   Navigation

Home
CV
Contact Me

   
--8<---cut here---end--->8---

And simply have inside curriculum-vitae.org:
#+STYLE: a#navigation-cv { color: red }

inside contact-me.org:
#+STYLE: a#navigation-contact-me { color: red }

etc

Setting the correct style can also be automated with suitable
Javascript.

- Taru Karttunen


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: Fully featured Web publishing

2009-03-23 Thread Sébastien Vauban
Hello,

>> Because the OP wants to include the same menu on every page.

To better explain my problem:

1. I would like to define my navigation menu once (as some "variable" of the
   project). For example:

--8<---cut here---start->8---
   (setq nav-menu '(("Home" .  "index.html")
("About Me" .  ( ("CV" . 
"curriculum-vitae.html")
 ("Contact Me" . "contact-me.html")))
("Resources" . ( ("Freeware"   . "freeware.html")
 ("Emacs"  . "dot-emacs.html")
--8<---cut here---end--->8---


2. I would like this to be converted to HTML for each page, but with a "mark"
   that indicates which page is generated (for the CSS to be able to
   highlight, in the navigation menu, the page that's currently displayed in
   the browser).

   For example, for my home page:

--8<---cut here---start->8---
   
   Navigation
   
 Home
 

 About Me
   
 CV
 Contact Me
   
 

 Resources
   
 Freeware
 Emacs
   
 
   
   
--8<---cut here---end--->8---

   and for my CV:

--8<---cut here---start->8---
   
   Navigation
   
 Home
 

 About Me
   
 CV
   
 Contact Me
   
 

 Resources
   
 Freeware
 Emacs
   
 
   
   
--8<---cut here---end--->8---

So, the question narrows down to: is there a hook available where the correct
code could be placed to achieve such a result?

Thanks a lot,
  Seb

-- 
Sébastien Vauban


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Fully featured Web publishing

2009-03-19 Thread Matthew Lundin
Richard Riley  writes:

>>> Why not us preamble?
>>>
>>> I'm not sure if its an approved way or not but has done for me for a site
>>> wide addition for a while now but I must admit to not being up to date
>>> with all latest and greatest innovations.
>>>
>>> http://richardriley.net/projects/emacs/dotorg.html

> It seemed the best way to do it at the time. What is the better way?
> At the time I asked about a header and footer which is fairly common
> and decided to use preamble and postamble to effectively act as common
> header and footer components. Prior to the "id=content" modifications
> (container) I also used to introduce the "content"container using
> preamble and postamble too (e.preamble opening the div and postamble
> closing it).

To chime in here, this is precisely how I create the menu on my website:

http://faculty.valpo.edu/mlundin/

In my org-publish-project-alist I have the following:

,
| [snip]
| :preamble "
| 
| 
| Home |
| Site Map
| 
| 
| Matthew Lundin
| 
| 
| "
| :postamble ""
| [snip]
`

The preamble is placed directly beneath the  tag.

I use to add a couple of extra wrapper divs, but with the new default
content div, I only add one. 

Obviously, one could get a lot more elaborate with this.

Best,
Matt


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: Fully featured Web publishing

2009-03-19 Thread Sébastien Vauban
Hi all,

Thanks for your input...

Rasmus Pank Roulund wrote:
>> Why not us preamble?
>
> Because the OP wants to include the same menu on every page. If you input
> the file you will only have to update one file and the other files will be
> updated.

I can't use your solutions, as the navigation menu is almost identical, but it
is not completely: the keyword `current' has to be appended to the entry the
page is about.

>>   The only real problem that I see (the above being nice-to-have's) is the
>>   following: I want to have a common navigation menu, but whose current
>>   page is highlighted. To do so, I just have to add the class `current' to
>>   the current entry, but this means the navigation menu is not constant
>>   between pages!

For example, my menu will be this one for the _home page_:

--8<---cut here---start->8---

Navigation

Home
 
About Me

CV
PGP Public 
Key
Contact Me


Resources

Freeware
Emacs




--8<---cut here---end--->8---

and this one for my _CV_:

--8<---cut here---start->8---

Navigation

Home
About Me

CV
  
PGP Public 
Key
Contact Me


Resources

Freeware
Emacs




--8<---cut here---end--->8---

The skeleton is static, but the instantiated navigation menu for a specific
page should be computed automatically, when publishing...

I hope I now have clearly expressed my point. If yes, do you see any solution
for me?

Best regards,
  Seb

-- 
Sébastien Vauban


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Fully featured Web publishing

2009-03-19 Thread Sebastian Rose
Richard Riley  writes:
> Is it a trick though?

Sorry, I mixed German and English here. I German a 'Trick' is primarily
a _positive_ thing.

If you want to turn it into something (slightly) negative, you say
'fauler Trick' here :)

(literally: 'lazy trick')



-- 
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.:  +49 (0)511 - 36 58 472
Fax:   +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http:  www.emma-stil.de


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Fully featured Web publishing

2009-03-19 Thread Richard Riley
Sebastian Rose  writes:

> Richard Riley  writes:
>> Why not us preamble?
>>
>> I'm not sure if its an approved way or not but has done for me for a site
>> wide addition for a while now but I must admit to not being up to date
>> with all latest and greatest innovations.
>>
>> http://richardriley.net/projects/emacs/dotorg.html
>
> Nice trick. We have to put this into the publishing tutorial!

Is it a trick though? It seemed the best way to do it at the time. What
is the better way? At the time I asked about a header and footer which
is fairly common and decided to use preamble and postamble to
effectively act as common header and footer components. Prior to the
"id=content" modifications (container) I also used to introduce the
"content"container using preamble and postamble too (e.preamble opening
the div and postamble closing it).

regards,

r.


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Fully featured Web publishing

2009-03-19 Thread Sebastian Rose
Richard Riley  writes:
> Why not us preamble?
>
> I'm not sure if its an approved way or not but has done for me for a site
> wide addition for a while now but I must admit to not being up to date
> with all latest and greatest innovations.
>
> http://richardriley.net/projects/emacs/dotorg.html

Nice trick. We have to put this into the publishing tutorial!



BTW: here is bug in the docs:

C-h v org-preamble TAB RET

   org-export-html-preamble is a variable defined in `org-exp.el'.
   Its value is nil

   Documentation:
   Preamble, to be inserted just before .  Set by publishing functions.


Should be:

   org-export-html-preamble is a variable defined in `org-exp.el'.
   Its value is nil

   Documentation:
   Preamble, to be inserted just after .  Set by publishing functions.





Regards,

   Sebastian


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Fully featured Web publishing

2009-03-19 Thread Richard Riley
Rasmus Pank Roulund  writes:

>> Why not us preamble?
>
> I am not sure I understand you question, but:
> Because the OP wants to include the same menu on every page. If you
> input the file you will only have to update one file and the other files
> will be updated. 

with preamble you do it across the web with one change in your project
definition and since it is across the web it seems appropriate to be
part of the org project definition.


I included a link to an example.

>
>
>
> ___
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>

-- 


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: Fully featured Web publishing

2009-03-19 Thread Rasmus Pank Roulund
> Why not us preamble?

I am not sure I understand you question, but:
Because the OP wants to include the same menu on every page. If you
input the file you will only have to update one file and the other files
will be updated. 



___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Fully featured Web publishing

2009-03-18 Thread Richard Riley

Rasmus Pank Roulund  writes:

> I have done something similar. I have a single menu file which I
> include on every page. 
> #+INCLUDE:menu.org
>
> Would that solve you problem?
>
> -Rasmus

Why not us preamble?

I'm not sure if its an approved way or not but has done for me for a site
wide addition for a while now but I must admit to not being up to date
with all latest and greatest innovations.

http://richardriley.net/projects/emacs/dotorg.html




___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: Fully featured Web publishing

2009-03-18 Thread Rasmus Pank Roulund
I have done something similar. I have a single menu file which I
include on every page. 
#+INCLUDE:menu.org

Would that solve you problem?

-Rasmus



___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Re: [Orgmode] Re: Fully featured Web publishing

2009-03-18 Thread Sebastian Rose
Sébastien Vauban  writes:
> Thanks for the other (useful) info. But, here, your answer is not adequate as
> I don't want to have almost identical information duplicated in each page of
> my site. Just imagine the pain it is if I want to change the structure (adding
> a new page in my menu -- I have to update all my pages!).


I understand. Use `#+SETUPFILE' for that reason.


Automatical computing of navigations is not possible (yet).


> The trick I used with Muse was to make that automatically computed:
>
> o   having a menu defined only once;
>
> o   per page, adding the `current' keyword on the adequate item --
> automatically done by the above function.
>
> Adding a page in my Web site means just updating one variable: the menu
> definition. Nothing more to do...
>
> Is there, then, a similar solution?  Or, at least, one achieving the same
> results by other means?
>
> Best regards,
>   Seb


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


[Orgmode] Re: Fully featured Web publishing

2009-03-18 Thread Sébastien Vauban
Hi Sebastian,

Sebastian Rose wrote:
> Sébastien Vauban  writes:
>> I'd like to use Org exclusively for composing and then publishing my Web 
>> site.
>> I've done it so far with Emacs Muse, but I have a strong deepish attraction 
>> to
>> go the Org way, for many different reasons you must be aware of -- more than 
>> I
>> am...
>>
>>   [...]
>>
>>   The only real problem that I see (the above being nice-to-have's) is the
>>   following: I want to have a common navigation menu, but whose current
>>   page is highlighted. To do so, I just have to add the class `current' to
>>   the current entry, but this means the navigation menu is not constant
>>   between pages!
>>
>>   I did that with Muse doing so:
>>
>>   (setq nav-menu '((\"Home\" .\"index.html\")
>>(\"About Me\" .( (\"CV\" . 
>> \"curriculum-vitae.html\")
>>   (\"PGP Public Key\" . 
>> \"pgp-public-key.html\")
>>   (\"Contact Me\" . 
>> \"contact-me.html\")))
>>(\"Resources\" .   ( (\"Ubuntu\" . 
>> \"ubuntu.html\")
>>   (\"Emacs\"  . 
>> \"dot-emacs.html\")
>>
>>   and in the footer file:
>>
>> 
>> Navigation
>> (my-muse-generate-nav-menu)
>> 
>>
>>   with:
>>
>> (defun my-muse-generate-nav-menu ()
>>  [...]
>> (if (string-match
>>  (concat ".*" (cdr (car 
>> nav-submenu)) "$")
>>  cur-path-html)
>> " class=\"current\""
>>   "")
>>  [...]
>>
>>   How can I do such a thing in Org?
>
> #+begin_html
>
>   your menu here
>
> #+end_html

Thanks for the other (useful) info. But, here, your answer is not adequate as
I don't want to have almost identical information duplicated in each page of
my site. Just imagine the pain it is if I want to change the structure (adding
a new page in my menu -- I have to update all my pages!).

The trick I used with Muse was to make that automatically computed:

o   having a menu defined only once;

o   per page, adding the `current' keyword on the adequate item --
automatically done by the above function.

Adding a page in my Web site means just updating one variable: the menu
definition. Nothing more to do...

Is there, then, a similar solution?  Or, at least, one achieving the same
results by other means?

Best regards,
  Seb

-- 
Sébastien Vauban


___
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode