From eef6d192e42eefe2c0986342c347c6a462f2c61b Mon Sep 17 00:00:00 2001 From: Brian Granger Date: Wed, 11 Jan 2012 22:35:24 -0800 Subject: [PATCH] Created new print view for notebook printing. --- IPython/frontend/html/notebook/handlers.py | 20 +++++++++++++++++++ IPython/frontend/html/notebook/notebookapp.py | 3 ++- .../html/notebook/static/css/notebook.css | 14 ------------- .../html/notebook/static/js/notebookmain.js | 20 ------------------- .../html/notebook/templates/notebook.html | 3 +-- 5 files changed, 23 insertions(+), 37 deletions(-) diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index 07b58b93c..9a37c4372 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -285,6 +285,26 @@ class NamedNotebookHandler(AuthenticatedHandler): ) +class PrintNotebookHandler(AuthenticatedHandler): + + @authenticate_unless_readonly + def get(self, notebook_id): + nbm = self.application.notebook_manager + project = nbm.notebook_dir + if not nbm.notebook_exists(notebook_id): + raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_id) + + self.render( + 'printnotebook.html', project=project, + notebook_id=notebook_id, + base_project_url=u'/', base_kernel_url=u'/', + kill_kernel=False, + read_only=self.read_only, + logged_in=self.logged_in, + login_available=self.login_available, + mathjax_url=self.application.ipython_app.mathjax_url, + ) + #----------------------------------------------------------------------------- # Kernel handlers #----------------------------------------------------------------------------- diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py index 34e730b53..00ab84aae 100644 --- a/IPython/frontend/html/notebook/notebookapp.py +++ b/IPython/frontend/html/notebook/notebookapp.py @@ -49,7 +49,7 @@ from .handlers import (LoginHandler, LogoutHandler, ProjectDashboardHandler, NewHandler, NamedNotebookHandler, MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler, ShellHandler, NotebookRootHandler, NotebookHandler, NotebookCopyHandler, - RSTHandler, AuthenticatedFileHandler + RSTHandler, AuthenticatedFileHandler, PrintNotebookHandler ) from .notebookmanager import NotebookManager @@ -98,6 +98,7 @@ class NotebookWebApplication(web.Application): (r"/new", NewHandler), (r"/%s" % _notebook_id_regex, NamedNotebookHandler), (r"/%s/copy" % _notebook_id_regex, NotebookCopyHandler), + (r"/%s/print" % _notebook_id_regex, PrintNotebookHandler), (r"/kernels", MainKernelHandler), (r"/kernels/%s" % _kernel_id_regex, KernelHandler), (r"/kernels/%s/%s" % (_kernel_id_regex, _kernel_action_regex), KernelActionHandler), diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend/html/notebook/static/css/notebook.css index b68c54630..a003023d0 100644 --- a/IPython/frontend/html/notebook/static/css/notebook.css +++ b/IPython/frontend/html/notebook/static/css/notebook.css @@ -357,20 +357,6 @@ p.dialog { padding : 0.2em; } -@media print { - body { overflow: visible !important; } - #menubar, #pager_splitter, #pager { display: none;} - #header {display: none !important; } - #main_app { overflow: visible !important; height: !important auto; } - #notebook_panel { overflow: visible !important; height: !important auto; } - #notebook { - height: !important auto; - overflow-y: !important visible; - overflow-x: !important hidden; - } - .ui-widget-content { border: 0px; } -} - .shortcut_key { display: inline-block; width: 15ex; diff --git a/IPython/frontend/html/notebook/static/js/notebookmain.js b/IPython/frontend/html/notebook/static/js/notebookmain.js index e6e7608db..7dd638c02 100644 --- a/IPython/frontend/html/notebook/static/js/notebookmain.js +++ b/IPython/frontend/html/notebook/static/js/notebookmain.js @@ -84,7 +84,6 @@ $(document).ready(function () { IPython.save_widget = new IPython.SaveWidget('span#save_widget'); IPython.quick_help = new IPython.QuickHelp('span#quick_help_area'); IPython.login_widget = new IPython.LoginWidget('span#login_widget'); - IPython.print_widget = new IPython.PrintWidget(); IPython.notebook = new IPython.Notebook('div#notebook'); IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status'); IPython.menubar = new IPython.MenuBar('#menubar') @@ -97,23 +96,12 @@ $(document).ready(function () { if(IPython.read_only){ // hide various elements from read-only view - IPython.save_widget.element.find('button#save_notebook').addClass('hidden'); - IPython.quick_help.element.addClass('hidden'); // shortcuts are disabled in read_only $('div#pager').remove(); $('div#pager_splitter').remove(); - $('button#new_notebook').addClass('hidden'); - $('div#cell_section').addClass('hidden'); - $('div#config_section').addClass('hidden'); - $('div#kernel_section').addClass('hidden'); $('span#login_widget').removeClass('hidden'); // set the notebook name field as not modifiable $('#notebook_name').attr('disabled','disabled') - - // left panel starts collapsed, but the collapse must happen after - // elements start drawing. Don't draw contents of the panel until - // after they are collapsed - IPython.left_panel.left_panel_element.css('visibility', 'hidden'); } $('div#main_app').css('display','block'); @@ -126,14 +114,6 @@ $(document).ready(function () { IPython.save_widget.update_url(); IPython.layout_manager.do_resize(); IPython.pager.collapse(); - if(IPython.read_only){ - // collapse the left panel on read-only - IPython.left_panel.collapse(); - // and finally unhide the panel contents after collapse - setTimeout(function(){ - IPython.left_panel.left_panel_element.css('visibility', 'visible'); - }, 200); - } },100); }); diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html index f51ecece3..740ed2142 100644 --- a/IPython/frontend/html/notebook/templates/notebook.html +++ b/IPython/frontend/html/notebook/templates/notebook.html @@ -79,7 +79,7 @@
- +
  • Edit @@ -174,7 +174,6 @@ -