Quantcast

Start notebook with custom markdown code snippets as default?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Start notebook with custom markdown code snippets as default?

Norfeldt
A lot of cool features can be added to the notebook by html and javascript like the quick & dirty autosave function and hide input

But is is possible to modify the default empty (start) notebook to have some code snippets included ___________?

(Imagine something like having it create a notebook with at markdown at the top with some predefined html and javascript)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Brian Granger-3
The best way of doing this right now is to clone an existing notebook.
 We don't have a great way of doing that, but starting in Jan, we will
be working on the dashboard and we will add things like that.

On Tue, Nov 27, 2012 at 11:13 AM, Norfeldt <[hidden email]> wrote:

> A lot of cool features can be added to the notebook by html and javascript
> like the /quick & dirty/ *autosave function* and *hide input*
>
> But is is possible to modify the default empty (start) notebook to have some
> code snippets included ___________?
>
> (Imagine something like having it create a notebook with at markdown at the
> top with some predefined html and javascript)
>
>
>
> --
> View this message in context: http://python.6.n6.nabble.com/Start-notebook-with-custom-markdown-code-snippets-as-default-tp4997506.html
> Sent from the IPython - User mailing list archive at Nabble.com.
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user



--
Brian E. Granger
Cal Poly State University, San Luis Obispo
[hidden email] and [hidden email]
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Matthias Bussonnier
In reply to this post by Norfeldt

Le 27 nov. 2012 à 20:13, Norfeldt a écrit :

> A lot of cool features can be added to the notebook by html and javascript
> like the /quick & dirty/ *autosave function* and *hide input*
>
> But is is possible to modify the default empty (start) notebook to have some
> code snippets included ___________?
>
> (Imagine something like having it create a notebook with at markdown at the
> top with some predefined html and javascript)

The question is what do you want to do with this template ?

Using custom.js you could inject pretty much anything in notebook,
So you could try to detect wether there is only one empty cell and change its content if it is the case.
Which has the same effect that a template.

If your goal is to inject Js in the notebook…. the custom.js is there to do that,
And you could add button to the toolbar or add menu or...
And this without 'polluting' the ipynb file with preferences that might be only yours.

--
Matthias

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Matthew Turk-3
Hi Matthias,

On Tue, Nov 27, 2012 at 2:40 PM, Matthias BUSSONNIER
<[hidden email]> wrote:

>
> Le 27 nov. 2012 à 20:13, Norfeldt a écrit :
>
>> A lot of cool features can be added to the notebook by html and javascript
>> like the /quick & dirty/ *autosave function* and *hide input*
>>
>> But is is possible to modify the default empty (start) notebook to have some
>> code snippets included ___________?
>>
>> (Imagine something like having it create a notebook with at markdown at the
>> top with some predefined html and javascript)
>
> The question is what do you want to do with this template ?
>
> Using custom.js you could inject pretty much anything in notebook,
> So you could try to detect wether there is only one empty cell and change its content if it is the case.
> Which has the same effect that a template.
>
> If your goal is to inject Js in the notebook…. the custom.js is there to do that,
> And you could add button to the toolbar or add menu or...
> And this without 'polluting' the ipynb file with preferences that might be only yours.
>

Is there a way to distribute a custom.js and have it update?  i.e.,
the full path as an argument to something like NotebookApp?

Thanks,

Matt

> --
> Matthias
>
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Matthias Bussonnier

No,

Custom.js is just a placeholder for user defined javascript. There are no update mecamisme planed, and I don't think there will be any dor custom js. Let's see vustom.js like your .bashrc or .gitconfig

Actually any file in .profile_xxx/static/ will overwrite ther counterpart if they exist, this is how custom js works with an empty custom js in iputhon source dir.

We are working on javascript plugin for notebook. Cf brian pull request on github. I also doubt we'll implement update as we are not dooing it for other ipython extensions.
--
Matthias

Le 27 nov. 2012 20:44, "Matthew Turk" <[hidden email]> a écrit :
Hi Matthias,

On Tue, Nov 27, 2012 at 2:40 PM, Matthias BUSSONNIER
<[hidden email]> wrote:
>
> Le 27 nov. 2012 à 20:13, Norfeldt a écrit :
>
>> A lot of cool features can be added to the notebook by html and javascript
>> like the /quick & dirty/ *autosave function* and *hide input*
>>
>> But is is possible to modify the default empty (start) notebook to have some
>> code snippets included ___________?
>>
>> (Imagine something like having it create a notebook with at markdown at the
>> top with some predefined html and javascript)
>
> The question is what do you want to do with this template ?
>
> Using custom.js you could inject pretty much anything in notebook,
> So you could try to detect wether there is only one empty cell and change its content if it is the case.
> Which has the same effect that a template.
>
> If your goal is to inject Js in the notebook…. the custom.js is there to do that,
> And you could add button to the toolbar or add menu or...
> And this without 'polluting' the ipynb file with preferences that might be only yours.
>

