From 7ea6322d24c310ea18702b54ad0c2fac5bc1809f Mon Sep 17 00:00:00 2001
From: Sebastian Kreisel <sebastian.kreisel@nexedi.com>
Date: Fri, 9 Jun 2017 15:31:02 +0200
Subject: [PATCH] software/ipython_notebook: Add renderjs extension and jupyter
 config dir creating

---
 software/ipython_notebook/instance.cfg.in | 23 +++++++++++++++++++++--
 software/ipython_notebook/software.cfg    | 14 +++++++++++++-
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/software/ipython_notebook/instance.cfg.in b/software/ipython_notebook/instance.cfg.in
index b310b890f..de8e8d737 100644
--- a/software/ipython_notebook/instance.cfg.in
+++ b/software/ipython_notebook/instance.cfg.in
@@ -8,10 +8,11 @@ parts =
   kernel-json
   custom-js
   monitor-base
+  renderjs-symlink-nbextension
+  renderjs-symlink-nbconfig
 extends =
   {{ monitor_template_rendered }}/template-monitor.cfg
 
-
 eggs-directory = {{ eggs_directory }}
 develop-eggs-directory = {{ develop_eggs_directory }}
 offline = true
@@ -74,7 +75,10 @@ command-line =
 wrapper-path = ${directory:service}/ipython_notebook
 parameters-extra = true
 # Explicitly define IPython Directory to be used while starting ipython notebook
-environment = IPYTHONDIR=${directory:ipython_dir}
+environment =
+  IPYTHONDIR=${directory:ipython_dir}
+  JUPYTER_CONFIG_DIR=${directory:jupyter_config_dir}
+  JUPYTER_DATA_DIR=${directory:jupyter_data_dir}
 
 [ipython-notebook-config]
 <= dynamic-jinja2-template-base
@@ -98,6 +102,12 @@ notebook_dir = ${:var}/notebooks
 ipython_dir = ${:home}/ipython
 ipython_kernel_dir = ${:ipython_dir}/kernels
 erp5_kernel_dir = ${:ipython_kernel_dir}/ERP5
+ipython_extension_dir = ${:ipython_dir}/extensions
+# Add folders to explicitly define jupyter [config/data] directories
+jupyter_data_dir = ${:home}/jupyter_data
+jupyter_nbext_dir = ${:home}/jupyter_data/nbextensions
+jupyter_config_dir = ${:home}/jupyter_config
+jupyter_nbconfig_dir = ${:home}/jupyter_config/nbconfig
 
 [ipython_notebook]
 # This part is called like this because knowledge0.write uses the part name for
@@ -150,3 +160,12 @@ template = {{ custom_js_location }}/{{ custom_js_filename }}
 rendered = ${directory:ipython_dir}/profile_default/static/custom/custom.js
 mode = 0744
 
+[renderjs-symlink-nbextension]
+recipe = cns.recipe.symlink
+symlink =  {{ renderjs_extension_location }}/renderjs_nbextension = ${directory:jupyter_nbext_dir}/renderjs_nbextension
+autocreate = true
+
+[renderjs-symlink-nbconfig]
+recipe = cns.recipe.symlink
+symlink =  {{ renderjs_extension_location }}/renderjs_nbextension/notebook.json = ${directory:jupyter_nbconfig_dir}/notebook.json
+autocreate = true
\ No newline at end of file
diff --git a/software/ipython_notebook/software.cfg b/software/ipython_notebook/software.cfg
index 7c6e3b62a..9c966ac35 100644
--- a/software/ipython_notebook/software.cfg
+++ b/software/ipython_notebook/software.cfg
@@ -9,10 +9,12 @@ extends =
   ../../component/openssl/buildout.cfg
   ../../component/seaborn/buildout.cfg
   ../../stack/monitor/buildout.cfg
+
 parts =
   slapos-cookbook
   ipython-notebook
   instance-jupyter
+  renderjs-nbextension
 
 [ipython-notebook]
 ; In the ipython notebook software, we use more eggs than in the minimal
@@ -59,12 +61,20 @@ md5sum = ab6e78ea20855e07d388b5b86d1770fe
 filename = custom.js.jinja
 md5sum = a851a68667a4e676cfa86b34a86b4239
 
+[renderjs-nbextension]
+recipe = zc.recipe.egg
+eggs = renderjs_nbextension
+
+# XXX uses ad-hock knowedge where zc.recipe.egg installs pure-python eggs
+pyversion = py2.7
+location = ${buildout:eggs-directory}/${:eggs}-${versions:renderjs-nbextension}-${:pyversion}.egg
+
 [instance-jupyter]
 recipe = slapos.recipe.template:jinja2
 template = ${:_profile_base_location_}/instance.cfg.in
 rendered = ${buildout:directory}/template.cfg
 mode = 0644
-md5sum = b564e553811db272be681c331b270bbe
+md5sum = c5f3beac134569a139b960b2936a47fe
 context =
   key bin_directory buildout:bin-directory
   key develop_eggs_directory buildout:develop-eggs-directory
@@ -82,6 +92,7 @@ context =
   key custom_js_location custom-js:location
   key custom_js_filename custom-js:filename
   key monitor_template_rendered buildout:directory
+  key renderjs_extension_location renderjs-nbextension:location
 
 [versions]
 Pygments = 2.2.0
@@ -113,6 +124,7 @@ terminado = 0.6
 tornado = 4.4.2
 traitlets = 4.3.2
 widgetsnbextension = 2.0.0
+renderjs-nbextension = 0.0.4
 
 # Required by:
 # tornado==4.4.2
-- 
2.30.9