2013-02-20 10:32:54 -05:00
|
|
|
;;; ox-deck.el --- deck.js Presentation Back-End for Org Export Engine
|
|
|
|
|
2014-01-07 08:18:17 -05:00
|
|
|
;; Copyright (C) 2013, 2014 Rick Frankel
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
;; Author: Rick Frankel <emacs at rickster dot com>
|
|
|
|
;; Keywords: outlines, hypermedia, slideshow
|
|
|
|
|
2013-03-10 12:57:47 -04:00
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
2013-02-20 10:32:54 -05:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; This library implements a deck.js presentation back-end for the Org
|
|
|
|
;; generic exporter.
|
|
|
|
|
|
|
|
;; Installation
|
|
|
|
;; -------------
|
|
|
|
;; Get a copy of deck.js from http://imakewebthings.com/deck.js/ or
|
|
|
|
;; the gitub repository at https://github.com/imakewebthings/deck.js.
|
|
|
|
;;
|
|
|
|
;; Add the path to the extracted code to the variable
|
|
|
|
;; `org-deck-directories' There are a number of customization in the
|
|
|
|
;; org-export-deck group, most of which can be overrriden with buffer
|
|
|
|
;; local customization (starting with DECK_.)
|
|
|
|
|
|
|
|
;; See ox.el and ox-html.el for more details on how this exporter
|
|
|
|
;; works (it is derived from ox-html.)
|
|
|
|
|
|
|
|
(require 'ox-html)
|
2013-02-26 14:26:27 -05:00
|
|
|
(eval-when-compile (require 'cl))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
2013-03-19 11:26:30 -04:00
|
|
|
(org-export-define-derived-backend 'deck 'html
|
2013-02-20 10:32:54 -05:00
|
|
|
:menu-entry
|
2013-03-19 11:26:30 -04:00
|
|
|
'(?d "Export to deck.js HTML Presentation"
|
|
|
|
((?H "To temporary buffer" org-deck-export-as-html)
|
|
|
|
(?h "To file" org-deck-export-to-html)
|
|
|
|
(?o "To file and open"
|
|
|
|
(lambda (a s v b)
|
|
|
|
(if a (org-deck-export-to-html t s v b)
|
|
|
|
(org-open-file (org-deck-export-to-html nil s v b)))))))
|
2013-02-20 10:32:54 -05:00
|
|
|
:options-alist
|
2013-03-19 11:26:30 -04:00
|
|
|
'((:html-link-home "HTML_LINK_HOME" nil nil)
|
|
|
|
(:html-link-up "HTML_LINK_UP" nil nil)
|
|
|
|
(:deck-postamble "DECK_POSTAMBLE" nil org-deck-postamble newline)
|
|
|
|
(:deck-preamble "DECK_PREAMBLE" nil org-deck-preamble newline)
|
|
|
|
(:html-head-include-default-style "HTML_INCLUDE_DEFAULT_STYLE" nil nil)
|
|
|
|
(:html-head-include-scripts "HTML_INCLUDE_SCRIPTS" nil nil)
|
|
|
|
(:deck-base-url "DECK_BASE_URL" nil org-deck-base-url)
|
|
|
|
(:deck-theme "DECK_THEME" nil org-deck-theme)
|
|
|
|
(:deck-transition "DECK_TRANSITION" nil org-deck-transition)
|
|
|
|
(:deck-include-extensions "DECK_INCLUDE_EXTENSIONS" nil
|
|
|
|
org-deck-include-extensions split)
|
|
|
|
(:deck-exclude-extensions "DECK_EXCLUDE_EXTENSIONS" nil
|
|
|
|
org-deck-exclude-extensions split))
|
2013-02-20 10:32:54 -05:00
|
|
|
:translate-alist
|
2013-03-19 11:26:30 -04:00
|
|
|
'((headline . org-deck-headline)
|
|
|
|
(inner-template . org-deck-inner-template)
|
|
|
|
(item . org-deck-item)
|
2013-05-26 19:17:18 -04:00
|
|
|
(link . org-deck-link)
|
2013-03-19 11:26:30 -04:00
|
|
|
(template . org-deck-template)))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defgroup org-export-deck nil
|
|
|
|
"Options for exporting Org mode files to deck.js HTML Presentations."
|
|
|
|
:tag "Org Export DECK"
|
|
|
|
:group 'org-export-html)
|
|
|
|
|
2013-02-26 14:26:27 -05:00
|
|
|
(defcustom org-deck-directories '("./deck.js")
|
2013-02-20 10:32:54 -05:00
|
|
|
"Directories to search for deck.js components (jquery,
|
|
|
|
modernizr; core, extensions and themes directories.)"
|
|
|
|
:group 'org-export-deck
|
|
|
|
:type '(repeat (string :tag "Directory")))
|
|
|
|
|
|
|
|
(defun org-deck--cleanup-components (components)
|
|
|
|
(remove-duplicates
|
|
|
|
(car (remove 'nil components))
|
|
|
|
:test (lambda (x y)
|
2013-02-25 13:09:31 -05:00
|
|
|
(string= (file-name-nondirectory x)
|
|
|
|
(file-name-nondirectory y)))))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck--find-extensions ()
|
|
|
|
"Returns a unique list of all extensions found in
|
|
|
|
in the extensions directories under `org-deck-directories'"
|
|
|
|
(org-deck--cleanup-components
|
2013-03-12 17:10:30 -04:00
|
|
|
(mapcar ; extensions under existing dirs
|
2013-02-25 13:09:31 -05:00
|
|
|
(lambda (dir)
|
|
|
|
(when (file-directory-p dir) (directory-files dir t "^[^.]")))
|
|
|
|
(mapcar ; possible extension directories
|
|
|
|
(lambda (x) (expand-file-name "extensions" x))
|
|
|
|
org-deck-directories))))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck--find-css (type)
|
|
|
|
"Return a unique list of all the css stylesheets in the themes/TYPE
|
|
|
|
directories under `org-deck-directories'."
|
|
|
|
(org-deck--cleanup-components
|
|
|
|
(mapcar
|
|
|
|
(lambda (dir)
|
|
|
|
(let ((css-dir (expand-file-name
|
2013-02-25 13:09:31 -05:00
|
|
|
(concat (file-name-as-directory "themes") type) dir)))
|
|
|
|
(when (file-directory-p css-dir)
|
|
|
|
(directory-files css-dir t "\\.css$"))))
|
|
|
|
org-deck-directories)))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck-list-components ()
|
|
|
|
"List all available deck extensions, styles and
|
|
|
|
transitions (with full paths) to a temporary buffer."
|
|
|
|
(interactive)
|
|
|
|
(let ((outbuf (get-buffer-create "*deck.js Extensions*")))
|
|
|
|
(with-current-buffer outbuf
|
|
|
|
(erase-buffer)
|
|
|
|
(insert "Extensions\n----------\n")
|
|
|
|
(insert (mapconcat 'identity (org-deck--find-extensions) "\n"))
|
|
|
|
(insert "\n\nStyles\n------\n")
|
|
|
|
(insert (mapconcat 'identity (org-deck--find-css "style") "\n"))
|
|
|
|
(insert "\n\nTransitions\n----------\n")
|
|
|
|
(insert (mapconcat 'identity (org-deck--find-css "transition") "\n")))
|
|
|
|
(switch-to-buffer-other-window outbuf)))
|
|
|
|
|
|
|
|
(defcustom org-deck-include-extensions nil
|
|
|
|
"If non-nil, list of extensions to include instead of all available.
|
|
|
|
Can be overriden or set with the DECK_INCLUDE_EXTENSIONS property.
|
|
|
|
During output generation, the extensions found by
|
|
|
|
`org-deck--find-extensions' are searched for the appropriate
|
|
|
|
files (scripts and/or stylesheets) to include in the generated
|
|
|
|
html. The href/src attributes are created relative to `org-deck-base-url'."
|
|
|
|
:group 'org-export-deck
|
|
|
|
:type '(repeat (string :tag "Extension")))
|
|
|
|
|
|
|
|
(defcustom org-deck-exclude-extensions nil
|
|
|
|
"If non-nil, list of extensions to exclude.
|
|
|
|
Can be overriden or set with the DECK_EXCLUDE_EXTENSIONS property."
|
|
|
|
:group 'org-export-deck
|
|
|
|
:type '(repeat (string :tag "Extension")))
|
|
|
|
|
|
|
|
(defcustom org-deck-theme "swiss.css"
|
|
|
|
"deck.js theme. Can be overriden with the DECK_THEME property.
|
|
|
|
If this value contains a path component (\"/\"), it is used as a
|
|
|
|
literal path (url). Otherwise it is prepended with
|
|
|
|
`org-deck-base-url'/themes/style/."
|
|
|
|
:group 'org-export-deck
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defcustom org-deck-transition "fade.css"
|
|
|
|
"deck.js transition theme. Can be overriden with the
|
|
|
|
DECK_TRANSITION property.
|
|
|
|
If this value contains a path component (\"/\"), it is used as a
|
|
|
|
literal path (url). Otherwise it is prepended with
|
|
|
|
`org-deck-base-url'/themes/transition/."
|
|
|
|
:group 'org-export-deck
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defcustom org-deck-base-url "deck.js"
|
|
|
|
"Url prefix to deck.js base directory containing the core, extensions
|
|
|
|
and themes directories.
|
|
|
|
Can be overriden with the DECK_BASE_URL property."
|
|
|
|
:group 'org-export-deck
|
|
|
|
:type 'string)
|
|
|
|
|
2013-03-16 15:10:53 -04:00
|
|
|
(defvar org-deck-pre/postamble-styles
|
|
|
|
`((both "left: 5px; width: 100%;")
|
|
|
|
(preamble "position: absolute; top: 10px;")
|
|
|
|
(postamble ""))
|
|
|
|
"Alist of css styles for the preamble, postamble and both respectively.
|
|
|
|
Can be overriden in `org-deck-styles'. See also `org-html-divs'.")
|
|
|
|
|
|
|
|
(defcustom org-deck-postamble "<h1>%a - %t</h1>"
|
|
|
|
"Non-nil means insert a postamble in HTML export.
|
|
|
|
|
|
|
|
When set to a string, use this string
|
|
|
|
as the postamble. When t, insert a string as defined by the
|
|
|
|
formatting string in `org-html-postamble-format'.
|
|
|
|
|
|
|
|
When set to a function, apply this function and insert the
|
|
|
|
returned string. The function takes the property list of export
|
|
|
|
options as its only argument.
|
2013-03-11 17:49:39 -04:00
|
|
|
|
|
|
|
This is included in the document at the bottom of the content
|
|
|
|
section, and uses the postamble element and id from
|
|
|
|
`org-html-divs'. The default places the author and presentation
|
2013-03-16 15:10:53 -04:00
|
|
|
title at the bottom of each slide.
|
2013-02-20 10:32:54 -05:00
|
|
|
|
2013-03-16 15:10:53 -04:00
|
|
|
The css styling is controlled by `org-deck-pre/postamble-styles'.
|
2013-03-11 17:49:39 -04:00
|
|
|
|
2013-03-16 15:10:53 -04:00
|
|
|
Setting :deck-postamble in publishing projects will take
|
|
|
|
precedence over this variable."
|
2013-02-20 10:32:54 -05:00
|
|
|
:group 'org-export-deck
|
2013-03-16 15:10:53 -04:00
|
|
|
:type '(choice (const :tag "No postamble" nil)
|
|
|
|
(const :tag "Default formatting string" t)
|
|
|
|
(string :tag "Custom formatting string")
|
|
|
|
(function :tag "Function (must return a string)")))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
2013-03-16 15:10:53 -04:00
|
|
|
(defcustom org-deck-preamble nil
|
|
|
|
"Non-nil means insert a preamble in HTML export.
|
|
|
|
|
|
|
|
When set to a string, use this string
|
|
|
|
as the preamble. When t, insert a string as defined by the
|
|
|
|
formatting string in `org-html-preamble-format'.
|
|
|
|
|
|
|
|
When set to a function, apply this function and insert the
|
|
|
|
returned string. The function takes the property list of export
|
|
|
|
options as its only argument.
|
|
|
|
|
|
|
|
This is included in the document at the top of content section, and
|
|
|
|
uses the preamble element and id from `org-html-divs'. The css
|
|
|
|
styling is controlled by `org-deck-pre/postamble-styles'.
|
|
|
|
|
|
|
|
Setting :deck-preamble in publishing projects will take
|
|
|
|
precedence over this variable."
|
|
|
|
:group 'org-export-deck
|
|
|
|
:type '(choice (const :tag "No preamble" nil)
|
|
|
|
(const :tag "Default formatting string" t)
|
|
|
|
(string :tag "Custom formatting string")
|
|
|
|
(function :tag "Function (must return a string)")))
|
2013-03-11 17:49:39 -04:00
|
|
|
|
|
|
|
(defvar org-deck-toc-styles
|
|
|
|
(mapconcat
|
|
|
|
'identity
|
|
|
|
(list
|
|
|
|
"#table-of-contents a {color: inherit;}"
|
|
|
|
"#table-of-contents ul {margin-bottom: 0;}"
|
|
|
|
"#table-of-contents li {padding: 0;}") "\n")
|
|
|
|
"Default css styles used for formatting a table of contents slide.
|
|
|
|
Can be overriden in `org-deck-styles'.
|
2013-03-16 15:10:53 -04:00
|
|
|
Note that when the headline numbering option is true, a \"list-style: none\"
|
2013-03-11 17:49:39 -04:00
|
|
|
is automatically added to avoid both numbers and bullets on the toc entries.")
|
|
|
|
|
|
|
|
(defcustom org-deck-styles
|
|
|
|
"
|
|
|
|
#title-slide h1 {
|
|
|
|
position: static; padding: 0;
|
|
|
|
margin-top: 10%;
|
|
|
|
-webkit-transform: none;
|
|
|
|
-moz-transform: none;
|
|
|
|
-ms-transform: none;
|
|
|
|
-o-transform: none;
|
|
|
|
transform: none;
|
|
|
|
}
|
|
|
|
#title-slide h2 {
|
|
|
|
text-align: center;
|
|
|
|
border:none;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
}"
|
|
|
|
"Deck specific CSS styles to include in exported html.
|
|
|
|
Defaults to styles for the title page."
|
2013-02-20 10:32:54 -05:00
|
|
|
:group 'org-export-deck
|
|
|
|
:type 'string)
|
|
|
|
|
2013-03-11 17:49:39 -04:00
|
|
|
(defcustom org-deck-title-slide-template
|
2013-03-16 15:10:53 -04:00
|
|
|
"<h1>%t</h1>
|
|
|
|
<h2>%a</h2>
|
|
|
|
<h2>%e</h2>
|
|
|
|
<h2>%d</h2>"
|
2013-03-11 17:49:39 -04:00
|
|
|
"Format template to specify title page section.
|
2013-03-16 15:10:53 -04:00
|
|
|
See `org-html-postamble-format' for the valid elements which
|
|
|
|
can be included.
|
2013-03-11 17:49:39 -04:00
|
|
|
|
|
|
|
It will be wrapped in the element defined in the :html-container
|
|
|
|
property, and defaults to the value of `org-html-container-element',
|
|
|
|
and have the id \"title-slide\"."
|
2013-02-20 10:32:54 -05:00
|
|
|
:group 'org-export-deck
|
|
|
|
:type 'string)
|
|
|
|
|
|
|
|
(defun org-deck-toc (depth info)
|
|
|
|
(concat
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "<%s id='table-of-contents' class='slide'>\n"
|
2013-03-12 17:10:30 -04:00
|
|
|
(plist-get info :html-container))
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "<h2>%s</h2>\n" (org-html--translate "Table of Contents" info))
|
2013-02-26 14:26:27 -05:00
|
|
|
(org-html--toc-text
|
2013-02-25 13:09:31 -05:00
|
|
|
(mapcar
|
|
|
|
(lambda (headline)
|
|
|
|
(let* ((class (org-element-property :HTML_CONTAINER_CLASS headline))
|
|
|
|
(section-number
|
|
|
|
(when
|
|
|
|
(and (not (org-export-low-level-p headline info))
|
|
|
|
(org-export-numbered-headline-p headline info))
|
|
|
|
(concat
|
|
|
|
(mapconcat
|
|
|
|
'number-to-string
|
|
|
|
(org-export-get-headline-number headline info) ".") ". ")))
|
|
|
|
(title
|
|
|
|
(concat
|
|
|
|
section-number
|
|
|
|
(replace-regexp-in-string ; remove any links in headline...
|
|
|
|
"</?a[^>]*>" ""
|
|
|
|
(org-export-data
|
|
|
|
(org-element-property :title headline) info)))))
|
2013-02-26 14:26:27 -05:00
|
|
|
(cons
|
2013-02-25 13:09:31 -05:00
|
|
|
(if (and class (string-match-p "\\<slide\\>" class))
|
|
|
|
(format
|
2013-05-26 19:17:18 -04:00
|
|
|
"<a href='#outline-container-%s'>%s</a>"
|
2013-02-25 13:09:31 -05:00
|
|
|
(or (org-element-property :CUSTOM_ID headline)
|
2013-05-26 19:17:18 -04:00
|
|
|
(concat
|
|
|
|
"sec-"
|
|
|
|
(mapconcat
|
|
|
|
'number-to-string
|
|
|
|
(org-export-get-headline-number headline info) "-")))
|
2013-02-25 13:09:31 -05:00
|
|
|
title)
|
|
|
|
title)
|
|
|
|
(org-export-get-relative-level headline info))))
|
|
|
|
(org-export-collect-headlines info depth)))
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "</%s>\n" (plist-get info :html-container))))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck--get-packages (info)
|
|
|
|
(let ((prefix (concat (plist-get info :deck-base-url) "/"))
|
2013-02-25 13:09:31 -05:00
|
|
|
(theme (plist-get info :deck-theme))
|
|
|
|
(transition (plist-get info :deck-transition))
|
|
|
|
(include (plist-get info :deck-include-extensions))
|
|
|
|
(exclude (plist-get info :deck-exclude-extensions))
|
|
|
|
(scripts '()) (sheets '()) (snippets '()))
|
2014-01-11 18:21:25 -05:00
|
|
|
(add-to-list 'scripts (concat prefix "jquery.min.js"))
|
2013-02-20 10:32:54 -05:00
|
|
|
(add-to-list 'scripts (concat prefix "core/deck.core.js"))
|
|
|
|
(add-to-list 'scripts (concat prefix "modernizr.custom.js"))
|
|
|
|
(add-to-list 'sheets (concat prefix "core/deck.core.css"))
|
2013-02-25 13:09:31 -05:00
|
|
|
(mapc
|
|
|
|
(lambda (extdir)
|
|
|
|
(let* ((name (file-name-nondirectory extdir))
|
|
|
|
(dir (file-name-as-directory extdir))
|
|
|
|
(path (concat prefix "extensions/" name "/"))
|
|
|
|
(base (format "deck.%s." name)))
|
|
|
|
(when (and (or (eq nil include) (member name include))
|
|
|
|
(not (member name exclude)))
|
|
|
|
(when (file-exists-p (concat dir base "js"))
|
|
|
|
(add-to-list 'scripts (concat path base "js")))
|
|
|
|
(when (file-exists-p (concat dir base "css"))
|
|
|
|
(add-to-list 'sheets (concat path base "css")))
|
|
|
|
(when (file-exists-p (concat dir base "html"))
|
|
|
|
(add-to-list 'snippets (concat dir base "html"))))))
|
|
|
|
(org-deck--find-extensions))
|
2013-03-03 20:50:58 -05:00
|
|
|
(if (not (string-match-p "^[[:space:]]*$" theme))
|
2013-03-12 17:10:30 -04:00
|
|
|
(add-to-list 'sheets
|
|
|
|
(if (file-name-directory theme) theme
|
|
|
|
(format "%sthemes/style/%s" prefix theme))))
|
2013-03-03 20:50:58 -05:00
|
|
|
(if (not (string-match-p "^[[:space:]]*$" transition))
|
2013-03-12 17:10:30 -04:00
|
|
|
(add-to-list
|
|
|
|
'sheets
|
|
|
|
(if (file-name-directory transition) transition
|
|
|
|
(format "%sthemes/transition/%s" prefix transition))))
|
2013-02-25 13:09:31 -05:00
|
|
|
(list :scripts (nreverse scripts) :sheets (nreverse sheets)
|
|
|
|
:snippets snippets)))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
2013-02-26 14:26:27 -05:00
|
|
|
(defun org-deck-inner-template (contents info)
|
2013-02-20 10:32:54 -05:00
|
|
|
"Return body of document string after HTML conversion.
|
|
|
|
CONTENTS is the transcoded contents string. INFO is a plist
|
|
|
|
holding export options."
|
2013-02-26 14:26:27 -05:00
|
|
|
(concat contents "\n"))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck-headline (headline contents info)
|
2013-02-25 12:55:32 -05:00
|
|
|
(let ((org-html-toplevel-hlevel 2)
|
|
|
|
(class (or (org-element-property :HTML_CONTAINER_CLASS headline) ""))
|
|
|
|
(level (org-export-get-relative-level headline info)))
|
|
|
|
(when (and (= 1 level) (not (string-match-p "\\<slide\\>" class)))
|
|
|
|
(org-element-put-property headline :HTML_CONTAINER_CLASS (concat class " slide")))
|
2013-02-25 13:09:31 -05:00
|
|
|
(org-html-headline headline contents info)))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck-item (item contents info)
|
|
|
|
"Transcode an ITEM element from Org to HTML.
|
|
|
|
CONTENTS holds the contents of the item. INFO is a plist holding
|
|
|
|
contextual information.
|
2014-01-11 18:25:14 -05:00
|
|
|
If the containing headline has the property :STEP, then
|
2013-02-20 10:32:54 -05:00
|
|
|
the \"slide\" class will be added to the to the list element,
|
|
|
|
which will make the list into a \"build\"."
|
|
|
|
(let ((text (org-html-item item contents info)))
|
2013-02-25 12:55:32 -05:00
|
|
|
(if (org-export-get-node-property :STEP item t)
|
|
|
|
(replace-regexp-in-string "^<li>" "<li class='slide'>" text)
|
2013-02-20 10:32:54 -05:00
|
|
|
text)))
|
|
|
|
|
2013-05-26 19:17:18 -04:00
|
|
|
(defun org-deck-link (link desc info)
|
|
|
|
(replace-regexp-in-string "href=\"#" "href=\"#outline-container-"
|
|
|
|
(org-html-link link desc info)))
|
|
|
|
|
2013-02-20 10:32:54 -05:00
|
|
|
(defun org-deck-template (contents info)
|
|
|
|
"Return complete document string after HTML conversion.
|
|
|
|
CONTENTS is the transcoded contents string. INFO is a plist
|
|
|
|
holding export options."
|
2013-03-16 15:10:53 -04:00
|
|
|
(let ((pkg-info (org-deck--get-packages info))
|
2013-05-30 08:33:47 -04:00
|
|
|
(org-html--pre/postamble-class "deck-status")
|
|
|
|
(info (plist-put
|
|
|
|
(plist-put info :html-preamble (plist-get info :deck-preamble))
|
|
|
|
:html-postamble (plist-get info :deck-postamble))))
|
2013-02-20 10:32:54 -05:00
|
|
|
(mapconcat
|
2013-02-25 13:09:31 -05:00
|
|
|
'identity
|
|
|
|
(list
|
2013-05-29 09:53:51 -04:00
|
|
|
(org-html-doctype info)
|
2013-02-25 13:09:31 -05:00
|
|
|
(let ((lang (plist-get info :language)))
|
|
|
|
(mapconcat
|
|
|
|
(lambda (x)
|
|
|
|
(apply
|
|
|
|
'format
|
2013-03-11 17:49:39 -04:00
|
|
|
"<!--%s <html %s lang='%s' xmlns='http://www.w3.org/1999/xhtml'> %s<![endif]-->"
|
2013-02-25 13:09:31 -05:00
|
|
|
x))
|
2013-03-11 17:49:39 -04:00
|
|
|
(list `("[if lt IE 7]>" "class='no-js ie6'" ,lang "")
|
|
|
|
`("[if IE 7]>" "class='no-js ie7'" ,lang "")
|
|
|
|
`("[if IE 8]>" "class='no-js ie8'" ,lang "")
|
2013-02-25 13:09:31 -05:00
|
|
|
`("[if gt IE 8]><!-->" "" ,lang "<!--")) "\n"))
|
|
|
|
"<head>"
|
|
|
|
(org-deck--build-meta-info info)
|
|
|
|
(mapconcat
|
|
|
|
(lambda (sheet)
|
|
|
|
(format
|
|
|
|
"<link rel='stylesheet' href='%s' type='text/css' />" sheet))
|
|
|
|
(plist-get pkg-info :sheets) "\n")
|
|
|
|
(mapconcat
|
|
|
|
(lambda (script)
|
|
|
|
(format
|
|
|
|
"<script src='%s' type='text/javascript'></script>" script))
|
|
|
|
(plist-get pkg-info :scripts) "\n")
|
|
|
|
(org-html--build-mathjax-config info)
|
|
|
|
"<script type='text/javascript'>"
|
|
|
|
" $(document).ready(function () { $.deck('.slide'); });"
|
|
|
|
"</script>"
|
2013-03-03 12:59:39 -05:00
|
|
|
(org-html--build-head info)
|
2013-03-11 17:49:39 -04:00
|
|
|
"<style type='text/css'>"
|
|
|
|
org-deck-toc-styles
|
|
|
|
(when (plist-get info :section-numbers)
|
|
|
|
"#table-of-contents ul li {list-style-type: none;}")
|
|
|
|
(format "#%s, #%s {%s}"
|
2013-03-12 17:10:30 -04:00
|
|
|
(nth 2 (assq 'preamble org-html-divs))
|
|
|
|
(nth 2 (assq 'postamble org-html-divs))
|
2013-03-16 15:10:53 -04:00
|
|
|
(nth 1 (assq 'both org-deck-pre/postamble-styles)))
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "#%s {%s}"
|
2013-03-12 17:10:30 -04:00
|
|
|
(nth 2 (assq 'preamble org-html-divs))
|
2013-03-16 15:10:53 -04:00
|
|
|
(nth 1 (assq 'preamble org-deck-pre/postamble-styles)))
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "#%s {%s}"
|
2013-03-12 17:10:30 -04:00
|
|
|
(nth 2 (assq 'postamble org-html-divs))
|
2013-03-16 15:10:53 -04:00
|
|
|
(nth 1 (assq 'postamble org-deck-pre/postamble-styles)))
|
2013-03-11 17:49:39 -04:00
|
|
|
org-deck-styles
|
|
|
|
"</style>"
|
2013-02-25 13:09:31 -05:00
|
|
|
"</head>"
|
|
|
|
"<body>"
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "<%s id='%s' class='deck-container'>"
|
2013-03-12 17:10:30 -04:00
|
|
|
(nth 1 (assq 'content org-html-divs))
|
|
|
|
(nth 2 (assq 'content org-html-divs)))
|
2013-03-16 15:10:53 -04:00
|
|
|
(org-html--build-pre/postamble 'preamble info)
|
2013-02-25 13:09:31 -05:00
|
|
|
;; title page
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "<%s id='title-slide' class='slide'>"
|
2013-03-12 17:10:30 -04:00
|
|
|
(plist-get info :html-container))
|
2013-03-16 15:10:53 -04:00
|
|
|
(format-spec org-deck-title-slide-template (org-html-format-spec info))
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "</%s>" (plist-get info :html-container))
|
2013-02-25 13:09:31 -05:00
|
|
|
;; toc page
|
|
|
|
(let ((depth (plist-get info :with-toc)))
|
|
|
|
(when depth (org-deck-toc depth info)))
|
|
|
|
contents
|
|
|
|
(mapconcat
|
|
|
|
(lambda (snippet)
|
|
|
|
(with-temp-buffer (insert-file-contents snippet)
|
|
|
|
(buffer-string)))
|
|
|
|
(plist-get pkg-info :snippets) "\n")
|
2013-03-16 15:10:53 -04:00
|
|
|
(org-html--build-pre/postamble 'postamble info)
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "</%s>" (nth 1 (assq 'content org-html-divs)))
|
2013-02-25 13:09:31 -05:00
|
|
|
"</body>"
|
|
|
|
"</html>\n") "\n")))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck--build-meta-info (info)
|
|
|
|
"Return meta tags for exported document.
|
|
|
|
INFO is a plist used as a communication channel."
|
|
|
|
(let* ((title (org-export-data (plist-get info :title) info))
|
2013-02-25 13:09:31 -05:00
|
|
|
(author (and (plist-get info :with-author)
|
|
|
|
(let ((auth (plist-get info :author)))
|
|
|
|
(and auth (org-export-data auth info)))))
|
|
|
|
(date (and (plist-get info :with-date)
|
2013-04-02 18:02:15 -04:00
|
|
|
(let ((date (org-export-get-date info)))
|
2013-02-25 13:09:31 -05:00
|
|
|
(and date (org-export-data date info)))))
|
|
|
|
(description (plist-get info :description))
|
|
|
|
(keywords (plist-get info :keywords)))
|
2013-02-20 10:32:54 -05:00
|
|
|
(mapconcat
|
|
|
|
'identity
|
|
|
|
(list
|
|
|
|
(format "<title>%s</title>" title)
|
2013-03-11 17:49:39 -04:00
|
|
|
(format "<meta http-equiv='Content-Type' content='text/html; charset=%s'/>"
|
2013-02-25 13:09:31 -05:00
|
|
|
(or (and org-html-coding-system
|
|
|
|
(fboundp 'coding-system-get)
|
|
|
|
(coding-system-get
|
|
|
|
org-html-coding-system 'mime-charset))
|
|
|
|
"iso-8859-1"))
|
2013-02-20 10:32:54 -05:00
|
|
|
(mapconcat
|
|
|
|
(lambda (attr)
|
2013-02-25 13:09:31 -05:00
|
|
|
(when (< 0 (length (car attr)))
|
|
|
|
(format "<meta name='%s' content='%s'/>\n"
|
|
|
|
(nth 1 attr) (car attr))))
|
2013-02-20 10:32:54 -05:00
|
|
|
(list '("Org-mode" "generator")
|
2013-02-25 13:09:31 -05:00
|
|
|
`(,author "author")
|
|
|
|
`(,description "description")
|
|
|
|
`(,keywords "keywords")) "")) "\n")))
|
2013-02-20 10:32:54 -05:00
|
|
|
(defun org-deck-export-as-html
|
|
|
|
(&optional async subtreep visible-only body-only ext-plist)
|
|
|
|
"Export current buffer to an HTML buffer.
|
|
|
|
|
|
|
|
If narrowing is active in the current buffer, only export its
|
|
|
|
narrowed part.
|
|
|
|
|
|
|
|
If a region is active, export that region.
|
|
|
|
|
|
|
|
A non-nil optional argument ASYNC means the process should happen
|
|
|
|
asynchronously. The resulting buffer should be accessible
|
|
|
|
through the `org-export-stack' interface.
|
|
|
|
|
|
|
|
When optional argument SUBTREEP is non-nil, export the sub-tree
|
|
|
|
at point, extracting information from the headline properties
|
|
|
|
first.
|
|
|
|
|
|
|
|
When optional argument VISIBLE-ONLY is non-nil, don't export
|
|
|
|
contents of hidden elements.
|
|
|
|
|
|
|
|
When optional argument BODY-ONLY is non-nil, only write code
|
|
|
|
between \"<body>\" and \"</body>\" tags.
|
|
|
|
|
|
|
|
EXT-PLIST, when provided, is a property list with external
|
|
|
|
parameters overriding Org default settings, but still inferior to
|
|
|
|
file-local settings.
|
|
|
|
|
|
|
|
Export is done in a buffer named \"*Org deck.js Export*\", which
|
|
|
|
will be displayed when `org-export-show-temporary-export-buffer'
|
|
|
|
is non-nil."
|
|
|
|
(interactive)
|
Export back-ends: Apply changes to export functions
* contrib/lisp/ox-confluence.el (org-confluence-export-as-confluence):
* contrib/lisp/ox-deck.el (org-deck-export-as-html,
org-deck-export-to-html):
* contrib/lisp/ox-freemind.el (org-freemind-export-to-freemind):
* contrib/lisp/ox-groff.el (org-groff-export-to-groff,
org-groff-export-to-pdf):
* contrib/lisp/ox-koma-letter.el (org-koma-letter-export-as-latex,
org-koma-letter-export-to-latex, org-koma-letter-export-to-pdf):
* contrib/lisp/ox-rss.el (org-rss-export-as-rss,
org-rss-export-to-rss):
* contrib/lisp/ox-s5.el (org-s5-export-as-html,
org-s5-export-to-html):
* contrib/lisp/ox-taskjuggler.el (org-taskjuggler-export):
* lisp/ob-haskell.el:
* lisp/ox-ascii.el (org-ascii-export-as-ascii,
org-ascii-export-to-ascii):
* lisp/ox-beamer.el (org-beamer-export-as-latex,
org-beamer-export-to-latex, org-beamer-export-to-pdf):
* lisp/ox-html.el (org-html-export-as-html, org-html-export-to-html):
* lisp/ox-icalendar.el (org-icalendar-export-to-ics):
* lisp/ox-latex.el (org-latex-export-as-latex,
org-latex-export-to-pdf):
* lisp/ox-man.el (org-man-export-to-man, org-man-export-to-pdf):
* lisp/ox-md.el (org-md-export-as-markdown,
org-md-export-to-markdown):
* lisp/ox-odt.el (org-odt-export-to-odt):
* lisp/ox-org.el (org-org-export-as-org, org-org-export-to-org):
* lisp/ox-publish.el (org-publish-org-to):
* lisp/ox-texinfo.el (org-texinfo-export-to-texinfo,
org-texinfo-export-to-info):
* testing/lisp/test-ob-exp.el (test-ob-exp/org-babel-exp-src-blocks/w-no-file):
2013-08-07 04:35:42 -04:00
|
|
|
(org-export-to-buffer 'deck "*Org deck.js Export*"
|
|
|
|
async subtreep visible-only body-only ext-plist (lambda () (nxml-mode))))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck-export-to-html
|
|
|
|
(&optional async subtreep visible-only body-only ext-plist)
|
|
|
|
"Export current buffer to a deck.js HTML file.
|
|
|
|
|
|
|
|
If narrowing is active in the current buffer, only export its
|
|
|
|
narrowed part.
|
|
|
|
|
|
|
|
If a region is active, export that region.
|
|
|
|
|
|
|
|
A non-nil optional argument ASYNC means the process should happen
|
|
|
|
asynchronously. The resulting file should be accessible through
|
|
|
|
the `org-export-stack' interface.
|
|
|
|
|
|
|
|
When optional argument SUBTREEP is non-nil, export the sub-tree
|
|
|
|
at point, extracting information from the headline properties
|
|
|
|
first.
|
|
|
|
|
|
|
|
When optional argument VISIBLE-ONLY is non-nil, don't export
|
|
|
|
contents of hidden elements.
|
|
|
|
|
|
|
|
When optional argument BODY-ONLY is non-nil, only write code
|
|
|
|
between \"<body>\" and \"</body>\" tags.
|
|
|
|
|
|
|
|
EXT-PLIST, when provided, is a property list with external
|
|
|
|
parameters overriding Org default settings, but still inferior to
|
|
|
|
file-local settings.
|
|
|
|
|
|
|
|
Return output file's name."
|
|
|
|
(interactive)
|
|
|
|
(let* ((extension (concat "." org-html-extension))
|
2013-02-25 13:09:31 -05:00
|
|
|
(file (org-export-output-file-name extension subtreep))
|
Export back-ends: Apply changes to export functions
* contrib/lisp/ox-confluence.el (org-confluence-export-as-confluence):
* contrib/lisp/ox-deck.el (org-deck-export-as-html,
org-deck-export-to-html):
* contrib/lisp/ox-freemind.el (org-freemind-export-to-freemind):
* contrib/lisp/ox-groff.el (org-groff-export-to-groff,
org-groff-export-to-pdf):
* contrib/lisp/ox-koma-letter.el (org-koma-letter-export-as-latex,
org-koma-letter-export-to-latex, org-koma-letter-export-to-pdf):
* contrib/lisp/ox-rss.el (org-rss-export-as-rss,
org-rss-export-to-rss):
* contrib/lisp/ox-s5.el (org-s5-export-as-html,
org-s5-export-to-html):
* contrib/lisp/ox-taskjuggler.el (org-taskjuggler-export):
* lisp/ob-haskell.el:
* lisp/ox-ascii.el (org-ascii-export-as-ascii,
org-ascii-export-to-ascii):
* lisp/ox-beamer.el (org-beamer-export-as-latex,
org-beamer-export-to-latex, org-beamer-export-to-pdf):
* lisp/ox-html.el (org-html-export-as-html, org-html-export-to-html):
* lisp/ox-icalendar.el (org-icalendar-export-to-ics):
* lisp/ox-latex.el (org-latex-export-as-latex,
org-latex-export-to-pdf):
* lisp/ox-man.el (org-man-export-to-man, org-man-export-to-pdf):
* lisp/ox-md.el (org-md-export-as-markdown,
org-md-export-to-markdown):
* lisp/ox-odt.el (org-odt-export-to-odt):
* lisp/ox-org.el (org-org-export-as-org, org-org-export-to-org):
* lisp/ox-publish.el (org-publish-org-to):
* lisp/ox-texinfo.el (org-texinfo-export-to-texinfo,
org-texinfo-export-to-info):
* testing/lisp/test-ob-exp.el (test-ob-exp/org-babel-exp-src-blocks/w-no-file):
2013-08-07 04:35:42 -04:00
|
|
|
(org-export-coding-system org-html-coding-system))
|
|
|
|
(org-export-to-file 'deck file
|
|
|
|
async subtreep visible-only body-only ext-plist)))
|
2013-02-20 10:32:54 -05:00
|
|
|
|
|
|
|
(defun org-deck-publish-to-html (plist filename pub-dir)
|
|
|
|
"Publish an org file to deck.js HTML Presentation.
|
|
|
|
FILENAME is the filename of the Org file to be published. PLIST
|
|
|
|
is the property list for the given project. PUB-DIR is the
|
|
|
|
publishing directory. Returns output file name."
|
|
|
|
(org-publish-org-to 'deck filename ".html" plist pub-dir))
|
|
|
|
|
|
|
|
(provide 'ox-deck)
|
2013-03-15 11:52:46 -04:00
|
|
|
|
|
|
|
;;; ox-deck.el ends here
|