added multiplex support via a few additional options

This commit is contained in:
Stephen Barrett 2014-11-04 10:33:03 +00:00
parent 9ea30500e9
commit 2622596302
1 changed files with 103 additions and 42 deletions

View File

@ -137,6 +137,28 @@ can be include."
:group 'org-export-reveal :group 'org-export-reveal
:type 'string) :type 'string)
(defcustom org-reveal-multiplex-id ""
"The ID to use for multiplexing."
:group 'org-export-reveal
:type 'string)
(defcustom org-reveal-multiplex-secret ""
"The secret to use for master slide."
:group 'org-export-reveal
:type 'string)
(defcustom org-reveal-multiplex-url ""
"The url of the socketio server."
:group 'org-export-reveal
:type 'string)
(defcustom org-reveal-multiplex-socketio-url
""
"the url of the socketio.js library"
: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
@ -239,7 +261,8 @@ can be include."
(const zoom) (const zoom)
(const notes) (const notes)
(const search) (const search)
(const remotes))) (const remotes)
(const multiplex)))
(defun if-format (fmt val) (defun if-format (fmt val)
(if val (format fmt val) "")) (if val (format fmt val) ""))
@ -249,7 +272,7 @@ can be include."
(cond (cond
((string= frag t) " class=\"fragment\"") ((string= frag t) " class=\"fragment\"")
(frag (format " class=\"fragment %s\"" frag)))) (frag (format " class=\"fragment %s\"" frag))))
(defun org-reveal-export-block (export-block contents info) (defun org-reveal-export-block (export-block contents info)
"Transocde a EXPORT-BLOCK element from Org to Reveal. "Transocde a EXPORT-BLOCK element from Org to Reveal.
@ -272,21 +295,21 @@ holding contextual information."
;; Then add enclosing <section> tags to mark slides. ;; Then add enclosing <section> tags to mark slides.
(setq contents (or contents "")) (setq contents (or contents ""))
(let* ((numberedp (org-export-numbered-headline-p headline info)) (let* ((numberedp (org-export-numbered-headline-p headline info))
(level (org-export-get-relative-level headline info)) (level (org-export-get-relative-level headline info))
(text (org-export-data (org-element-property :title headline) info)) (text (org-export-data (org-element-property :title headline) info))
(todo (and (plist-get info :with-todo-keywords) (todo (and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword headline))) (let ((todo (org-element-property :todo-keyword headline)))
(and todo (org-export-data todo info))))) (and todo (org-export-data todo info)))))
(todo-type (and todo (org-element-property :todo-type headline))) (todo-type (and todo (org-element-property :todo-type headline)))
(tags (and (plist-get info :with-tags) (tags (and (plist-get info :with-tags)
(org-export-get-tags headline info))) (org-export-get-tags headline info)))
(priority (and (plist-get info :with-priority) (priority (and (plist-get info :with-priority)
(org-element-property :priority headline))) (org-element-property :priority headline)))
;; Create the headline text. ;; Create the headline text.
(full-text (funcall (or (plist-get info :html-format-headline-function) (full-text (funcall (or (plist-get info :html-format-headline-function)
;; nil function, return a suggestive error ;; nil function, return a suggestive error
(error "Export failed. It seems you are using a stable release of Org-mode. Please use Org-reveal `stable' branch for Org-mode stable releases.")) (error "Export failed. It seems you are using a stable release of Org-mode. Please use Org-reveal `stable' branch for Org-mode stable releases."))
todo todo-type priority text tags info))) todo todo-type priority text tags info)))
(cond (cond
;; Case 1: This is a footnote section: ignore it. ;; Case 1: This is a footnote section: ignore it.
((org-element-property :footnote-section-p headline) nil) ((org-element-property :footnote-section-p headline) nil)
@ -296,19 +319,19 @@ holding contextual information."
((org-export-low-level-p headline info) ((org-export-low-level-p headline info)
;; Build the real contents of the sub-tree. ;; Build the real contents of the sub-tree.
(let* ((type (if numberedp 'ordered 'unordered)) (let* ((type (if numberedp 'ordered 'unordered))
(itemized-body (org-reveal-format-list-item (itemized-body (org-reveal-format-list-item
contents type nil info nil 'none full-text))) contents type nil info nil 'none full-text)))
(concat (concat
(and (org-export-first-sibling-p headline info) (and (org-export-first-sibling-p headline info)
(org-html-begin-plain-list type)) (org-html-begin-plain-list type))
itemized-body itemized-body
(and (org-export-last-sibling-p headline info) (and (org-export-last-sibling-p headline info)
(org-html-end-plain-list type))))) (org-html-end-plain-list type)))))
;; Case 3. Standard headline. Export it as a section. ;; Case 3. Standard headline. Export it as a section.
(t (t
(let* ((level1 (+ level (1- org-html-toplevel-hlevel))) (let* ((level1 (+ level (1- org-html-toplevel-hlevel)))
(hlevel (org-reveal--get-hlevel info)) (hlevel (org-reveal--get-hlevel info))
(first-content (car (org-element-contents headline)))) (first-content (car (org-element-contents headline))))
(concat (concat
(if (or (/= level 1) (if (or (/= level 1)
(not (org-export-first-sibling-p headline info))) (not (org-export-first-sibling-p headline info)))
@ -461,6 +484,21 @@ transition: Reveal.getQueryHash().transition || '%s', // default/cube/page/conca
transitionSpeed: '%s',\n" transitionSpeed: '%s',\n"
(plist-get info :reveal-trans) (plist-get info :reveal-trans)
(plist-get info :reveal-speed)) (plist-get info :reveal-speed))
;; multiplexing - depends on defvar 'client-multiplex'
(when (plist-get info :reveal-multiplex-id)
(format
"multiplex: {
secret: %s, // null if client
id: '%s', // id, obtained from socket.io server
url: '%s' // Location of socket.io server
},\n"
(if (eq client-multiplex nil)
(format "'%s'" (plist-get info :reveal-multiplex-secret))
(format "null"))
(plist-get info :reveal-multiplex-id)
(plist-get info :reveal-multiplex-url)))
;; optional JS library heading ;; optional JS library heading
" "
// Optional libraries used to extend on reveal.js // Optional libraries used to extend on reveal.js
@ -475,7 +513,17 @@ dependencies: [
zoom (format " { src: '%splugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }" root-path) zoom (format " { src: '%splugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
notes (format " { src: '%splugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path) notes (format " { src: '%splugin/notes/notes.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) search (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))) remotes (format " { src: '%splugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
multiplex (format " { src: '%s', async: true },\n%s"
(plist-get info :reveal-multiplex-socketio-url)
; following ensures that either client.js or master.js is included depending on defva client-multiplex value state
(if (not client-multiplex)
(progn
(if (plist-get info :reveal-multiplex-secret)
(setq client-multiplex t))
(format " { src: '%splugin/multiplex/master.js', async: true }" root-path))
(format " { src: '%splugin/multiplex/client.js', async: true }" root-path)))))
(builtin-codes (builtin-codes
(mapcar (mapcar
(lambda (p) (lambda (p)
@ -641,8 +689,8 @@ the plist used as a communication channel."
(let ((parent (org-export-get-parent paragraph))) (let ((parent (org-export-get-parent paragraph)))
(cond (cond
((and (eq (org-element-type parent) 'item) ((and (eq (org-element-type parent) 'item)
(= (org-element-property :begin paragraph) (= (org-element-property :begin paragraph)
(org-element-property :contents-begin parent))) (org-element-property :contents-begin parent)))
;; leading paragraph in a list item have no tags ;; leading paragraph in a list item have no tags
contents) contents)
((org-html-standalone-image-p paragraph info) ((org-html-standalone-image-p paragraph info)
@ -688,24 +736,24 @@ contextual information."
(if (org-export-read-attribute :attr_html src-block :textarea) (if (org-export-read-attribute :attr_html src-block :textarea)
(org-html--textarea-block src-block) (org-html--textarea-block src-block)
(let ((lang (org-element-property :language src-block)) (let ((lang (org-element-property :language src-block))
(caption (org-export-get-caption src-block)) (caption (org-export-get-caption src-block))
(code (org-html-format-code src-block info)) (code (org-html-format-code src-block info))
(frag (org-export-read-attribute :attr_reveal src-block :frag)) (frag (org-export-read-attribute :attr_reveal src-block :frag))
(label (let ((lbl (org-element-property :name src-block))) (label (let ((lbl (org-element-property :name src-block)))
(if (not lbl) "" (if (not lbl) ""
(format " id=\"%s\"" (format " id=\"%s\""
(org-export-solidify-link-text lbl)))))) (org-export-solidify-link-text lbl))))))
(if (not lang) (if (not lang)
(format "<pre %s%s>\n%s</pre>" (format "<pre %s%s>\n%s</pre>"
(or (frag-class frag) " class=\"example\"") (or (frag-class frag) " class=\"example\"")
label label
code) code)
(format (format
"<div class=\"org-src-container\">\n%s%s\n</div>" "<div class=\"org-src-container\">\n%s%s\n</div>"
(if (not caption) "" (if (not caption) ""
(format "<label class=\"org-src-name\">%s</label>" (format "<label class=\"org-src-name\">%s</label>"
(org-export-data caption info))) (org-export-data caption info)))
(format "\n<pre %s%s>%s</pre>" (format "\n<pre %s%s>%s</pre>"
(or (frag-class frag) (or (frag-class frag)
(format " class=\"src src-%s\"" lang)) (format " class=\"src src-%s\"" lang))
label code)))))) label code))))))
@ -744,15 +792,28 @@ info is a plist holding export options."
</html>\n")) </html>\n"))
(defvar client-multiplex nil
"used to cause generation of client html file for multiplex")
(defun org-reveal-export-to-html (defun org-reveal-export-to-html
(&optional async subtreep visible-only body-only ext-plist) (&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a reveal.js HTML file." "Export current buffer to a reveal.js HTML file."
(interactive) (interactive)
(let* ((extension (concat "." org-html-extension)) (let* ((extension (concat "." org-html-extension))
(file (org-export-output-file-name extension subtreep))) (file (org-export-output-file-name extension subtreep))
(org-export-to-file 'reveal file (clientfile (org-export-output-file-name (concat "_client" extension) subtreep)))
async subtreep visible-only body-only ext-plist)))
; export filename_client HTML file if multiplexing
(setq client-multiplex nil)
(setq retfile (org-export-to-file 'reveal file
async subtreep visible-only body-only ext-plist))
; export the client HTML file if client-multiplex is set true
; by previous call to org-export-to-file
(if (eq client-multiplex t)
(org-export-to-file 'reveal clientfile
async subtreep visible-only body-only ext-plist))
(cond (t retfile))))
(defun org-reveal-export-to-html-and-browse (defun org-reveal-export-to-html-and-browse
(&optional async subtreep visible-only body-only ext-plist) (&optional async subtreep visible-only body-only ext-plist)