Created new print view for notebook printing.

pull/37/head
Brian Granger 14 years ago committed by MinRK
parent 76f500b3c3
commit eef6d192e4

@ -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
#-----------------------------------------------------------------------------

@ -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),

@ -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;

@ -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);
});

@ -79,7 +79,7 @@
</ul>
</li>
<hr/>
<li id="print_notebook"><a href="#">Print</a></li>
<li id="print_notebook"><a href="/{{notebook_id}}/print" target="_blank">Print View</a></li>
</ul>
</li>
<li><a href="#">Edit</a>
@ -174,7 +174,6 @@
<script src="/static/js/quickhelp.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/loginwidget.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/pager.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/printwidget.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/menubar.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/notebook.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/notebookmain.js" type="text/javascript" charset="utf-8"></script>

Loading…
Cancel
Save