# Pastebin onebox?

**URL:** https://meta.discourse.org/t/pastebin-onebox/29867
**Category:** Feature
**Created:** [June 10, 2015, 7:47pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867 "2015-06-10T19:47:57Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [June 10, 2015, 7:47pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/1 "2015-06-10T19:47:57Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 10, 2015, 8:10pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/2 "2015-06-10T20:10:16Z")

</div>

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

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [June 10, 2015, 11:03pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/3 "2015-06-10T23:03:52Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [January 15, 2016, 4:08pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/4 "2016-01-15T16:08:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [January 18, 2016, 4:24pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/5 "2016-01-18T16:24:36Z")

</div>

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

> <https://pastebin.com/raw/YH8wQDi8>

Enjoy, and thanks for nudging me about this @downey 🙂

* * *

[https://github.com/discourse/onebox/commit/29400bcb7ac74f902bed24ac8da175f953b01c56](https://github.com/discourse/onebox/commit/29400bcb7ac74f902bed24ac8da175f953b01c56)

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [January 18, 2016, 5:19pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/6 "2016-01-18T17:19:15Z")

</div>

This works great. Thanks @techAPJ!

---

<div class="post-metadata">

### Author: ![lrossouw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lrossouw/32/121275_2.png) [@lrossouw](https://meta.discourse.org/u/lrossouw)
#### Post date: [January 18, 2016, 5:53pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/7 "2016-01-18T17:53:53Z")

</div>

And the open source clone hastebin?  
😃

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [January 18, 2016, 6:47pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/8 "2016-01-18T18:47:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lrossouw](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lrossouw/32/121275_2.png) [@lrossouw](https://meta.discourse.org/u/lrossouw)
#### Post date: [January 18, 2016, 7:51pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/9 "2016-01-18T19:51:52Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 18, 2016, 11:02pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/10 "2016-01-18T23:02:57Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wil93](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wil93/32/121264_2.png) [@wil93](https://meta.discourse.org/u/wil93)
#### Post date: [February 8, 2016, 1:05pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/11 "2016-02-08T13:05:37Z")

</div>

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

> <https://pastebin.com/awq7Zhs9>

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [February 8, 2016, 2:36pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/12 "2016-02-08T14:36:21Z")

</div>

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:

> <https://pastebin.com/bLQcKwjy>

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 8, 2016, 7:35pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/13 "2016-02-08T19:35:57Z")

</div>

Shouldn’t that be min-height then?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [February 8, 2016, 7:45pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/14 "2016-02-08T19:45:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [February 8, 2016, 8:00pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/15 "2016-02-08T20:00:54Z")

</div>

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](https://www.w3.org/TR/CSS2/visudet.html#inline-replaced-height) (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 ☹ 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.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [February 8, 2016, 8:04pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/16 "2016-02-08T20:04:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [February 10, 2016, 6:47pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/17 "2016-02-10T18:47:05Z")

</div>

> [@cpradio](#):
>
> 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.

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

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [February 22, 2016, 11:06am UTC](https://meta.discourse.org/t/pastebin-onebox/29867/18 "2016-02-22T11:06:09Z")

</div>

> [@wil93](#):
>
> Only 3 lines are shown even if there are more…

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:

> **[How do I reply to folks here?](https://try.discourse.org/t/how-do-i-reply-to-folks-here/51/6)**
>
> I noticed there’s a few different ways to reply. I’m unclear which method of replying I should use, and when. Can anyone clarify this for me? Also how do I quote someone else’s post, as I have seen others do in replies here?

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 22, 2016, 4:28pm UTC](https://meta.discourse.org/t/pastebin-onebox/29867/19 "2016-02-22T16:28:44Z")

</div>

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:

> <https://pastebin.com/5HAC1rHc>

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [December 4, 2025, 11:36am UTC](https://meta.discourse.org/t/pastebin-onebox/29867/20 "2025-12-04T11:36:00Z")

</div>


