-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba20dcb
commit 29f24b1
Showing
99 changed files
with
2,396 additions
and
211 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
cache/posts/using-a-local-revealjs-library-with-your-ipython-slides.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
<div class="text_cell_render border-box-sizing rendered_html"> | ||
<p>IPython slides are powered by <a href="https://github.com/hakimel/reveal.js/">Reveal.js</a> library, you probably already know that.</p> | ||
<p>But... you probably don't know that we use <a href="http://www.jsdelivr.com/">jsdelivr</a> CDN to load all the necessary js and css files. As a consequence, you don't need to download Reveal.js, but also, the speaker notes are not working by default.</p> | ||
<p>But... what happens, if you have low connectivity in the place where you will be presenting your talk (or if you want to use the speaker notes feature)? <!-- TEASER_END --></p> | ||
<p>In this case, it would be better to use a local copy of the Reveal.js library. And you can easily configure this behavior using a config object from the IPython machinery.</p> | ||
<p>Below, you have one way to do it:</p> | ||
</div> | ||
<div class="cell border-box-sizing code_cell vbox"> | ||
<div class="input hbox"> | ||
<div class="prompt input_prompt"> | ||
In [1]: | ||
</div> | ||
<div class="input_area box-flex1"> | ||
<div class="highlight"><pre><span class="kn">from</span> <span class="nn">IPython.nbconvert.exporters</span> <span class="kn">import</span> <span class="n">SlidesExporter</span> | ||
<span class="kn">from</span> <span class="nn">IPython.config</span> <span class="kn">import</span> <span class="n">Config</span> | ||
|
||
<span class="kn">from</span> <span class="nn">IPython.nbformat</span> <span class="kn">import</span> <span class="n">current</span> <span class="k">as</span> <span class="n">nbformat</span> | ||
|
||
<span class="n">infile</span> <span class="o">=</span> <span class="s">"talk.ipynb"</span> <span class="c"># load the name of your slideshow</span> | ||
<span class="n">outfile</span> <span class="o">=</span> <span class="s">"talk.slides.html"</span> | ||
|
||
<span class="n">notebook</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">infile</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> | ||
<span class="n">notebook_json</span> <span class="o">=</span> <span class="n">nbformat</span><span class="o">.</span><span class="n">reads_json</span><span class="p">(</span><span class="n">notebook</span><span class="p">)</span> | ||
|
||
<span class="c"># This is the config object I talked before: </span> | ||
<span class="c"># After the 'url_prefix', you can set the location of your </span> | ||
<span class="c"># local reveal.js library, i.e. if the reveal.js is located </span> | ||
<span class="c"># in the same directory as your talk.slides.html, then </span> | ||
<span class="c"># set 'url_prefix':'reveal.js'.</span> | ||
|
||
<span class="n">c</span> <span class="o">=</span> <span class="n">Config</span><span class="p">({</span> | ||
<span class="s">'RevealHelpTransformer'</span><span class="p">:{</span> | ||
<span class="s">'enabled'</span><span class="p">:</span><span class="bp">True</span><span class="p">,</span> | ||
<span class="s">'url_prefix'</span><span class="p">:</span><span class="s">'reveal.js'</span><span class="p">,</span> | ||
<span class="p">},</span> | ||
<span class="p">})</span> | ||
|
||
<span class="n">exportHtml</span> <span class="o">=</span> <span class="n">SlidesExporter</span><span class="p">(</span><span class="n">config</span><span class="o">=</span><span class="n">c</span><span class="p">)</span> | ||
<span class="p">(</span><span class="n">body</span><span class="p">,</span><span class="n">resources</span><span class="p">)</span> <span class="o">=</span> <span class="n">exportHtml</span><span class="o">.</span><span class="n">from_notebook_node</span><span class="p">(</span><span class="n">notebook_json</span><span class="p">)</span> | ||
|
||
<span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s">'w'</span><span class="p">)</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">body</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s">'utf-8'</span><span class="p">))</span> | ||
</pre></div> | ||
|
||
</div> | ||
</div> | ||
|
||
</div> | ||
<div class="text_cell_render border-box-sizing rendered_html"> | ||
<p>Then, just serve the directory:</p> | ||
<p><code>python -m SimpleHTTPServer 8000</code></p> | ||
<p>open the browser and point it to <code>http://localhost:port</code>, ie:</p> | ||
<p><code>xdg-open http://127.0.0.1:8000</code></p> | ||
<p>OK, that's all... you don't need connectivity anymore ;-) OK, just kidding... he he!</p> | ||
<p><strong>NOTE</strong>: If you are using master, it is even simpler... because now <code>--post serve</code> post-processor uses tornado to forward requests to the CDN if and only if local Reveal.js is unavailable (PR merged <a href="https://github.com/ipython/ipython/pull/4048">here</a>, thanks <strong>MinRK</strong>). So, just locate the <code>reveal.js</code> in the same directory as your talk.slides.html lives and run (as usually):</p> | ||
<p><code>ipython nbconvert talk.ipynb --to slides --post serve</code></p> | ||
<p>You can also point to another directory using the <code>--reveal-prefix</code> alias, ie:</p> | ||
<p><code>ipython nbconvert talk.ipynb --to slides --post serve --reveal-prefix foo/reveal.js</code></p> | ||
<p>Hope it helps.</p> | ||
<p>Damián.</p> | ||
</div> |
61 changes: 61 additions & 0 deletions
61
cache/posts/using-a-local-revealjs-library-with-your-ipython-slides.html.es
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
<div class="text_cell_render border-box-sizing rendered_html"> | ||
<p>IPython slides are powered by <a href="https://github.com/hakimel/reveal.js/">Reveal.js</a> library, you probably already know that.</p> | ||
<p>But... you probably don't know that we use <a href="http://www.jsdelivr.com/">jsdelivr</a> CDN to load all the necessary js and css files. As a consequence, you don't need to download Reveal.js, but also, the speaker notes are not working by default.</p> | ||
<p>But... what happens, if you have low connectivity in the place where you will be presenting your talk (or if you want to use the speaker notes feature)? <!-- TEASER_END --></p> | ||
<p>In this case, it would be better to use a local copy of the Reveal.js library. And you can easily configure this behavior using a config object from the IPython machinery.</p> | ||
<p>Below, you have one way to do it:</p> | ||
</div> | ||
<div class="cell border-box-sizing code_cell vbox"> | ||
<div class="input hbox"> | ||
<div class="prompt input_prompt"> | ||
In [1]: | ||
</div> | ||
<div class="input_area box-flex1"> | ||
<div class="highlight"><pre><span class="kn">from</span> <span class="nn">IPython.nbconvert.exporters</span> <span class="kn">import</span> <span class="n">SlidesExporter</span> | ||
<span class="kn">from</span> <span class="nn">IPython.config</span> <span class="kn">import</span> <span class="n">Config</span> | ||
|
||
<span class="kn">from</span> <span class="nn">IPython.nbformat</span> <span class="kn">import</span> <span class="n">current</span> <span class="k">as</span> <span class="n">nbformat</span> | ||
|
||
<span class="n">infile</span> <span class="o">=</span> <span class="s">"talk.ipynb"</span> <span class="c"># load the name of your slideshow</span> | ||
<span class="n">outfile</span> <span class="o">=</span> <span class="s">"talk.slides.html"</span> | ||
|
||
<span class="n">notebook</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">infile</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> | ||
<span class="n">notebook_json</span> <span class="o">=</span> <span class="n">nbformat</span><span class="o">.</span><span class="n">reads_json</span><span class="p">(</span><span class="n">notebook</span><span class="p">)</span> | ||
|
||
<span class="c"># This is the config object I talked before: </span> | ||
<span class="c"># After the 'url_prefix', you can set the location of your </span> | ||
<span class="c"># local reveal.js library, i.e. if the reveal.js is located </span> | ||
<span class="c"># in the same directory as your talk.slides.html, then </span> | ||
<span class="c"># set 'url_prefix':'reveal.js'.</span> | ||
|
||
<span class="n">c</span> <span class="o">=</span> <span class="n">Config</span><span class="p">({</span> | ||
<span class="s">'RevealHelpTransformer'</span><span class="p">:{</span> | ||
<span class="s">'enabled'</span><span class="p">:</span><span class="bp">True</span><span class="p">,</span> | ||
<span class="s">'url_prefix'</span><span class="p">:</span><span class="s">'reveal.js'</span><span class="p">,</span> | ||
<span class="p">},</span> | ||
<span class="p">})</span> | ||
|
||
<span class="n">exportHtml</span> <span class="o">=</span> <span class="n">SlidesExporter</span><span class="p">(</span><span class="n">config</span><span class="o">=</span><span class="n">c</span><span class="p">)</span> | ||
<span class="p">(</span><span class="n">body</span><span class="p">,</span><span class="n">resources</span><span class="p">)</span> <span class="o">=</span> <span class="n">exportHtml</span><span class="o">.</span><span class="n">from_notebook_node</span><span class="p">(</span><span class="n">notebook_json</span><span class="p">)</span> | ||
|
||
<span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s">'w'</span><span class="p">)</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">body</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s">'utf-8'</span><span class="p">))</span> | ||
</pre></div> | ||
|
||
</div> | ||
</div> | ||
|
||
</div> | ||
<div class="text_cell_render border-box-sizing rendered_html"> | ||
<p>Then, just serve the directory:</p> | ||
<p><code>python -m SimpleHTTPServer 8000</code></p> | ||
<p>open the browser and point it to <code>http://localhost:port</code>, ie:</p> | ||
<p><code>xdg-open http://127.0.0.1:8000</code></p> | ||
<p>OK, that's all... you don't need connectivity anymore ;-) OK, just kidding... he he!</p> | ||
<p><strong>NOTE</strong>: If you are using master, it is even simpler... because now <code>--post serve</code> post-processor uses tornado to forward requests to the CDN if and only if local Reveal.js is unavailable (PR merged <a href="https://github.com/ipython/ipython/pull/4048">here</a>, thanks <strong>MinRK</strong>). So, just locate the <code>reveal.js</code> in the same directory as your talk.slides.html lives and run (as usually):</p> | ||
<p><code>ipython nbconvert talk.ipynb --to slides --post serve</code></p> | ||
<p>You can also point to another directory using the <code>--reveal-prefix</code> alias, ie:</p> | ||
<p><code>ipython nbconvert talk.ipynb --to slides --post serve --reveal-prefix foo/reveal.js</code></p> | ||
<p>Hope it helps.</p> | ||
<p>Damián.</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"family": [2, "/categories/family.html"], "less": [1, "/categories/less.html"], "zen": [1, "/categories/zen.html"], "gh-pages": [1, "/categories/gh-pages.html"], "IPython": [16, "/categories/ipython.html"], "zenmode": [1, "/categories/zenmode.html"], "talks": [1, "/categories/talks.html"], "politics": [1, "/categories/politics.html"], "nikola": [10, "/categories/nikola.html"], "git": [1, "/categories/git.html"], "blog": [6, "/categories/blog.html"], "flood": [1, "/categories/flood.html"], "theme": [1, "/categories/theme.html"], "nbconvert": [7, "/categories/nbconvert.html"], "vIPer": [3, "/categories/viper.html"], "tutorials": [1, "/categories/tutorials.html"], "css": [1, "/categories/css.html"], "opensource": [1, "/categories/opensource.html"], "life": [2, "/categories/life.html"], "python": [18, "/categories/python.html"], "javascript": [1, "/categories/javascript.html"], "SciPyCon": [1, "/categories/scipycon.html"], "slideshow": [3, "/categories/slideshow.html"], "first_post": [1, "/categories/first_post.html"], "reveal": [4, "/categories/reveal.html"], "Facundo": [2, "/categories/facundo.html"], "extension": [1, "/categories/extension.html"], "pdf": [1, "/categories/pdf.html"]} | ||
{"family": [2, "/categories/family.html"], "less": [1, "/categories/less.html"], "zen": [1, "/categories/zen.html"], "gh-pages": [1, "/categories/gh-pages.html"], "IPython": [17, "/categories/ipython.html"], "zenmode": [1, "/categories/zenmode.html"], "talks": [1, "/categories/talks.html"], "politics": [1, "/categories/politics.html"], "nikola": [10, "/categories/nikola.html"], "git": [1, "/categories/git.html"], "blog": [6, "/categories/blog.html"], "flood": [1, "/categories/flood.html"], "theme": [1, "/categories/theme.html"], "nbconvert": [8, "/categories/nbconvert.html"], "vIPer": [3, "/categories/viper.html"], "tutorials": [1, "/categories/tutorials.html"], "local": [1, "/categories/local.html"], "css": [1, "/categories/css.html"], "opensource": [1, "/categories/opensource.html"], "life": [2, "/categories/life.html"], "python": [19, "/categories/python.html"], "javascript": [1, "/categories/javascript.html"], "SciPyCon": [1, "/categories/scipycon.html"], "slideshow": [4, "/categories/slideshow.html"], "connectivity": [1, "/categories/connectivity.html"], "first_post": [1, "/categories/first_post.html"], "reveal": [5, "/categories/reveal.html"], "Facundo": [2, "/categories/facundo.html"], "extension": [1, "/categories/extension.html"], "pdf": [1, "/categories/pdf.html"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.