Blogging with Nikola and IPython
Alert! This post is outdated, please
goto
;-) this link to get updated information.
NOTE: Obviously, this post was written in the IPython notebook and was rendered by Nikola (helped by nbconvert).
INGREDIENTS:
NOTE: The theme was tested with Nikola version 5.1
- IPython
- site-ipython theme for Nikola
- compile_ipynb for Nikola
STEPS:
- Install Nikola and IPython (probably you have IPython installed if you are reading this post).
- Install the site-ipython theme in your Nikola instalation. You can see some the documentation about how to do it here.
NOTE: Another way to do it is copying the site-ipython theme inside the nikola/data/themes folder BEFORE installing Nikola.
NOTE2: The recommended way to do it would be copying the site-ipython theme inside your_site after initialization of your_site. See below.
- Initialize your_site:
nikola init your_site
you can ask for
nikola --help
for other available options.
- Create a plugins folder inside your_site
- Copy the compile_ipynb plugin (compile_ipynb.plugin file and the compile_ipynb folder, which are is located inside the extra-plugins folder in the Nikola master) in your_site/plugins/ folder.
- Then, download the custom nbconvert and nbformat from here and put them inside your_site/plugins/compile_ipynb/ folder.
- Finally, you have to put:
post_pages = (
("posts/*.ipynb", "posts", "post.tmpl", True),
("stories/*.ipynb", "stories", "story.tmpl", False),
)
and
THEME = 'site-ipython'
in your conf.py file of your_site (you can modified the other pieces inside conf.py according to your needs).
NOTE: This setup is done only once time a life... hehe¶
USE:
- First create a new post:
nikola new_post -f ipynb
NOTE: IGNORE the -2 option in nikola new_page (it is no sense with the current implementation).
You will be asked for a title (you can also add the title and tags in the previous call).
Then, two files will be created by Nikola in the /posts folder of your_site: a meta file containing title, slug, time, tags (you can modified them with any text processor) and a naive ipynb file with the corresponding title.
You can init the ipython notebook
inside this folder and modified the "post" notebook as you wish (do not forget to save the changes inside your notebook).
- Finally, just:
nikola build
and deploy the output folder containing your_site... to see it locally:
nikola serve
That's it all, my friend!
PS: And now some cells to show you this is areal notebook...
pwd
%pylab inline
x = linspace(0, 3*pi, 500)
plot(x, sin(x**2))
title('A simple chirp');
x = 1
y = 4
z = y/(1-x)
Courtesy of MathJax, you can include mathematical expressions both inline: $e^{i\pi} + 1 = 0$ and displayed:
$$e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i$$from IPython.display import Image
Image(url='http://python.org/images/python-logo.gif')
from IPython.display import YouTubeVideo
# a talk about IPython at Sage Days at U. Washington, Seattle.
# Video credit: William Stein.
YouTubeVideo('1j_HxD4iLn8')
OK, enough... see you soon!
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