Print long topic to PDF, redux, again

feedback

(cpradio) #28

I think he is stating, using the Print > Save as PDF in your browser, or using a virtual printer that prints to PDF on your computer. It isn’t being converted to PDF on the server. If that is the case, moving it to a scheduled job won’t solve anything, but I could have misread that.


(Rafael dos Santos Silva) #29

Exactly @cpradio. Discourse is just generating html.


(Rafael dos Santos Silva) #30

It’s a start. I’ve done the must have parts, but there’s probably something I forgot.


(Joshua Rosenfeld) #32

So has this been merged yet?

Subtly dealing with whisper I think exisits here…


(Rafael dos Santos Silva) #33

I’m fixing my mistakes in the PR with help from @tgxworld and @zogstrip. Also we are discussing enabling by default with a small limit.


(Jay Pfaffman) #34

Anything up with this? I have an academic user who needs to export entire discussions for offline analysis.


(Jeff Atwood) #35

We weren’t able to come up with anything we liked here, so we kinda put it on the back burner.


(Jay Pfaffman) #36

My solution is going to be a client-side parser that’ll take a topic URL and spit out something vaguely resembling in Mbox file.


(Rafael dos Santos Silva) #37

First version is a go on Meta :tada:

  1. Go to a long topic: The State of JavaScript on Android in 2015 is... poor

  2. Press CTRL+P

  3. :printer:


(Sam Saffron) #38

The quote styling is a bit funky :slight_smile:


(Barry van Oudtshoorn) #39

Looks great!

I’ve noticed on Firefox that I sometimes get the browser-native print dialog pop up immediately, then your new popup window once I close the print dialog, and then the desired print dialog. I also noticed that the popup-blocker kicked in – so is the keypress perhaps not prevent propagation of the event, and is it perhaps opening the popup after an async call, rather than as a direct result of the keypress?


(Rafael dos Santos Silva) #40

Exactly. I couldn’t find a way to properly stop propagation on the print event. (it doesn’t look possible)


(Barry van Oudtshoorn) #41

I don’t know if it’s possible on the print event, but it’s possible on the key combo. (I didn’t know there was a print event!) Note that you can’t use keypress – that only works in Firefox, as the other browsers seem to handle the default print in keydown.

Here’s the super-simple approach:

https://jsfiddle.net/0kch2s63/2/

It works correctly in both Firefox and Chrome. Unfortunately in Edge you still get the printing popup – but the event is handled appropriately. Not sure about Safari – I don’t have a Mac on me at present. :slight_smile:


(Rafael dos Santos Silva) #42

This was happening indeed in earlier versions. Since this line got added, it doesn’t happen anymore with me on latest Firefox at Ubuntu Linux.


(Rafael dos Santos Silva) #43

I tried an approach were we could re-use the CSS we have:

Not sure if it’s the best way, but this way we doesn’t bloat the crawler version for bots and keep the style DRY.


One of the pages of our longest topic (157 pages long) on meta with quotes and oneboxes:


(Jeff Atwood) #44

@falco can you summarize the final result here?


(Rafael dos Santos Silva) #45

As requested, there is no UI for printing.

So any user can start to print by pressing CTRL+P when on a long topic. (This shortcut is show in our keyboard help)

For example, going to The State of JavaScript on Android in 2015 is... poor and pressing CTRL+P will open a popup with a print dialog asking to print 64 pages.


(Tobias Eigen) #46

Nice work! I love this!

I don’t suppose there is a way to exclude certain (or all) html customizations from the javascriptless or print view, is there? Right now it shows up as a bulleted table of contents because it’s not including the accompanying css, which we don’t want.

Example:


(cpradio) #47

Sure you can! Or at least in theory. I haven’t had a chance to put it in practice yet though.

@media print {
  .menu-primary-container { display: none }
}

You can also hide such things from the crawler using

body.crawler {
  .menu-primary-container { display: none }
}

Edit: and by crawler, I mean the crawler view the print window seems to utilize. Google will still see your links as I don’t think it parses CSS to know what content it should index (I could be wrong on that though).


(Kane York) #48

(This is off topic)
I think Google does do this, I remember some posts talking about how they detected font-color: #fffffe on keyword stuffing as being too invisible to see.