Fixed #429. Updated multiplexing exports with Reveal.js 4.x

This commit is contained in:
Yujie Wen 2020-09-26 12:28:46 +08:00
parent 553e1a9d67
commit 79b01ae85b
2 changed files with 46 additions and 33 deletions

View File

@ -743,20 +743,27 @@ This feature is turned off by default and needs to be switched on with ~org-reve
'n'. set it to nil will forbid the auto-completion for speaker notes.
** Multiplexing
Reveal.js supports multiplexing, which allows your audience to view
the slides of the presentation you are controlling on their own phone, tablet
or laptop. As the master presentation navigates the slides, all client
presentations will update in real time. See a demo at
http://revealjs.jit.su/.
Reveal.js supports a [[https://github.com/reveal/multiplex#multiplex-plugin][multiplexing plugin]], which allows your
audience to view the slides of the presentation you are controlling
on their own phone, tablet or laptop. As the master presentation
navigates the slides, all client presentations will update in real
time. See a demo at [[https://reveal-multiplex.glitch.me/]].
You can enable multiplexing for your slide generation by including the
following options:
To use multiplexing, first prepare a Socket.io server by the
instruction [[https://github.com/reveal/multiplex#socketio-server][here]]. Then include the following options in the org
file. Contents in ~[]~ are commentary notes, not part of the
options.
#+BEGIN_SRC org
#+REVEAL_MULTIPLEX_ID: [Obtained from the socket.io server. ]
#+REVEAL_MULTIPLEX_SECRET: [Obtained from socket.io server. Gives the master control of the presentation.]
#+REVEAL_MULTIPLEX_URL: http://revealjs.jit.su:80 [Location of socket.io server]
#+REVEAL_MULTIPLEX_SOCKETIO_URL: http://cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.10/socket.io.min.js
#+REVEAL_PLUGINS: ([any other plugins you are using] multiplex)
,#+REVEAL_MULTIPLEX_ID: [Obtained from the socket.io server. ]
,#+REVEAL_MULTIPLEX_SECRET: [Obtained from socket.io server. Gives the master control of the presentation.]
,#+REVEAL_MULTIPLEX_URL: https://reveal-multiplex.glitch.me [Location of socket.io server]
,#+REVEAL_PLUGINS: ([any other plugins you are using] multiplex)
#+END_SRC
If your are using Reveal.js 3.x, an extra option is necessary for
Socket.io scripts.
#+BEGIN_SRC org
,#+REVEAL_MULTIPLEX_SOCKETIO_URL: http://cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.10/socket.io.min.js
#+END_SRC
You must generate unique values for the =REVEAL_MULTIPLEX_ID= and

View File

@ -754,6 +754,7 @@ dependencies: [
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)
remotes (format " { src: '%splugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }" root-path)
;; multiplex setup for reveal.js 3.x
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
@ -764,15 +765,24 @@ dependencies: [
(format " { src: '%splugin/multiplex/master.js', async: true }" root-path))
(format " { src: '%splugin/multiplex/client.js', async: true }" root-path)))))
(builtin-codes
(if (eq version 4)
'() ;; For reveal.js 4.x, skip the builtin plug-in
;; codes as they are for 3.x. The 4.x builtin
;; plug-ins are specified by separate <script>
;; blocks
(mapcar
(lambda (p)
(eval (plist-get builtins p)))
(org-reveal--get-plugins info))))
(let ((plugins (org-reveal--get-plugins info)))
(if (eq version 4)
;; For reveal.js 4.x, skip the builtin plug-in
;; codes except multiplex as all other plug-ins
;; in 4.x are specified by separate <script>
;; blocks
(let ((url (plist-get info :reveal-multiplex-url)))
(if (memq 'multiplex plugins)
(list (format " { src: '%s/socket.io/socket.io.js', async: true }, { src: '%s/%s', async: true } "
url url
(if client-multiplex "client.js"
(progn
(setq client-multiplex t)
"master.js"))))
'()))
(mapcar (lambda (p)
(eval (plist-get builtins p)))
plugins))))
(external-plugins
(append
;; Global setting
@ -1410,9 +1420,6 @@ transformed fragment attribute to ELEM's attr_html plist."
(t (org-reveal--update-attr-html elem frag default-style frag-index)))
elem)))
(defvar client-multiplex nil
"used to cause generation of client html file for multiplex")
(defun org-reveal-export-to-html
(&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a reveal.js HTML file."
@ -1420,19 +1427,18 @@ transformed fragment attribute to ELEM's attr_html plist."
(let* ((extension (concat "." org-html-extension))
(file (org-export-output-file-name extension subtreep))
(clientfile (org-export-output-file-name (concat "_client" extension) subtreep))
(retfile))
(org-export-exclude-tags (cons "noexport_reveal" org-export-exclude-tags))
(client-multiplex nil))
; export filename_client HTML file if multiplexing
(setq client-multiplex nil)
(let ((org-export-exclude-tags (cons "noexport_reveal" org-export-exclude-tags)))
(setq retfile (org-export-to-file 'reveal file
async subtreep visible-only body-only ext-plist)))
(let ((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)
; export the client HTML file if client-multiplex is set true
; by previous call to org-export-to-file
(when client-multiplex
(org-export-to-file 'reveal clientfile
async subtreep visible-only body-only ext-plist))
retfile))
retfile)))
(defun org-reveal-export-to-html-and-browse
(&optional async subtreep visible-only body-only ext-plist)