Commit f2b3b545 authored by Ayush Tiwari's avatar Ayush Tiwari

Wendelin: Add custom js to display help test at start of notebook with erp5 kernel

parent 44719ea4
......@@ -25,6 +25,7 @@ parts =
monitor-deploy-set-password-cgi
erp5-kernel
kernel-json
custom-js
extends = {{ parameter_dict['monitor-template'] }}
......@@ -150,3 +151,9 @@ context =
key kernel_dir erp5-kernel:rendered
raw display_name ERP5
raw language_name python
[custom-js]
recipe = slapos.recipe.template:jinja2
template = {{ parameter_dict['custom_js_location'] }}/{{ parameter_dict['custom_js_filename'] }}
rendered = ${directory:ipython_dir}/profile_default/static/custom/custom.js
mode = 0744
\ No newline at end of file
......@@ -21,6 +21,8 @@ erp5_kernel_filename = {{ erp5_kernel_filename }}
kernel_json_location = {{ kernel_json_location }}
kernel_json_filename = {{ kernel_json_filename }}
monitor-template = {{ monitor_template }}
custom_js_location = {{ custom_js_location }}
custom_js_filename = {{ custom_js_filename }}
[dynamic-template-notebook]
< = jinja2-template-base
......
......@@ -39,6 +39,13 @@ parts +=
eggs +=
requests
${manpy:eggs}
${scikit-learn:egg}
${scipy:egg}
${pandas:egg}
${msgpack-python:egg}
${wendelin.core:egg}
${ipython:egg}
${matplotlib:egg}
initialization +=
${manpy:initialization}
......@@ -116,12 +123,21 @@ filename = kernel.json.jinja
mode = 0644
md5sum = ab6e78ea20855e07d388b5b86d1770fe
[custom-js]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/${:filename}
download-only = true
destination = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = custom.js.jinja
mode = 0644
md5sum = 4a3686e221370e5f7fc930409cca49d0
[instance]
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance.cfg.in
rendered = ${buildout:directory}/template.cfg
mode = 0644
md5sum = bad629610dd6e12e87f1a72aa12f968b
md5sum = 01406027e623ce3aafb1febb9fd1dae5
context =
key slapos_core_version versions:slapos.core
key bin_directory buildout:bin-directory
......@@ -141,6 +157,8 @@ context =
key erp5_kernel_filename erp5-kernel:filename
key kernel_json_location kernel-json:location
key kernel_json_filename kernel-json:filename
key custom_js_location custom-js:location
key custom_js_filename custom-js:filename
[template-erp5-cluster]
<= template
......@@ -151,7 +169,7 @@ rendered = ${buildout:directory}/template-erp5-cluster.cfg
[template-notebook]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/instance-notebook.cfg.in
md5sum = b18be2954fd3a7986068a9657398bb9e
md5sum = ecd2a8eb1a0f9d87357f4b7442b3d78a
mode = 644
[template-default]
......
// leave at least 2 line with only a star on it below, or doc generation fails
/**
*
*
* Placeholder for custom user javascript
* mainly to be overridden in profile/static/custom/custom.js
* This will always be an empty file in IPython
*
* User could add any javascript in the `profile/static/custom/custom.js` file.
* It will be executed by the ipython notebook at load time.
*
* Same thing with `profile/static/custom/custom.css` to inject custom css into the notebook.
*
*
* The object available at load time depend on the version of IPython in use.
* there is no guaranties of API stability.
*
* The example below explain the principle, and might not be valid.
*
* Instances are created after the loading of this file and might need to be accessed using events:
* define([
* 'base/js/namespace',
* 'base/js/events'
* ], function(IPython, events) {
* events.on("app_initialized.NotebookApp", function () {
* IPython.keyboard_manager....
* });
* });
*
* __Example 1:__
*
* Create a custom button in toolbar that execute `%qtconsole` in kernel
* and hence open a qtconsole attached to the same kernel as the current notebook
*
* define([
* 'base/js/namespace',
* 'base/js/events'
* ], function(IPython, events) {
* events.on('app_initialized.NotebookApp', function(){
* IPython.toolbar.add_buttons_group([
* {
* 'label' : 'run qtconsole',
* 'icon' : 'icon-terminal', // select your icon from http://fortawesome.github.io/Font-Awesome/icons
* 'callback': function () {
* IPython.notebook.kernel.execute('%qtconsole')
* }
* }
* // add more button here if needed.
* ]);
* });
* });
*
* __Example 2:__
*
* At the completion of the dashboard loading, load an unofficial javascript extension
* that is installed in profile/static/custom/
*
* define([
* 'base/js/events'
* ], function(events) {
* events.on('app_initialized.DashboardApp', function(){
* require(['custom/unofficial_extension.js'])
* });
* });
*
* __Example 3:__
*
* Use `jQuery.getScript(url [, success(script, textStatus, jqXHR)] );`
* to load custom script into the notebook.
*
* // to load the metadata ui extension example.
* $.getScript('/static/notebook/js/celltoolbarpresets/example.js');
* // or
* // to load the metadata ui extension to control slideshow mode / reveal js for nbconvert
* $.getScript('/static/notebook/js/celltoolbarpresets/slideshow.js');
*
*
* @module IPython
* @namespace IPython
* @class customjs
* @static
*/
$([IPython.events]).on('notebook_loaded.Notebook', function(){
var kernelname = IPython.notebook.kernel_selector.current_selection;
var display_text="<div class='output_subarea output_text output_result'>\
<pre>Follow these steps to customize your notebook with ERP5 kernel :-</br>\
1. Add <b>%erp5_url &lt;your_erp5_url&gt;/erp5/Base_executeJupyter</b>.</br>\
Make sure you have 'erp5_data_notebook' business template installed in your erp5</br>\
2. <b>%notebook_set_reference &lt;your_notebook_refernce&gt;</b></br>\
It would be better to set the reference to match with erp5 refernce pattern.</br>\
3. <b>%erp5_user &lt;your_erp5_username&gt;</b></br>\
4. <b>%erp5_password &lt;your_erp5_password&gt;</b></br>\
5. As soon as you see 'Please Proceed' message you can now access your erp5 using notebook.</br>\
<p><u>OTHER USEFUL MAGICS</u> -</br>\
<b>%use_reference &lt;your_notebook_refernce&gt;</b> -This is used next time you open your notebook, though the previous magic %notebook_set_refernce would also work.</br>\
<b>%my_notebooks</b> -This is used to display all the notebooks created by the specific user.</br>\
</pre></div>";
if (kernelname=="erp5"){
$('div#notebook-container').prepend(display_text);
}
});
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment