Implement static publishing of HTML notebook #706

Merged
merged 3 commits into from Aug 19, 2011

Projects

None yet

4 participants

@stefanv
stefanv commented Aug 17, 2011

Add a publish button that takes the current "notebook" div and embeds it inside a clean page, ready for printing or saving.

@fperez
Member
fperez commented Aug 17, 2011

I won't do the merge because I think @ellisonbg should have a look at it (as well as @minrk) in case you disagree with any of the JS decisions. But I think the functionality is perfect and we should merge this in now before we merge the whole #705, so that when the NB lands it's pretty much fully operational.

@stefanv
stefanv commented Aug 17, 2011

One slight tweak I'll make later this evening: not to display the current cell highlight.

@ellisonbg
Member

The save widget should only contain logic and HTML tags related to saving the notebook. There are two options:

  1. We put the button in the "Notebook" section of the left panel (see panelsection for that code).
  2. We put the button in a span right after the save widget span and keep it up top.

I have been trying to keep the header area clear of most things so my initial though is to do 1, but I am open to 2. What do others think?

Also, this capability should be called "Print" as we plan on having "Publish" be something that is richer (with a static URL) and includes a notion of sharing. This is more of a lightweight on the fly printing capability.

@fperez
Member
fperez commented Aug 17, 2011

:) Actually Stefan had called it print, and I suggested 'publish' after our conversation the other night. But he's actually also started to play with gist upload functionality, so you're right that we should keep the 'publish' name for something else.

However, I don't think that 'print' is the right name, because what this gives is a static html version, that can both be saved to disk or printed. So I wonder if 'View HTML' wouldn't be a better name... Thoughts?

@minrk
Member
minrk commented Aug 17, 2011

This is exactly what the GMail 'print' button does - it loads a separate HTML view, that is printer-friendly. That page also triggers the browser's print via javascript, but I'm not sure that it always has, since that didn't used to be a reliable API in browsers.

@fperez
Member
fperez commented Aug 17, 2011

Yes, but just because gmail does it doesn't mean it's right :) Further, in that case they do pop up the print dialog directly, which makes more sense. But I don't want ours to pop up a print dialog automatically, as in many cases you may want this for reasons other than actual printing. So I think we should state what the button does: it gives a static view of the notebook...

Obviously the downside is that people looking to print may do the wrong thing and try to print the active version...

How about calling it 'Print/HTML'? And not popping the print dialog automatically. Then it's clear that's the way to print, but also to get a static html view...

@minrk
Member
minrk commented Aug 17, 2011

One slight issue I found when testing with the quantum_computing example:

Some math output gets center-aligned. I think I recall there being a tweak to force left alignment somewhere in the notebook.

@ellisonbg
Member

What about "Print Preview"?

@ellisonbg
Member

@minrk: Hmm, I don't see any center justified math. Can you give more information or sent me a screen shot?

@minrk
Member
minrk commented Aug 17, 2011

Note that it's fine in the notebook itself, but multiline equations are centered in the print output:

<img src="http://img685.imageshack.us/img685/7894/screenshot20110817at141.png />

Single-line equations also seem fine.

@fperez
Member
fperez commented Aug 17, 2011

On Wed, Aug 17, 2011 at 1:28 PM, ellisonbg
reply@reply.github.com
wrote:

What about "Print Preview"?

Long, it will overflow the button even with pretty small fonts...

I'm still +1 on Print/html

@stefanv
stefanv commented Aug 18, 2011

I pulled out the printing functionality into printwidget.js, and moved the button to the panel.

The centering of maths is due to MathJax inserting a "text-align: center;" around the maths. Not sure how to override that easily.

@ellisonbg ellisonbg merged commit 968e3fe into ipython:htmlnotebook Aug 19, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment