##// END OF EJS Templates
Getting linearity to reveal fragments. This avoid rendering of - (none) cells before fragments.
damianavila -
Show More
@@ -1,63 +1,70 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 from .base import Preprocessor
15 from .base import Preprocessor
16 from IPython.utils.traitlets import Unicode
16 from IPython.utils.traitlets import Unicode
17
17
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19 # Classes and functions
19 # Classes and functions
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21
21
22 class RevealHelpPreprocessor(Preprocessor):
22 class RevealHelpPreprocessor(Preprocessor):
23
23
24 url_prefix = Unicode('reveal.js', config=True,
24 url_prefix = Unicode('reveal.js', config=True,
25 help="""The URL prefix for reveal.js.
25 help="""The URL prefix for reveal.js.
26 This can be a a relative URL for a local copy of reveal.js,
26 This can be a a relative URL for a local copy of reveal.js,
27 or point to a CDN.
27 or point to a CDN.
28
28
29 For speaker notes to work, a local reveal.js prefix must be used.
29 For speaker notes to work, a local reveal.js prefix must be used.
30 """
30 """
31 )
31 )
32
32
33 def preprocess(self, nb, resources):
33 def preprocess(self, nb, resources):
34 """
34 """
35 Called once to 'preprocess' contents of the notebook.
35 Called once to 'preprocess' contents of the notebook.
36
36
37 Parameters
37 Parameters
38 ----------
38 ----------
39 nb : NotebookNode
39 nb : NotebookNode
40 Notebook being converted
40 Notebook being converted
41 resources : dictionary
41 resources : dictionary
42 Additional resources used in the conversion process. Allows
42 Additional resources used in the conversion process. Allows
43 preprocessors to pass variables into the Jinja engine.
43 preprocessors to pass variables into the Jinja engine.
44 """
44 """
45
45
46 for worksheet in nb.worksheets:
46 for worksheet in nb.worksheets:
47 for index, cell in enumerate(worksheet.cells):
47 for index, cell in enumerate(worksheet.cells):
48
48
49 #Make sure the cell has slideshow metadata.
49 #Make sure the cell has slideshow metadata.
50 cell.metadata.slide_type = cell.get('metadata', {}).get('slideshow', {}).get('slide_type', '-')
50 cell.metadata.slide_type = cell.get('metadata', {}).get('slideshow', {}).get('slide_type', '-')
51
51
52 #Get the slide type. If type is start of subslide or slide,
52 #Get the slide type. If type is start of subslide or slide,
53 #end the last subslide/slide.
53 #end the last subslide/slide.
54 if cell.metadata.slide_type in ['slide']:
54 if cell.metadata.slide_type in ['slide']:
55 worksheet.cells[index - 1].metadata.slide_helper = 'slide_end'
55 worksheet.cells[index - 1].metadata.slide_helper = 'slide_end'
56 if cell.metadata.slide_type in ['subslide']:
56 if cell.metadata.slide_type in ['subslide']:
57 worksheet.cells[index - 1].metadata.slide_helper = 'subslide_end'
57 worksheet.cells[index - 1].metadata.slide_helper = 'subslide_end'
58
58 if cell.metadata.slide_type in ['fragment']:
59 try:
60 i = 1
61 while 1:
62 worksheet.cells[index + i].metadata.frag_helper = 'fragment_end'
63 i += 1
64 except IndexError as e:
65 pass #Last cell doesn't have a next one
59
66
60 if not isinstance(resources['reveal'], dict):
67 if not isinstance(resources['reveal'], dict):
61 resources['reveal'] = {}
68 resources['reveal'] = {}
62 resources['reveal']['url_prefix'] = self.url_prefix
69 resources['reveal']['url_prefix'] = self.url_prefix
63 return nb, resources
70 return nb, resources
@@ -1,197 +1,203 b''
1 {%- extends 'basic.tpl' -%}
1 {%- extends 'basic.tpl' -%}
2 {% from 'mathjax.tpl' import mathjax %}
2 {% from 'mathjax.tpl' import mathjax %}
3
3
4 {%- block any_cell scoped -%}
4 {%- block any_cell scoped -%}
5 {%- if cell.metadata.slide_type in ['slide'] -%}
5 {%- if cell.metadata.slide_type in ['slide'] -%}
6 <section>
6 <section>
7 <section>
7 <section>
8 {{ super() }}
8 {{ super() }}
9 {%- elif cell.metadata.slide_type in ['subslide'] -%}
9 {%- elif cell.metadata.slide_type in ['subslide'] -%}
10 <section>
10 <section>
11 {{ super() }}
11 {{ super() }}
12 {%- elif cell.metadata.slide_type in ['-'] -%}
12 {%- elif cell.metadata.slide_type in ['-'] -%}
13 {%- if cell.metadata.frag_helper in ['fragment_end'] -%}
14 <div class="fragment">
15 {{ super() }}
16 </div>
17 {%- else -%}
13 {{ super() }}
18 {{ super() }}
19 {%- endif -%}
14 {%- elif cell.metadata.slide_type in ['skip'] -%}
20 {%- elif cell.metadata.slide_type in ['skip'] -%}
15 <div style=display:none>
21 <div style=display:none>
16 {{ super() }}
22 {{ super() }}
17 </div>
23 </div>
18 {%- elif cell.metadata.slide_type in ['notes'] -%}
24 {%- elif cell.metadata.slide_type in ['notes'] -%}
19 <aside class="notes">
25 <aside class="notes">
20 {{ super() }}
26 {{ super() }}
21 </aside>
27 </aside>
22 {%- elif cell.metadata.slide_type in ['fragment'] -%}
28 {%- elif cell.metadata.slide_type in ['fragment'] -%}
23 <div class="fragment">
29 <div class="fragment">
24 {{ super() }}
30 {{ super() }}
25 </div>
31 </div>
26 {%- endif -%}
32 {%- endif -%}
27 {%- if cell.metadata.slide_helper in ['subslide_end'] -%}
33 {%- if cell.metadata.slide_helper in ['subslide_end'] -%}
28 </section>
34 </section>
29 {%- elif cell.metadata.slide_helper in ['slide_end'] -%}
35 {%- elif cell.metadata.slide_helper in ['slide_end'] -%}
30 </section>
36 </section>
31 </section>
37 </section>
32 {%- endif -%}
38 {%- endif -%}
33 {%- endblock any_cell -%}
39 {%- endblock any_cell -%}
34
40
35 {% block header %}
41 {% block header %}
36 <!DOCTYPE html>
42 <!DOCTYPE html>
37 <html>
43 <html>
38 <head>
44 <head>
39
45
40 <meta charset="utf-8" />
46 <meta charset="utf-8" />
41 <meta http-equiv="X-UA-Compatible" content="chrome=1" />
47 <meta http-equiv="X-UA-Compatible" content="chrome=1" />
42
48
43 <meta name="apple-mobile-web-app-capable" content="yes" />
49 <meta name="apple-mobile-web-app-capable" content="yes" />
44 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
50 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
45
51
46 <title>{{resources['metadata']['name']}} slides</title>
52 <title>{{resources['metadata']['name']}} slides</title>
47
53
48 <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
54 <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
49 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
55 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
50
56
51 <!-- General and theme style sheets -->
57 <!-- General and theme style sheets -->
52 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/reveal.css">
58 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/reveal.css">
53 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/theme/simple.css" id="theme">
59 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/css/theme/simple.css" id="theme">
54
60
55 <!-- For syntax highlighting -->
61 <!-- For syntax highlighting -->
56 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/lib/css/zenburn.css">
62 <link rel="stylesheet" href="{{resources.reveal.url_prefix}}/lib/css/zenburn.css">
57
63
58 <!-- If the query includes 'print-pdf', include the PDF print sheet -->
64 <!-- If the query includes 'print-pdf', include the PDF print sheet -->
59 <script>
65 <script>
60 if( window.location.search.match( /print-pdf/gi ) ) {
66 if( window.location.search.match( /print-pdf/gi ) ) {
61 var link = document.createElement( 'link' );
67 var link = document.createElement( 'link' );
62 link.rel = 'stylesheet';
68 link.rel = 'stylesheet';
63 link.type = 'text/css';
69 link.type = 'text/css';
64 link.href = '{{resources.reveal.url_prefix}}/css/print/pdf.css';
70 link.href = '{{resources.reveal.url_prefix}}/css/print/pdf.css';
65 document.getElementsByTagName( 'head' )[0].appendChild( link );
71 document.getElementsByTagName( 'head' )[0].appendChild( link );
66 }
72 }
67
73
68 </script>
74 </script>
69
75
70 <!--[if lt IE 9]>
76 <!--[if lt IE 9]>
71 <script src="{{resources.reveal.url_prefix}}/lib/js/html5shiv.js"></script>
77 <script src="{{resources.reveal.url_prefix}}/lib/js/html5shiv.js"></script>
72 <![endif]-->
78 <![endif]-->
73
79
74 <!-- Get Font-awesome from cdn -->
80 <!-- Get Font-awesome from cdn -->
75 <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css">
81 <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css">
76
82
77 {% for css in resources.inlining.css -%}
83 {% for css in resources.inlining.css -%}
78 <style type="text/css">
84 <style type="text/css">
79 {{ css }}
85 {{ css }}
80 </style>
86 </style>
81 {% endfor %}
87 {% endfor %}
82
88
83 <style type="text/css">
89 <style type="text/css">
84 /* Overrides of notebook CSS for static HTML export */
90 /* Overrides of notebook CSS for static HTML export */
85 html {
91 html {
86 overflow-y: auto;
92 overflow-y: auto;
87 }
93 }
88 .reveal {
94 .reveal {
89 font-size: 160%;
95 font-size: 160%;
90 }
96 }
91 .reveal pre {
97 .reveal pre {
92 width: inherit;
98 width: inherit;
93 padding: 0.4em;
99 padding: 0.4em;
94 margin: 0px;
100 margin: 0px;
95 font-family: monospace, sans-serif;
101 font-family: monospace, sans-serif;
96 font-size: 80%;
102 font-size: 80%;
97 box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
103 box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
98 }
104 }
99 .reveal section img {
105 .reveal section img {
100 border: 0px solid black;
106 border: 0px solid black;
101 box-shadow: 0 0 10px rgba(0, 0, 0, 0);
107 box-shadow: 0 0 10px rgba(0, 0, 0, 0);
102 }
108 }
103 .reveal i {
109 .reveal i {
104 font-style: normal;
110 font-style: normal;
105 font-family: FontAwesome;
111 font-family: FontAwesome;
106 font-size: 2em;
112 font-size: 2em;
107 }
113 }
108 .reveal .slides {
114 .reveal .slides {
109 text-align: left;
115 text-align: left;
110 }
116 }
111 .reveal.fade {
117 .reveal.fade {
112 opacity: 1;
118 opacity: 1;
113 }
119 }
114 .reveal .progress {
120 .reveal .progress {
115 position: static;
121 position: static;
116 }
122 }
117 div.input_area {
123 div.input_area {
118 padding: 0.06em;
124 padding: 0.06em;
119 }
125 }
120 div.code_cell {
126 div.code_cell {
121 background-color: transparent;
127 background-color: transparent;
122 }
128 }
123 div.prompt {
129 div.prompt {
124 width: 11ex;
130 width: 11ex;
125 padding: 0.4em;
131 padding: 0.4em;
126 margin: 0px;
132 margin: 0px;
127 font-family: monospace, sans-serif;
133 font-family: monospace, sans-serif;
128 font-size: 80%;
134 font-size: 80%;
129 text-align: right;
135 text-align: right;
130 }
136 }
131 div.output_area pre {
137 div.output_area pre {
132 font-family: monospace, sans-serif;
138 font-family: monospace, sans-serif;
133 font-size: 80%;
139 font-size: 80%;
134 }
140 }
135 div.output_prompt {
141 div.output_prompt {
136 /* 5px right shift to account for margin in parent container */
142 /* 5px right shift to account for margin in parent container */
137 margin: 5px 5px 0 0;
143 margin: 5px 5px 0 0;
138 }
144 }
139 .rendered_html p {
145 .rendered_html p {
140 text-align: inherit;
146 text-align: inherit;
141 }
147 }
142 </style>
148 </style>
143
149
144 <!-- Custom stylesheet, it must be in the same directory as the html file -->
150 <!-- Custom stylesheet, it must be in the same directory as the html file -->
145 <link rel="stylesheet" href="custom.css">
151 <link rel="stylesheet" href="custom.css">
146
152
147 </head>
153 </head>
148 {% endblock header%}
154 {% endblock header%}
149
155
150
156
151 {% block body %}
157 {% block body %}
152 <body>
158 <body>
153 <div class="reveal">
159 <div class="reveal">
154 <div class="slides">
160 <div class="slides">
155 {{ super() }}
161 {{ super() }}
156 </div>
162 </div>
157 </div>
163 </div>
158
164
159 <script src="{{resources.reveal.url_prefix}}/lib/js/head.min.js"></script>
165 <script src="{{resources.reveal.url_prefix}}/lib/js/head.min.js"></script>
160
166
161 <script src="{{resources.reveal.url_prefix}}/js/reveal.js"></script>
167 <script src="{{resources.reveal.url_prefix}}/js/reveal.js"></script>
162
168
163 <script>
169 <script>
164
170
165 // Full list of configuration options available here: https://github.com/hakimel/reveal.js#configuration
171 // Full list of configuration options available here: https://github.com/hakimel/reveal.js#configuration
166 Reveal.initialize({
172 Reveal.initialize({
167 controls: true,
173 controls: true,
168 progress: true,
174 progress: true,
169 history: true,
175 history: true,
170
176
171 theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
177 theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
172 transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/none
178 transition: Reveal.getQueryHash().transition || 'linear', // default/cube/page/concave/zoom/linear/none
173
179
174 // Optional libraries used to extend on reveal.js
180 // Optional libraries used to extend on reveal.js
175 dependencies: [
181 dependencies: [
176 { src: "{{resources.reveal.url_prefix}}/lib/js/classList.js", condition: function() { return !document.body.classList; } },
182 { src: "{{resources.reveal.url_prefix}}/lib/js/classList.js", condition: function() { return !document.body.classList; } },
177 { src: "{{resources.reveal.url_prefix}}/plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }
183 { src: "{{resources.reveal.url_prefix}}/plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }
178 ]
184 ]
179 });
185 });
180 </script>
186 </script>
181
187
182 <!-- Loading mathjax macro -->
188 <!-- Loading mathjax macro -->
183 {{ mathjax() }}
189 {{ mathjax() }}
184
190
185 <script>
191 <script>
186 Reveal.addEventListener( 'slidechanged', function( event ) {
192 Reveal.addEventListener( 'slidechanged', function( event ) {
187 window.scrollTo(0,0);
193 window.scrollTo(0,0);
188 MathJax.Hub.Rerender(event.currentSlide);
194 MathJax.Hub.Rerender(event.currentSlide);
189 });
195 });
190 </script>
196 </script>
191
197
192 </body>
198 </body>
193 {% endblock body %}
199 {% endblock body %}
194
200
195 {% block footer %}
201 {% block footer %}
196 </html>
202 </html>
197 {% endblock footer %} No newline at end of file
203 {% endblock footer %}
General Comments 0
You need to be logged in to leave comments. Login now