##// END OF EJS Templates
remove special handling of speaker notes
MinRK -
Show More
@@ -1,94 +1,67 b''
1 """Module that pre-processes the notebook for export via Reveal.
1 """Module that pre-processes the notebook for export via Reveal.
2 """
2 """
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4 # Copyright (c) 2013, the IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
5 #
5 #
6 # Distributed under the terms of the Modified BSD License.
6 # Distributed under the terms of the Modified BSD License.
7 #
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10
10
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 import os
15 import os
16 import urllib2
16 import urllib2
17
17
18 from .base import Preprocessor
18 from .base import Preprocessor
19 from IPython.utils.traitlets import Unicode, Bool
19 from IPython.utils.traitlets import Unicode, Bool
20
20
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 # Classes and functions
22 # Classes and functions
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 class RevealHelpPreprocessor(Preprocessor):
25 class RevealHelpPreprocessor(Preprocessor):
26
26
27 url_prefix = Unicode('//cdn.jsdelivr.net/reveal.js/2.4.0',
27 url_prefix = Unicode('https://cdn.jsdelivr.net/reveal.js/2.4.0', config=True,
28 config=True,
28 help="""The URL prefix for reveal.js.
29 help="""If you want to use a local reveal.js library,
29 This can be a a relative URL for a local copy of reveal.js,
30 use 'url_prefix':'reveal.js' in your config object.""")
30 or point to a CDN.
31
31
32 speaker_notes = Bool(False,
32 For speaker notes to work, a local reveal.js must be used.
33 config=True,
33 """
34 help="""If you want to use the speaker notes
34 )
35 set this to True.""")
36
35
37 def preprocess(self, nb, resources):
36 def preprocess(self, nb, resources):
38 """
37 """
39 Called once to 'preprocess' contents of the notebook.
38 Called once to 'preprocess' contents of the notebook.
40
39
41 Parameters
40 Parameters
42 ----------
41 ----------
43 nb : NotebookNode
42 nb : NotebookNode
44 Notebook being converted
43 Notebook being converted
45 resources : dictionary
44 resources : dictionary
46 Additional resources used in the conversion process. Allows
45 Additional resources used in the conversion process. Allows
47 preprocessors to pass variables into the Jinja engine.
46 preprocessors to pass variables into the Jinja engine.
48 """
47 """
49
48
50 for worksheet in nb.worksheets :
49 for worksheet in nb.worksheets :
51 for index, cell in enumerate(worksheet.cells):
50 for index, cell in enumerate(worksheet.cells):
52
51
53 #Make sure the cell has slideshow metadata.
52 #Make sure the cell has slideshow metadata.
54 cell.metadata.align_type = cell.get('metadata', {}).get('slideshow', {}).get('align_type', 'Left')
53 cell.metadata.align_type = cell.get('metadata', {}).get('slideshow', {}).get('align_type', 'Left')
55 cell.metadata.slide_type = cell.get('metadata', {}).get('slideshow', {}).get('slide_type', '-')
54 cell.metadata.slide_type = cell.get('metadata', {}).get('slideshow', {}).get('slide_type', '-')
56
55
57 #Get the slide type. If type is start of subslide or slide,
56 #Get the slide type. If type is start of subslide or slide,
58 #end the last subslide/slide.
57 #end the last subslide/slide.
59 if cell.metadata.slide_type in ['slide']:
58 if cell.metadata.slide_type in ['slide']:
60 worksheet.cells[index - 1].metadata.slide_helper = 'slide_end'
59 worksheet.cells[index - 1].metadata.slide_helper = 'slide_end'
61 if cell.metadata.slide_type in ['subslide']:
60 if cell.metadata.slide_type in ['subslide']:
62 worksheet.cells[index - 1].metadata.slide_helper = 'subslide_end'
61 worksheet.cells[index - 1].metadata.slide_helper = 'subslide_end'
63
62
64
63
65 if not isinstance(resources['reveal'], dict):
64 if not isinstance(resources['reveal'], dict):
66 resources['reveal'] = {}
65 resources['reveal'] = {}
67 resources['reveal']['url_prefix'] = self.url_prefix
66 resources['reveal']['url_prefix'] = self.url_prefix
68 resources['reveal']['notes_prefix'] = self.url_prefix
69
70 cdn = 'http://cdn.jsdelivr.net/reveal.js/2.4.0'
71 local = 'local'
72 html_path = 'plugin/notes/notes.html'
73 js_path = 'plugin/notes/notes.js'
74
75 html_infile = os.path.join(cdn, html_path)
76 js_infile = os.path.join(cdn, js_path)
77 html_outfile = os.path.join(local, html_path)
78 js_outfile = os.path.join(local, js_path)
79
80 if self.speaker_notes:
81 if 'outputs' not in resources:
82 resources['outputs'] = {}
83 resources['outputs'][html_outfile] = self.notes_helper(html_infile)
84 resources['outputs'][js_outfile] = self.notes_helper(js_infile)
85 resources['reveal']['notes_prefix'] = local
86
87 return nb, resources
67 return nb, resources
88
89 def notes_helper(self, infile):
90 """Helper function to get the content from an url."""
91
92 content = urllib2.urlopen(infile).read()
93
94 return content
@@ -1,185 +1,185 b''
1 {%- extends 'reveal_internals/slides.tpl' -%}
1 {%- extends 'reveal_internals/slides.tpl' -%}
2
2
3
3
4 {% block header %}
4 {% block header %}
5 <!DOCTYPE html>
5 <!DOCTYPE html>
6 <html>
6 <html>
7 <head>
7 <head>
8
8
9 <meta charset="utf-8" />
9 <meta charset="utf-8" />
10 <meta http-equiv="X-UA-Compatible" content="chrome=1">
10 <meta http-equiv="X-UA-Compatible" content="chrome=1">
11
11
12 <meta name="apple-mobile-web-app-capable" content="yes" />
12 <meta name="apple-mobile-web-app-capable" content="yes" />
13 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
13 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
14
14
15 <!-- General and theme style sheets -->
15 <!-- General and theme style sheets -->
16 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/reveal.css">
16 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/reveal.css">
17 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/theme/simple.css" id="theme">
17 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/theme/simple.css" id="theme">
18
18
19 <!-- For syntax highlighting -->
19 <!-- For syntax highlighting -->
20 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/lib/css/zenburn.css">
20 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/lib/css/zenburn.css">
21
21
22 <!-- If the query includes 'print-pdf', use the PDF print sheet -->
22 <!-- If the query includes 'print-pdf', use the PDF print sheet -->
23 <script>
23 <script>
24 document.write( '<link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
24 document.write( '<link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
25 </script>
25 </script>
26
26
27 <!--[if lt IE 9]>
27 <!--[if lt IE 9]>
28 <script src="{{resources.reveal.url_prefix}}/lib/js/html5shiv.js"></script>
28 <script src="{{resources.reveal.url_prefix}}/lib/js/html5shiv.js"></script>
29 <![endif]-->
29 <![endif]-->
30
30
31 {% for css in resources.inlining.css -%}
31 {% for css in resources.inlining.css -%}
32 <style type="text/css">
32 <style type="text/css">
33 {{ css }}
33 {{ css }}
34 </style>
34 </style>
35 {% endfor %}
35 {% endfor %}
36
36
37 <style type="text/css">
37 <style type="text/css">
38 /* Overrides of notebook CSS for static HTML export */
38 /* Overrides of notebook CSS for static HTML export */
39 .reveal {
39 .reveal {
40 font-size: 20px;
40 font-size: 20px;
41 overflow-y: auto;
41 overflow-y: auto;
42 overflow-x: hidden;
42 overflow-x: hidden;
43 }
43 }
44 .reveal pre {
44 .reveal pre {
45 width: 95%;
45 width: 95%;
46 padding: 0.4em;
46 padding: 0.4em;
47 margin: 0px;
47 margin: 0px;
48 font-family: monospace, sans-serif;
48 font-family: monospace, sans-serif;
49 font-size: 80%;
49 font-size: 80%;
50 box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
50 box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
51 }
51 }
52 .reveal section img {
52 .reveal section img {
53 border: 0px solid black;
53 border: 0px solid black;
54 box-shadow: 0 0 10px rgba(0, 0, 0, 0);
54 box-shadow: 0 0 10px rgba(0, 0, 0, 0);
55 }
55 }
56 .reveal .slides {
56 .reveal .slides {
57 text-align: left;
57 text-align: left;
58 }
58 }
59 .reveal.fade {
59 .reveal.fade {
60 opacity: 1;
60 opacity: 1;
61 }
61 }
62 div.input_area {
62 div.input_area {
63 padding: 0.06em;
63 padding: 0.06em;
64 }
64 }
65 div.code_cell {
65 div.code_cell {
66 background-color: transparent;
66 background-color: transparent;
67 }
67 }
68 div.prompt {
68 div.prompt {
69 width: 11ex;
69 width: 11ex;
70 padding: 0.4em;
70 padding: 0.4em;
71 margin: 0px;
71 margin: 0px;
72 font-family: monospace, sans-serif;
72 font-family: monospace, sans-serif;
73 font-size: 80%;
73 font-size: 80%;
74 text-align: right;
74 text-align: right;
75 }
75 }
76 div.output_area pre {
76 div.output_area pre {
77 font-family: monospace, sans-serif;
77 font-family: monospace, sans-serif;
78 font-size: 80%;
78 font-size: 80%;
79 }
79 }
80 div.output_prompt {
80 div.output_prompt {
81 /* 5px right shift to account for margin in parent container */
81 /* 5px right shift to account for margin in parent container */
82 margin: 5px 5px 0 0;
82 margin: 5px 5px 0 0;
83 }
83 }
84 .rendered_html p {
84 .rendered_html p {
85 text-align: inherit;
85 text-align: inherit;
86 }
86 }
87 </style>
87 </style>
88
88
89 <!-- Custom stylesheet, it must be in the same directory as the html file -->
89 <!-- Custom stylesheet, it must be in the same directory as the html file -->
90 <link rel="stylesheet" href="custom.css">
90 <link rel="stylesheet" href="custom.css">
91
91
92 </head>
92 </head>
93 {% endblock header%}
93 {% endblock header%}
94
94
95
95
96 {% block body %}
96 {% block body %}
97 <body>
97 <body>
98 <div class="reveal">
98 <div class="reveal">
99 <div class="slides">
99 <div class="slides">
100 {{ super() }}
100 {{ super() }}
101 </div>
101 </div>
102 </div>
102 </div>
103
103
104 <!--
104 <!--
105 Uncomment the following block and the addthis_widget.js (see below inside dependencies)
105 Uncomment the following block and the addthis_widget.js (see below inside dependencies)
106 to get enable social buttons.
106 to get enable social buttons.
107 -->
107 -->
108
108
109 <!--
109 <!--
110 <div class="addthis_toolbox addthis_floating_style addthis_32x32_style" style="left:20px;top:20px;">
110 <div class="addthis_toolbox addthis_floating_style addthis_32x32_style" style="left:20px;top:20px;">
111 <a class="addthis_button_twitter"></a>
111 <a class="addthis_button_twitter"></a>
112 <a class="addthis_button_google_plusone_share"></a>
112 <a class="addthis_button_google_plusone_share"></a>
113 <a class="addthis_button_linkedin"></a>
113 <a class="addthis_button_linkedin"></a>
114 <a class="addthis_button_facebook"></a>
114 <a class="addthis_button_facebook"></a>
115 <a class="addthis_button_more"></a>
115 <a class="addthis_button_more"></a>
116 </div>
116 </div>
117 -->
117 -->
118
118
119 <script src="{{resources.reveal.url_prefix}}/lib/js/head.min.js"></script>
119 <script src="{{resources.reveal.url_prefix}}/lib/js/head.min.js"></script>
120
120
121 <script src="{{resources.reveal.url_prefix}}/js/reveal.js"></script>
121 <script src="{{resources.reveal.url_prefix}}/js/reveal.js"></script>
122
122
123 <script>
123 <script>
124
124
125 // Full list of configuration options available here: https://github.com/hakimel/reveal.js#configuration
125 // Full list of configuration options available here: https://github.com/hakimel/reveal.js#configuration
126 Reveal.initialize({
126 Reveal.initialize({
127 controls: true,
127 controls: true,
128 progress: true,
128 progress: true,
129 history: true,
129 history: true,
130
130
131 theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
131 theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
132 transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/none
132 transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/none
133
133
134 // Optional libraries used to extend on reveal.js
134 // Optional libraries used to extend on reveal.js
135 dependencies: [
135 dependencies: [
136 { src: "{{resources.reveal.url_prefix}}/lib/js/classList.js", condition: function() { return !document.body.classList; } },
136 { src: "{{resources.reveal.url_prefix}}/lib/js/classList.js", condition: function() { return !document.body.classList; } },
137 { src: "{{resources.reveal.url_prefix}}/plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
137 { src: "{{resources.reveal.url_prefix}}/plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
138 { src: "{{resources.reveal.notes_prefix}}/plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }
138 { src: "{{resources.reveal.url_prefix}}/plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }
139 // { src: 'http://s7.addthis.com/js/300/addthis_widget.js', async: true},
139 // { src: 'http://s7.addthis.com/js/300/addthis_widget.js', async: true},
140 ]
140 ]
141 });
141 });
142 </script>
142 </script>
143
143
144 <!-- MathJax configuration -->
144 <!-- MathJax configuration -->
145 <script type="text/x-mathjax-config">
145 <script type="text/x-mathjax-config">
146 MathJax.Hub.Config({
146 MathJax.Hub.Config({
147 tex2jax: {
147 tex2jax: {
148 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
148 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
149 displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
149 displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
150 },
150 },
151 displayAlign: 'left', // Change this to 'center' to center equations.
151 displayAlign: 'left', // Change this to 'center' to center equations.
152 "HTML-CSS": {
152 "HTML-CSS": {
153 styles: {'.MathJax_Display': {"margin": 0}}
153 styles: {'.MathJax_Display': {"margin": 0}}
154 }
154 }
155 });
155 });
156 </script>
156 </script>
157 <!-- End of mathjax configuration -->
157 <!-- End of mathjax configuration -->
158
158
159 <script>
159 <script>
160 // We wait for the onload function to load MathJax after the page is completely loaded.
160 // We wait for the onload function to load MathJax after the page is completely loaded.
161 // MathJax is loaded 1 unit of time after the page is ready.
161 // MathJax is loaded 1 unit of time after the page is ready.
162 // This hack prevent problems when you load multiple js files (i.e. social button from addthis).
162 // This hack prevent problems when you load multiple js files (i.e. social button from addthis).
163 //
163 //
164 window.onload = function () {
164 window.onload = function () {
165 setTimeout(function () {
165 setTimeout(function () {
166 var script = document.createElement("script");
166 var script = document.createElement("script");
167 script.type = "text/javascript";
167 script.type = "text/javascript";
168 script.src = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS_HTML";
168 script.src = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS_HTML";
169 document.getElementsByTagName("head")[0].appendChild(script);
169 document.getElementsByTagName("head")[0].appendChild(script);
170 },1)
170 },1)
171 }
171 }
172 </script>
172 </script>
173
173
174 <script>
174 <script>
175 Reveal.addEventListener( 'slidechanged', function( event ) {
175 Reveal.addEventListener( 'slidechanged', function( event ) {
176 MathJax.Hub.Rerender(event.currentSlide);
176 MathJax.Hub.Rerender(event.currentSlide);
177 });
177 });
178 </script>
178 </script>
179
179
180 </body>
180 </body>
181 {% endblock body %}
181 {% endblock body %}
182
182
183 {% block footer %}
183 {% block footer %}
184 </html>
184 </html>
185 {% endblock footer %} No newline at end of file
185 {% endblock footer %}
General Comments 0
You need to be logged in to leave comments. Login now