diff --git a/converters/reveal.py b/converters/reveal.py index 7c7d822..5d6a1e8 100644 --- a/converters/reveal.py +++ b/converters/reveal.py @@ -180,6 +180,16 @@ class ConverterReveal(ConverterHTML): slide[i] = right + left return list(itertools.chain(*slides)) + def render(self): + "read, convert, and save self.infile" + self.notes = self.template_notes() + self.notesjs = self.template_notesjs() + if not hasattr(self, 'nb'): + self.read() + self.output = self.convert() + assert(type(self.output) == unicode) + return self.save() + def save(self, outfile=None, encoding=None): "read and parse notebook into self.nb" if outfile is None: @@ -218,11 +228,11 @@ class ConverterReveal(ConverterHTML): dict(type='"text/css"'))) return header - def template_read(self): + def template_read(self, templ): "read the reveal_template.html" here = os.path.split(os.path.realpath(__file__))[0] reveal_template = os.path.join(here, '..', 'templates', - 'reveal_base.html') + templ) with io.open(reveal_template, 'r', encoding='utf-8') as f: template = f.readlines() template = [s.strip() for s in template] @@ -230,11 +240,35 @@ class ConverterReveal(ConverterHTML): def template_split(self): "split the reveal_template.html in header and footer lists" - temp = self.template_read() + temp = self.template_read('reveal_base.html') splitted_temp = [list(x[1]) for x in itertools.groupby(temp, lambda x: x == u'%slides%') if not x[0]] return splitted_temp + def template_notesjs(self): + #"split the reveal_template.html in header and footer lists" + temp = self.template_read('notes_base.js') + for i, j in enumerate(temp): + if j == u'%source%': + temp[i] = '\'' + self.outbase + '_notes.html\'' + here = os.path.split(os.path.realpath(__file__))[0] + path_js = os.path.join(here, '..', 'js', self.outbase + '_notes.js') + with io.open(path_js, 'w', + encoding=self.default_encoding) as f: + f.write('\n'.join(temp)) + return [] + + def template_notes(self): + #"split the reveal_template.html in header and footer lists" + temp = self.template_read('notes_base.html') + for i, j in enumerate(temp): + if j == u'%source%': + temp[i] = 'src=\"' + self.outbase + '_slides.html\"' + with io.open(self.outbase + '_notes.html', 'w', + encoding=self.default_encoding) as f: + f.write('\n'.join(temp)) + return [] + def optional_header(self): optional_header_body = self.template_split() return ['', '', ''] + \ @@ -243,4 +277,8 @@ class ConverterReveal(ConverterHTML): def optional_footer(self): optional_footer_body = self.template_split() + for i, j in enumerate(optional_footer_body[1]): + if j == u'%source%': + optional_footer_body[1][i] = \ + 'src: \'js/' + self.outbase + '_notes.js\'' return optional_footer_body[1] + ['', ''] \ No newline at end of file diff --git a/templates/notes.html b/templates/notes_base.html similarity index 95% rename from templates/notes.html rename to templates/notes_base.html index d418bc8..222901b 100644 --- a/templates/notes.html +++ b/templates/notes_base.html @@ -89,11 +89,17 @@
- +
- + UPCOMING:
diff --git a/js/notes.js b/templates/notes_base.js similarity index 97% rename from js/notes.js rename to templates/notes_base.js index b982505..57405ff 100644 --- a/js/notes.js +++ b/templates/notes_base.js @@ -5,7 +5,9 @@ var RevealNotes = (function() { function openNotes() { - var notesPopup = window.open( 'templates/notes.html', 'reveal.js - Notes', 'width=1120,height=850' ); + var notesPopup = window.open( + %source% + , 'reveal.js - Notes', 'width=1120,height=850' ); // Fires when slide is changed Reveal.addEventListener( 'slidechanged', function( event ) { diff --git a/templates/reveal_base.html b/templates/reveal_base.html index e8bf621..de6172e 100644 --- a/templates/reveal_base.html +++ b/templates/reveal_base.html @@ -42,7 +42,9 @@ { src: 'reveal/lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: 'reveal/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, { src: 'reveal/plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }, - { src: 'js/notes.js', async: true, condition: function() { return !!document.body.classList; } }, + { + %source% + , async: true, condition: function() { return !!document.body.classList; } }, { src: 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS_HTML', async: true }, { src: 'js/revealmathjax.js', async: true} ]