Deploy your Nikola-powered blog content from the IPython notebook
Following the idea to release all the extensions I had working on in the last few weeks/months, today I will release an old but very useful IPython notebook extension for people blogging with Nikola: the nikola_deploy extension.
Yes, I am always very original picking the names of the extensions ;-). A pic to illustrate the extension button at the toolbar:
Note: Nikola supports the ipynb file as an input... and using the IPython.nbconvert machinery it is able to render the static HTML representation of your ipynbs inside the complete infrastructure of a powerful static site engine.
First, to know some things about my blogging workflow using IPython, Nikola, git and gh-pages, I suggest you to re-read these previous posts:
- Bidirectional IPython-Nikola workflow to write your blog post
- One line deployment of your site to gh-pages
OK, coming back to the extension, the idea behind this one is very simple: I will call the nikola deploy
command from inside the IPython notebook using our beloved IPython.notebook.kernel.execute
method, and also taking the advantage of passing commands to the underlying system just pre-pending with the !
mark. The relevant lines are below:
36 if (clean=="True") {
37 IPython.notebook.kernel.execute('!nikola clean');
38 }
39 IPython.notebook.kernel.execute('!nikola build');
40 IPython.notebook.kernel.execute('!nikola deploy');
After writing the content of my post following the workflow explained in previous posts, I just click on the nikola_deploy extension button and the site is cleaned (if you choose this option to True in the config file, please set it to False if you want a quick building), built and deployed automagically ;-)
And that's all... the complete code below:
cat -n /media/datos/Desarrollos/mIPyex/custom/nikola_deploy/main.js
Again, the extension lives in this new repo: mIPyex, where I will upload the development versions of my own extensions. When I get them enough stable, I will make a copy of them in the IPython notebook extensions repo where you can get a lot of and useful interesting extensions.
OK, as you can see... it is very simple to blog with IPython and Nikola, so I invite you to try it now and let me know any ideas, comments or critics.
Enjoy!
Damián
Did you like the content? Great!
Or visit my support page for more information.
Btw, don't forget this blog post is an ipynb file itself! So, you can download it from the "Source" link at the top of the post if you want to play with it ;-)
Comments powered by Disqus