Enable additional options for JavaScript org-info.js

This commit is contained in:
Carsten Dominik 2008-04-16 10:34:55 +02:00
parent e533bfaadf
commit 8489632557
2 changed files with 49 additions and 14 deletions

View File

@ -6772,18 +6772,26 @@ needed to invoke the script. Using the line above, you can set the following
viewing options: viewing options:
@example @example
path: @r{The path to the script. The default is to grab the script from}
@r{@url{http://orgmode.org/org-info.js}, but you might want to have}
@r{a local copy and use a path like @samp{../scripts/org-info.js}.}
view: @r{Initial view when website is first shown. Possible values are} view: @r{Initial view when website is first shown. Possible values are}
info @r{Info-like interface with one section per page.} info @r{Info-like interface with one section per page.}
overview @r{Folding interface, initially showing only top-level.} overview @r{Folding interface, initially showing only top-level.}
content @r{Folding interface, starting with all headlines visible.} content @r{Folding interface, starting with all headlines visible.}
showall @r{Folding interface, all headlines and text visible.} showall @r{Folding interface, all headlines and text visible.}
toc: @r{Should the table of content be visible as the first section?} sdepth: @r{Maximum headline level that will still become an independent}
@r{section for info and folding modes. The default is taken from}
@r{@code{org-headline-levels} (= the @code{H} @code{#+OPTIONS} switch).}
@r{If this is smaller than in @code{org-headline-levels}, each}
@r{info/folding section can still contain children headlines.}
@r{Default is @code{org-headline-levels} (= the @code{H} @code{#+OPTIONS} switch).}
toc: @r{Should the table of content @emph{initially} be visible?}
@r{Even when @code{nil}, you can always get to the toc with @kbd{i}.} @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
ltoc: @r{Should there be short contents in each section?} tdepth: @r{The depth of the table of contents. The defaults are taken from}
path: @r{The path to the script. The default is to grab the script from} @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
@r{@url{http://orgmode.org/org-info.js}, but you might want to have} ltoc: @r{Should there be short contents (children) in each section?}
@r{a local copy use a path like @samp{../scripts/org-info.js}.} mouse: @r{Headings are highlighted when the mouse is over themq. Should be}
mouse: @r{Headings are highlighted when the mouse is over the. Should be}
@r{@samp{underline} (default) or a background color like @samp{#cccccc}.} @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
buttons: @r{Should view-toggle buttons be everywhere? When @code{nil} (the} buttons: @r{Should view-toggle buttons be everywhere? When @code{nil} (the}
@r{default), only one such button will be present.} @r{default), only one such button will be present.}

View File

@ -68,6 +68,8 @@ line in the buffer. See also the variable `org-infojs-options'."
'((path PATH "http://orgmode.org/org-info.js") '((path PATH "http://orgmode.org/org-info.js")
(view VIEW "info") (view VIEW "info")
(toc TOC :table-of-contents) (toc TOC :table-of-contents)
(tdepth TOC_DEPTH "max")
(sdepth SECTION_DEPTH "max")
(mouse MOUSE_HINT "underline") (mouse MOUSE_HINT "underline")
(runs MAX_RUNS "5") (runs MAX_RUNS "5")
(buttons VIEW_BUTTONS "0") (buttons VIEW_BUTTONS "0")
@ -83,13 +85,19 @@ line in the buffer. See also the variable `org-infojs-options'."
Each of the options must have an entry in `org-export-html/infojs-opts-table'. Each of the options must have an entry in `org-export-html/infojs-opts-table'.
The value can either be a string that will be passed to the script, or The value can either be a string that will be passed to the script, or
a property. This property is then assumed to be a property that is defined a property. This property is then assumed to be a property that is defined
by the Export/Publishing setup of Org." by the Export/Publishing setup of Org.
The `sdepth' and `tdepth' parameters can also be set to \"max\", which
means to use the maximum value consistent with other options."
:group 'org-infojs :group 'org-infojs
:type :type
'(repeat `(set :greedy t :inline t
(cons (symbol :tag "Option") ,@(mapcar
(choice (symbol :tag "Publishing/Export property") (lambda (x)
(string :tag "Value"))))) (list 'cons (list 'const (car x))
'(choice
(symbol :tag "Publishing/Export property")
(string :tag "Value"))))
org-infojs-opts-table)))
(defcustom org-infojs-template (defcustom org-infojs-template
"<script type=\"text/javascript\" language=\"JavaScript\" src=\"%SCRIPT_PATH\"></script> "<script type=\"text/javascript\" language=\"JavaScript\" src=\"%SCRIPT_PATH\"></script>
@ -115,7 +123,12 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
exp-plist exp-plist
;; We do want to use the script, set it up ;; We do want to use the script, set it up
(let ((template org-infojs-template) (let ((template org-infojs-template)
p1 s p v a1 tmp e opt var val table default) (ptoc (plist-get exp-plist :table-of-contents))
(hlevels (plist-get exp-plist :headline-levels))
tdepth sdepth p1 s p v a1 tmp e opt var val table default)
(setq sdepth hlevels
tdepth hlevels)
(if (integerp ptoc) (setq tdepth (min ptoc tdepth)))
(setq v (plist-get exp-plist :infojs-opt) (setq v (plist-get exp-plist :infojs-opt)
table org-infojs-opts-table) table org-infojs-opts-table)
(while (setq e (pop table)) (while (setq e (pop table))
@ -130,6 +143,12 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
((eq opt 'path) ((eq opt 'path)
(and (string-match "%SCRIPT_PATH" template) (and (string-match "%SCRIPT_PATH" template)
(setq template (replace-match val t t template)))) (setq template (replace-match val t t template))))
((eq opt 'sdepth)
(if (integerp (read val))
(setq sdepth (min (read val) hlevels))))
((eq opt 'tdepth)
(if (integerp (read val))
(setq tdepth (min (read val) hlevels))))
(t (t
(setq val (setq val
(cond (cond
@ -139,6 +158,15 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
(t (format "%s" val)))) (t (format "%s" val))))
(push (cons var val) s)))) (push (cons var val) s))))
;; Now we set the depth of the *generated* TOC to SDEPTH, because the
;; toc will actually determine the splitting. How much of the toc will
;; actually be displayed is governed by the TDEPTH option.
(setq exp-plist (plist-put exp-plist :table-of-contents sdepth))
;; The table of contents should ot show more sections then we generate
(setq tdepth (min tdepth sdepth))
(push (cons "TOC_DEPTH" tdepth) s)
(setq s (mapconcat (setq s (mapconcat
(lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");" (lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
(car x) (cdr x))) (car x) (cdr x)))
@ -154,7 +182,6 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
;; setting ;; setting
(if (not (plist-get exp-plist :table-of-contents)) (if (not (plist-get exp-plist :table-of-contents))
(setq exp-plist (plist-put exp-plist :table-of-contents t))) (setq exp-plist (plist-put exp-plist :table-of-contents t)))
;; Return the modified property list ;; Return the modified property list
exp-plist))) exp-plist)))