Add custom variable for extra JS, and fixed the bug of unexpected comma in joining builtin JS codes and empty extra JS codes.

This commit is contained in:
Yujie Wen 2014-07-10 23:11:02 +08:00
parent 0444db1cb0
commit 3c839d0caa
1 changed files with 23 additions and 27 deletions

View File

@ -58,7 +58,7 @@
(:reveal-speed "REVEAL_SPEED" nil org-reveal-transition-speed t) (:reveal-speed "REVEAL_SPEED" nil org-reveal-transition-speed t)
(:reveal-theme "REVEAL_THEME" nil org-reveal-theme t) (:reveal-theme "REVEAL_THEME" nil org-reveal-theme t)
(:reveal-extra-css "REVEAL_EXTRA_CSS" nil nil nil) (:reveal-extra-css "REVEAL_EXTRA_CSS" nil nil nil)
(:reveal-extra-js "REVEAL_EXTRA_JS" nil nil nil) (:reveal-extra-js "REVEAL_EXTRA_JS" nil org-reveal-extra-js nil)
(:reveal-hlevel "REVEAL_HLEVEL" nil nil t) (:reveal-hlevel "REVEAL_HLEVEL" nil nil t)
(:reveal-title-slide-template "REVEAL_TITLE_SLIDE_TEMPLATE" nil org-reveal-title-slide-template t) (:reveal-title-slide-template "REVEAL_TITLE_SLIDE_TEMPLATE" nil org-reveal-title-slide-template t)
(:reveal-mathjax nil "reveal_mathjax" org-reveal-mathjax t) (:reveal-mathjax nil "reveal_mathjax" org-reveal-mathjax t)
@ -131,6 +131,12 @@ can be include."
:group 'org-export-reveal :group 'org-export-reveal
:type 'string) :type 'string)
(defcustom org-reveal-extra-js
""
"URL to extra JS file."
:group 'org-export-reveal
:type 'string)
(defcustom org-reveal-control t (defcustom org-reveal-control t
"Reveal control applet." "Reveal control applet."
:group 'org-export-reveal :group 'org-export-reveal
@ -458,37 +464,27 @@ transitionSpeed: '%s',\n"
dependencies: [ dependencies: [
" "
;; JS libraries ;; JS libraries
(let ((builtins-code (let* ((builtins
(let ((builtins '(classList (format " { src: '%slib/js/classList.js', condition: function() { return !document.body.classList; } }" root-path)
'(classList markdown (format " { src: '%splugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
(format " { src: '%slib/js/classList.js', condition: function() { return !document.body.classList; } }" root-path)
markdown
(format " { src: '%splugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: '%splugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }" root-path root-path) { src: '%splugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }" root-path root-path)
highlight highlight (format " { src: '%splugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }" root-path)
(format " { src: '%splugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }" root-path) zoom (format " { src: '%splugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
zoom notes (format " { src: '%splugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
(format " { src: '%splugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }" root-path) search (format " { src: '%splugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
notes remotes (format " { src: '%splugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)))
(format " { src: '%splugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path) (builtin-codes
search (mapcar
(format " { src: '%splugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
remotes
(format " { src: '%splugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path))))
(mapconcat
(lambda (p) (lambda (p)
(eval (plist-get builtins p))) (eval (plist-get builtins p)))
(let ((buffer-plugins (plist-get info :reveal-plugins))) (let ((buffer-plugins (plist-get info :reveal-plugins)))
(if buffer-plugins (car (read-from-string buffer-plugins)) (if buffer-plugins (car (read-from-string buffer-plugins))
org-reveal-plugins)) org-reveal-plugins))))
",\n"))) (extra-codes (plist-get info :reveal-extra-js))
(extra-js (plist-get info :reveal-extra-js))) (total-codes
(or (and builtins-code extra-js (if (string= "" extra-codes) builtin-codes
(concat builtins-code ", " extra-js)) (append (list extra-codes) builtin-codes))))
builtins-code (mapconcat 'identity total-codes ",\n"))
extra-js))
" "
] ]
}); });