1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

Apply changes to slideshow exporter to use new `org-html-divs'

specification.

* contrib/lisp/ox-deck.el:
  - Rename header/footer options and methods to preamble/postamble to
  be more consistent with underlining html exporter. Also remove
  included wrapper section to allow for using the element specified in
  `org-html-divs'.
  - add `org-deck-preamble-postamble-styles' variable
  - Rename `org-deck-title-page-styles' to `org-deck-styles'.
  - Rename `org-deck-title-page-* to `org-deck-title-slide-*'

(org-deck-template):
        - use :html-doctype instead of forcing html5.
        - use xhtml valid meta charset tag
        - Use elements specified in `org-html-divs'.
        - Cleanup embeded css (move into a single style section)

* contrib/lisp/ox-s5.el:
  - Use `org-html-div' container class for content
  - Change header/footer templates to remove wrapper from
  customization string.
(org-s5-toc): Use :html-container instead of hard-coded div.
(org-s5-template): use :html-doctype, :html-container and
`org-html-divs' container class.
This commit is contained in:
Rick Frankel 2013-03-11 17:49:39 -04:00
parent acbf00ea24
commit 60830fa4d2
2 changed files with 212 additions and 183 deletions

View File

@ -166,89 +166,92 @@ Can be overriden with the DECK_BASE_URL property."
:group 'org-export-deck
:type 'string)
(defcustom org-deck-footer-template
(defcustom org-deck-postamble-template
"<h1>%author - %title</h1>"
"Format template to specify footer div.
Completed using `org-fill-template'.
Optional keys include %author, %email, %file, %title and %date.
This is included in a <footer> section."
"Format template to specify the postamble section of document.
Completed using `org-fill-template', optional keys include
%author, %email, %file, %title and %date.
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
title at the bottom of each slide. See also
`org-deck-preamble-postamble-styles'."
:group 'org-export-deck
:type 'string)
(defcustom org-deck-header-template ""
"Format template to specify page. Completed using `org-fill-template'.
Optional keys include %author, %email, %file, %title and %date.
This is included in a <header> section."
(defcustom org-deck-preamble-template ""
"Format template to specify the preamble section of the document.
Completed using `org-fill-template', optional keys include
%author, %email, %file, %title and %date.
This is included before the content section of the document and
would normally be a header for the presentation. See also
`org-deck-preamble-postamble-styles'."
:group 'org-export-deck
:type 'string)
(defcustom org-deck-title-page-style
"<style type='text/css'>
header, footer { left: 5px; width: 100% }
header { position: absolute; top: 10px; }
#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;
}
</style>"
"CSS styles to use for title page"
(defvar org-deck-preamble-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'.")
(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'.
Note that when the headline numbering option is true, a \"list-style: none\"
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."
:group 'org-export-deck
:type 'string)
(defcustom org-deck-title-page-template
"<div class='slide' id='title-slide'>
<h1>%title</h1>
(defcustom org-deck-title-slide-template
"<h1>%title</h1>
<h2>%author</h2>
<h2>%email</h2>
<h2>%date</h2>
</div>"
"Format template to specify title page div.
Completed using `org-fill-template'.
Optional keys include %author, %email, %file, %title and %date.
Note that the wrapper div must include the class \"slide\"."
:group 'org-export-deck
:type 'string)
<h2>%date</h2>"
"Format template to specify title page section.
Completed using `org-fill-template', optional keys include
%author, %email, %file, %title and %date.
(defcustom org-deck-toc-style
"<style type='text/css'>
header, footer { left: 5px; width: 100% }
header { position: absolute; top: 10px; }
#table-of-contents 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;
}
</style>"
"CSS styles to use for title page"
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\"."
:group 'org-export-deck
:type 'string)
(defun org-deck-toc (depth info)
(concat
"<div id=\"table-of-contents\" class=\"slide\">\n"
(format "<h2>%s</h2>\n"
(org-html--translate "Table of Contents" info))
(format "<%s id='table-of-contents' class='slide'>\n"
(plist-get info :html-container))
(format "<h2>%s</h2>\n" (org-html--translate "Table of Contents" info))
(org-html--toc-text
(mapcar
(lambda (headline)
@ -280,7 +283,7 @@ Note that the wrapper div must include the class \"slide\"."
title)
(org-export-get-relative-level headline info))))
(org-export-collect-headlines info depth)))
"</div>\n"))
(format "</%s>\n" (plist-get info :html-container))))
(defun org-deck--get-packages (info)
(let ((prefix (concat (plist-get info :deck-base-url) "/"))
@ -362,17 +365,17 @@ holding export options."
(mapconcat
'identity
(list
"<!DOCTYPE html>"
(plist-get info :html-doctype)
(let ((lang (plist-get info :language)))
(mapconcat
(lambda (x)
(apply
'format
"<!--%s <html class='no-js %s' lang='%s'> %s<![endif]-->"
"<!--%s <html %s lang='%s' xmlns='http://www.w3.org/1999/xhtml'> %s<![endif]-->"
x))
(list `("[if lt IE 7]>" "ie6" ,lang "")
`("[if IE 7]>" "ie7" ,lang "")
`("[if IE 8]>" "ie8" ,lang "")
(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 "")
`("[if gt IE 8]><!-->" "" ,lang "<!--")) "\n"))
"<head>"
(org-deck--build-meta-info info)
@ -381,13 +384,6 @@ holding export options."
(format
"<link rel='stylesheet' href='%s' type='text/css' />" sheet))
(plist-get pkg-info :sheets) "\n")
"<style type='text/css'>"
"#table-of-contents a {color: inherit;}"
"#table-of-contents ul {margin-bottom: 0;}"
(when (plist-get info :section-numbers)
"#table-of-contents ul li {list-style-type: none;}")
"</style>"
""
(mapconcat
(lambda (script)
(format
@ -398,17 +394,39 @@ holding export options."
" $(document).ready(function () { $.deck('.slide'); });"
"</script>"
(org-html--build-head info)
org-deck-title-page-style
"<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}"
(nth 2 (assq 'preamble org-html-divs))
(nth 2 (assq 'postamble org-html-divs))
(nth 1 (assq 'both org-deck-preamble-postamble-styles)))
(format "#%s {%s}"
(nth 2 (assq 'preamble org-html-divs))
(nth 1 (assq 'preamble org-deck-preamble-postamble-styles)))
(format "#%s {%s}"
(nth 2 (assq 'postamble org-html-divs))
(nth 1 (assq 'postamble org-deck-preamble-postamble-styles)))
org-deck-styles
"</style>"
"</head>"
"<body>"
"<header class='deck-status'>"
(format "<%s id='%s' class='deck-status'>"
(nth 1 (assq 'preamble org-html-divs))
(nth 2 (assq 'preamble org-html-divs)))
(org-fill-template
org-deck-header-template (org-deck-template-alist info))
"</header>"
"<div class='deck-container'>"
org-deck-preamble-template (org-deck-template-alist info))
(format "</%s>" (nth 1 (assq 'preamble org-html-divs)))
(format "<%s id='%s' class='deck-container'>"
(nth 1 (assq 'content org-html-divs))
(nth 2 (assq 'content org-html-divs)))
;; title page
(format "<%s id='title-slide' class='slide'>"
(plist-get info :html-container))
(org-fill-template
org-deck-title-page-template (org-deck-template-alist info))
org-deck-title-slide-template (org-deck-template-alist info))
(format "</%s>" (plist-get info :html-container))
;; toc page
(let ((depth (plist-get info :with-toc)))
(when depth (org-deck-toc depth info)))
@ -418,11 +436,13 @@ holding export options."
(with-temp-buffer (insert-file-contents snippet)
(buffer-string)))
(plist-get pkg-info :snippets) "\n")
"<footer class='deck-status'>"
(format "<%s id='%s' class='deck-status'>"
(nth 1 (assq 'postamble org-html-divs))
(nth 2 (assq 'postamble org-html-divs)))
(org-fill-template
org-deck-footer-template (org-deck-template-alist info))
"</footer>"
"</div>"
org-deck-postamble-template (org-deck-template-alist info))
(format "</%s>" (nth 1 (assq 'postamble org-html-divs)))
(format "</%s>" (nth 1 (assq 'content org-html-divs)))
"</body>"
"</html>\n") "\n")))
@ -442,7 +462,7 @@ INFO is a plist used as a communication channel."
'identity
(list
(format "<title>%s</title>" title)
(format "<meta charset='%s' />"
(format "<meta http-equiv='Content-Type' content='text/html; charset=%s'/>"
(or (and org-html-coding-system
(fboundp 'coding-system-get)
(coding-system-get

View File

@ -56,9 +56,9 @@
((?H "To temporary buffer" org-s5-export-as-html)
(?h "To file" org-s5-export-to-html)
(?o "To file and open"
(lambda (a s v b)
(if a (org-s5-export-to-html t s v b)
(org-open-file (org-s5-export-to-html nil s v b)))))))
(lambda (a s v b)
(if a (org-s5-export-to-html t s v b)
(org-open-file (org-s5-export-to-html nil s v b)))))))
:options-alist
((:html-link-home "HTML_LINK_HOME" nil nil)
(:html-link-up "HTML_LINK_UP" nil nil)
@ -118,96 +118,97 @@ Can be overriden with the S5_UI_URL property."
:type '(choice (const hidden) (const visibile)))
(defcustom org-s5-footer-template
"<div id=\"footer\">
<h1>%author - %title</h1>
</div>"
"Format template to specify footer div. Completed using
`org-fill-template'.
Optional keys include %author, %email, %file, %title and %date.
Note that the div id must be \"footer\"."
"<h1>%author - %title</h1>"
"Format template to specify footer div.
Completed using `org-fill-template', optional keys include
%author, %email, %file, %title and %date.
It will be wrapped in a <div> with the id \"footer\""
:group 'org-export-s5
:type 'string)
(defcustom org-s5-header-template "<div id=\"header\"></div>"
"Format template to specify footer div. Completed using
`org-fill-template'.
Optional keys include %author, %email, %file, %title and %date.
Note that the div id must be \"header\"."
(defcustom org-s5-header-template ""
"Format template to specify header div.
Completed using `org-fill-template', optional keys include
%author, %email, %file, %title and %date.
It will be wrapped in a <div> with the id \"header\""
:group 'org-export-s5
:type 'string)
(defcustom org-s5-title-page-template
"<div class=\"slide title-page\">
<h1>%title</h1>
<h1>%author</h1>
<h1>%email</h1>
<h1>%date</h1>
</div>"
"Format template to specify title page div. Completed using
`org-fill-template'.
Optional keys include %author, %email, %file, %title and %date.
Note that the wrapper div must include the class \"slide\"."
(defcustom org-s5-title-slide-template
"<h1>%title</h1>
<h2>%author</h2>
<h2>%email</h2>
<h2>%date</h2>"
"Format template to specify title page section.
Completed using `org-fill-template', optional keys include
%author, %email, %file, %title and %date.
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\"."
:group 'org-export-s5
:type 'string)
(defun org-s5--format-toc-headline (headline info)
"Return an appropriate table of contents entry for HEADLINE.
Note that (currently) the S5 exporter does not support deep links,
so the table of contents is not \"active\".
INFO is a plist used as a communication channel."
(let* ((headline-number (org-export-get-headline-number headline info))
(section-number
(and (not (org-export-low-level-p headline info))
(org-export-numbered-headline-p headline info)
(concat (mapconcat 'number-to-string headline-number ".") ". ")))
(tags (and (eq (plist-get info :with-tags) t)
(org-export-get-tags headline info))))
(section-number
(and (not (org-export-low-level-p headline info))
(org-export-numbered-headline-p headline info)
(concat (mapconcat 'number-to-string headline-number ".") ". ")))
(tags (and (eq (plist-get info :with-tags) t)
(org-export-get-tags headline info))))
(concat section-number
(org-export-data
(org-export-get-alt-title headline info) info)
(and tags "&nbsp;&nbsp;&nbsp;") (org-html--tags tags))))
(org-export-data
(org-export-get-alt-title headline info) info)
(and tags "&nbsp;&nbsp;&nbsp;") (org-html--tags tags))))
(defun org-s5-toc (depth info)
(let* ((headlines (org-export-collect-headlines info depth))
(toc-entries
(mapcar (lambda (headline)
(cons (org-s5--format-toc-headline headline info)
(org-export-get-relative-level headline info)))
(org-export-collect-headlines info depth))))
(toc-entries
(mapcar (lambda (headline)
(cons (org-s5--format-toc-headline headline info)
(org-export-get-relative-level headline info)))
(org-export-collect-headlines info depth))))
(when toc-entries
(concat
"<div id=\"table-of-contents\" class=\"slide\">\n"
(format "<%s id='table-of-contents' class='slide'>\n"
(plist-get info :html-container))
(format "<h1>%s</h1>\n"
(org-html--translate "Table of Contents" info))
(org-html--translate "Table of Contents" info))
"<div id=\"text-table-of-contents\">"
(org-html--toc-text toc-entries)
"</div>\n"
"</div>\n"))))
(format "</%s>\n" (plist-get info :html-container))))))
(defun org-s5--build-head (info)
(let* ((dir (plist-get info :s5-ui-url))
(theme (or (plist-get info :s5-theme-file) "default/slides.css")))
(theme (or (plist-get info :s5-theme-file) "default/slides.css")))
(mapconcat
'identity
(list
"<!-- style sheet links -->"
(mapconcat
(lambda (list)
(format
(concat
"<link rel='stylesheet' href='%s/default/%s' type='text/css'"
" media='%s' id='%s' />")
dir (nth 0 list) (nth 1 list) (nth 2 list)))
(format
(concat
"<link rel='stylesheet' href='%s/default/%s' type='text/css'"
" media='%s' id='%s' />")
dir (nth 0 list) (nth 1 list) (nth 2 list)))
(list
'("outline.css" "screen" "outlineStyle")
'("print.css" "print" "slidePrint")
'("opera.css" "projection" "operaFix")) "\n")
'("outline.css" "screen" "outlineStyle")
'("print.css" "print" "slidePrint")
'("opera.css" "projection" "operaFix")) "\n")
(format (concat
"<link rel='stylesheet' href='%s' type='text/css'"
" media='screen' id='slideProj' />")
(if (string-match-p "^\\(http\\|/\\)" theme) theme
(concat dir "/" theme)))
"<link rel='stylesheet' href='%s' type='text/css'"
" media='screen' id='slideProj' />")
(if (string-match-p "^\\(http\\|/\\)" theme) theme
(concat dir "/" theme)))
"<!-- S5 JS -->"
(concat
"<script src='" dir
@ -217,7 +218,7 @@ INFO is a plist used as a communication channel."
(concat
(org-html--build-meta-info info)
(format "<meta name=\"version\" content=\"S5 %s\" />\n"
(plist-get info :s5-version))
(plist-get info :s5-version))
(format "<meta name='defaultView' content='%s' />\n"
(plist-get info :s5-default-view))
(format "<meta name='controlVis' content='%s' />"
@ -239,16 +240,16 @@ If a containing headline has the property :INCREMENTAL,
then the \"incremental\" class will be added to the to the list,
which will make the list into a \"build\"."
(let* ((type (org-element-property :type plain-list))
(tag (case type
(ordered "ol")
(unordered "ul")
(descriptive "dl"))))
(tag (case type
(ordered "ol")
(unordered "ul")
(descriptive "dl"))))
(format "%s\n%s%s"
(format
"<%s class='org-%s%s'>" tag tag
(if (org-export-get-node-property :INCREMENTAL plain-list t)
" incremental" ""))
contents (org-html-end-plain-list type))))
(format
"<%s class='org-%s%s'>" tag tag
(if (org-export-get-node-property :INCREMENTAL plain-list t)
" incremental" ""))
contents (org-html-end-plain-list type))))
(defun org-s5-template-alist (info)
`(
@ -271,10 +272,9 @@ holding export options."
(mapconcat
'identity
(list
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
(plist-get info :html-doctype)
(format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">"
(plist-get info :language) (plist-get info :language))
(plist-get info :language) (plist-get info :language))
"<head>"
(org-s5--build-meta-info info)
(org-s5--build-head info)
@ -285,20 +285,29 @@ holding export options."
"<div class=\"layout\">"
"<div id=\"controls\"><!-- no edit --></div>"
"<div id=\"currentSlide\"><!-- no edit --></div>"
"<div id='header'>"
(org-fill-template
org-s5-header-template (org-s5-template-alist info))
"</div>"
"<div id='footer'>"
(org-fill-template
org-s5-footer-template (org-s5-template-alist info))
"</div>"
(format "<div id=\"%s\" class=\"presentation\">" (nth 1 org-html-divs))
"</div>"
(format "<%s id=\"%s\" class=\"presentation\">"
(nth 1 (assq 'content org-html-divs))
(nth 2 (assq 'content org-html-divs)))
;; title page
(format "<%s id='title-slide' class='slide'>"
(plist-get info :html-container))
(org-fill-template
org-s5-title-page-template (org-s5-template-alist info))
org-s5-title-slide-template (org-s5-template-alist info))
(format "</%s>" (plist-get info :html-container))
;; table of contents.
(let ((depth (plist-get info :with-toc)))
(when depth (org-s5-toc depth info)))
contents
"</div>"
(format "</%s>" (nth 1 (assq 'content org-html-divs)))
"</body>"
"</html>\n") "\n"))
@ -335,21 +344,21 @@ is non-nil."
(interactive)
(if async
(org-export-async-start
(lambda (output)
(with-current-buffer (get-buffer-create "*Org S5 Export*")
(erase-buffer)
(insert output)
(goto-char (point-min))
(nxml-mode)
(org-export-add-to-stack (current-buffer) 's5)))
`(org-export-as 's5 ,subtreep ,visible-only ,body-only ',ext-plist))
(lambda (output)
(with-current-buffer (get-buffer-create "*Org S5 Export*")
(erase-buffer)
(insert output)
(goto-char (point-min))
(nxml-mode)
(org-export-add-to-stack (current-buffer) 's5)))
`(org-export-as 's5 ,subtreep ,visible-only ,body-only ',ext-plist))
(let ((outbuf (org-export-to-buffer
's5 "*Org S5 Export*"
subtreep visible-only body-only ext-plist)))
's5 "*Org S5 Export*"
subtreep visible-only body-only ext-plist)))
;; Set major mode.
(with-current-buffer outbuf (nxml-mode))
(when org-export-show-temporary-export-buffer
(switch-to-buffer-other-window outbuf)))))
(switch-to-buffer-other-window outbuf)))))
(defun org-s5-export-to-html
(&optional async subtreep visible-only body-only ext-plist)
@ -381,18 +390,18 @@ file-local settings.
Return output file's name."
(interactive)
(let* ((extension (concat "." org-html-extension))
(file (org-export-output-file-name extension subtreep))
(org-export-coding-system org-html-coding-system))
(file (org-export-output-file-name extension subtreep))
(org-export-coding-system org-html-coding-system))
(if async
(org-export-async-start
(lambda (f) (org-export-add-to-stack f 's5))
(let ((org-export-coding-system org-html-coding-system))
`(expand-file-name
(org-export-to-file
's5 ,file ,subtreep ,visible-only ,body-only ',ext-plist))))
(org-export-async-start
(lambda (f) (org-export-add-to-stack f 's5))
(let ((org-export-coding-system org-html-coding-system))
`(expand-file-name
(org-export-to-file
's5 ,file ,subtreep ,visible-only ,body-only ',ext-plist))))
(let ((org-export-coding-system org-html-coding-system))
(org-export-to-file
's5 file subtreep visible-only body-only ext-plist)))))
(org-export-to-file
's5 file subtreep visible-only body-only ext-plist)))))
(defun org-s5-publish-to-html (plist filename pub-dir)
"Publish an org file to S5 HTML Presentation.