Pastebin onebox?


(Michael Downey) #1

Is anyone thinking about or working on a onebox for Pastebin? The Gist onebox is pretty good but it seems many more of our people (and here too, I think) are going with pastebin instead.


Ubuntu Pastebin onebox?
(Jeff Atwood) #2

Sure, can you research that @techapj and see what’s involved to make that work with Oneboxer?


(Kane York) #3

For the raw contents, all you need to do is take the Paste ID and make a request to /raw.php?i=<paste id>. I’m not sure how to get the language, date, author, etc.


(Michael Downey) #4

@techapj Did you happen to find an easy solution for this? I’ve tried to encourage GitHub gists but old habits die hard. :slight_smile:


(Arpit Jalan) #5

Okay, I just created a custom onebox engine for Pastebin! :tada:

Enjoy, and thanks for nudging me about this @downey :slightly_smiling:



(Michael Downey) #6

This works great. Thanks @techAPJ!


(Louis Rossouw) #7

And the open source clone hastebin?
:smiley:


(Arpit Jalan) #8

It seems like hastebin.com does not provide any API access, nor any oEmbed endpoint.


(Louis Rossouw) #9

Yes not an embed point but it has the same /raw/ function as pastebin.


(Jeff Atwood) #10

You’d need to lobby them to support oEmbed or OpenGraph…


(William Di Luigi) #11

Wouldn’t it be better to remove the max-height: 100px though? Only 3 lines are shown even if there are more…

http://pastebin.com/awq7Zhs9


(Arpit Jalan) #12

Thats’s because if max-height property is not provided then the one line pastes takes up 150px height by default. Adding max-height: 100px limits that to 100px. See:

http://pastebin.com/bLQcKwjy


(Jeff Atwood) #13

Shouldn’t that be min-height then?


(cpradio) #14

Not exactly. Something is forcing iframes to be 150px tall. Need to figure out where that is happening to figure out how to properly fix it.


(cpradio) #15

Okay, big thanks to @RyanReese (who found the spec for me and solidified that I was on the right track), but unfortunately this is part of the CSS2 spec.

Visual formatting model details (search for 150)

In short, Chrome or whatever browser you are using is enforcing the 150px iframe size (so long as they follow the CSS2 spec).

So how do you reduce it or enlarge it based on the content of the iframe? With JavaScript :frowning: There isn’t a CSS solution that can tell you the height of the iframe content (as that data exists on another page/site). So unless you can execute some JavaScript to get the inner height of the iframe before it is cooked, Discourse just has to pick a happy medium to ship with.

If you can, the idea would be to detect if it is greater than 100px, if it is, set the height style and max-height to 300px (to give it some room to show the user what data is there. Otherwise, set it to 100px for both attributes.


(cpradio) #16

Also, it would be ideal to handle these max-height/min-height/height styles in a class labelled pastebin-onebox so it is easier to override versus attaching it to the iframe via inline styles.

Maybe have a pastebin-onebox (which is the 100px setting) and a pastebin-onebox-large for the 300px setting


(Kane York) #17

You could have the oneboxing code download raw.php and use the ‘large’ if there’s more than 1 line.


(Arpit Jalan) #18

Okay I fixed this issue by removing Pastebin iframe and instead extracting first 10 lines of a paste, similar to GitHub Gist onebox.


See the improved pastebin onebox demo here:


(Michael Downey) #19

This looks nice but it seems to struggle with long lines. The old one wrapped, but the new one does not. Anything that can be done for that?

Old one here until an update installed and the post is rebaked:

http://pastebin.com/5HAC1rHc