# Implement Gist onebox

**URL:** <https://meta.discourse.org/t/implement-gist-onebox/14041>\
**Category:** Feature\
**Tags:** rfc, spec\
**Created:** [2014 年 3 月 24 日午前 12:18 UTC](https://meta.discourse.org/t/implement-gist-onebox/14041 "2014-03-24T00:18:02Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2014 年 3 月 24 日午前 12:18 UTC](https://meta.discourse.org/t/implement-gist-onebox/14041/1 "2014-03-24T00:18:03Z")

</div>

We had a naive implementation for Gist oneboxes, however it failed miserably due to dynamic loading:

In particular this:

> <https://stackoverflow.com/questions/9154026/jquery-dynamically-load-a-gist-embed>

To resolve this issue:

The [Gist oneboxer](https://github.com/discourse/onebox/blob/master/lib/onebox/engine/github_gist_onebox.rb) should use a similar approach to the [blob oneboxer](https://github.com/discourse/onebox/blob/master/lib/onebox/engine/github_blob_onebox.rb)

1. It must take care of truncating huge files
2. It must take care of displaying gists with multiple files

Syntax highlighting is to be handled by our pre-existing syntax highlighting engine, all the onebox is to do is to decorate divs with the guessed syntax.

* * *

I thought of possibly using therubyracer to evaluate the gist js, but it inserts stylesheets. Additionally there is a possibly iframe approach but it will be both slower (and impact rendering) and more fragile.

---

_[View the full topic](https://meta.discourse.org/t/implement-gist-onebox/14041)._