Is there a way to distribute a custom.js and have it update?  i.e.,
the full path as an argument to something like NotebookApp?

Thanks,

Matt

> --
> Matthias
>
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Norfeldt
In reply to this post by Matthias Bussonnier
Matthias Bussonnier wrote
If your goal is to inject Js in the notebook…. the custom.js is there to do that,
And you could add button to the toolbar or add menu or...
And this without 'polluting' the ipynb file with preferences that might be only yours.
--
Matthias
This is exactly what I want!
I don't know javaScript but have got a long way with copy pasting codesnippets together

- What would be the easiest way to add a (or multiple) button(s) to the toolbar that calls a js script function ___________ ?

- Can anybody help me get started on a js script that toggles the Header off by default ____________ ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Matthias Bussonnier

Le 27 nov. 2012 à 23:18, Norfeldt a écrit :

Matthias Bussonnier wrote
If your goal is to inject Js in the notebook…. the custom.js is there to
do that,
And you could add button to the toolbar or add menu or...
And this without 'polluting' the ipynb file with preferences that might be
only yours.
--
Matthias

This is exactly what I want!
I don't know javaScript but have got a long way with copy pasting
codesnippets together

- What would be the easiest way to add a (or multiple) button(s) to the
toolbar that calls a js script function ___________ ?

have a look at https://github.com/ipython/ipython/pull/2571  (js documentation)
I'll be happy o have feedback / corrections , more example.

Compiled version and the page you want would be here http://elacave.lmdb.eu/~carreau/yui/classes/IPython.customjs.html 



- Can anybody help me get started on a js script that toggles the Header off
by default ____________ ?

$('div#header').hide()
IPython.layout_manager.do_resize();

Probably bound to 
'notebook_loaded.Notebook' event

so smth like

$([IPython.events]).on('notebook_loaded.Notebook', function(){
$('div#header').hide()
IPython.layout_manager.do_resize();
})

-- 
Matthias





--
View this message in context: http://python.6.n6.nabble.com/Start-notebook-with-custom-markdown-code-snippets-as-default-tp4997506p4997540.html
Sent from the IPython - User mailing list archive at Nabble.com.
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user


_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Norfeldt
Figured out howto hide the header and have the simple autosave function running:

If somebody want to have it in a markup cell then this is the code to paste
<body>autosave is enabled to ½ minutes interval</body>
<script type="text/javascript">
    // Autosave
    setInterval( "IPython.notebook.save_notebook()", 0.5*60*1000 );
    
    // Hide the Header at starup
    $([IPython.events]).on('notebook_loaded.Notebook', function(){
	$('div#header').hide()
	IPython.layout_manager.do_resize();
    })
</script>

I had some difficulty getting the injection up and running.
looking in my custom profile folder I saw no static dir.
So I created the following path
~/.ipython/profile_<profile name>/static/js
and dropped a file custom.js file using nano that contained this only this code:

Do I need to make change in the config the profile_notebook.py _____________?


suppose I want to inject an extra button(s) into the toolbar (like enable/disable, adjust the auto-save function). What would be the easiest way to go _________?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Norfeldt
About the last question of injection extra buttons - wrote that before I had a look at:
http://elacave.lmdb.eu/~carreau/yui/classes/IPython.customjs.html

Then I had the issue with the non-existing js dir and non-injecting custom.js

When I get this up and running then I should be able to just follow that link and inject extra buttons and private functionality.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Matthias Bussonnier

> Then I had the issue with the non-existing js dir and non-injecting
> custom.js
>

Actually, everything you did should be enough. Maybe you need to restart the server and check if it is not a cache issue with your browser.
But it should work.
--
Matthias


> When I get this up and running then I should be able to just follow that
> link and inject extra buttons and private functionality.
>
>
>
> --
> View this message in context: http://python.6.n6.nabble.com/Start-notebook-with-custom-markdown-code-snippets-as-default-tp4997506p4998083.html
> Sent from the IPython - User mailing list archive at Nabble.com.
> _______________________________________________
> IPython-User mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-user

_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Start notebook with custom markdown code snippets as default?

Norfeldt
Matthias Bussonnier wrote
Actually, everything you did should be enough. Maybe you need to restart the server and check if it is not a cache issue with your browser.
But it should work.
Tried to clear the cache and restart the server, but no luck. Kinda weird that the static directory and js wasn't created in the first place.


Do I need to set anything in the startup dir or the config files?
Loading...