The discussion focuses on implementing a Gist onebox for Discourse, addressing challenges with dynamic loading and API rate limits. sam initially proposed a server-side approach similar to the blob oneboxer, emphasizing the need to handle file truncation and multiple files while leveraging existing syntax highlighting. He noted that client-side solutions like therubyracer or iframes were less desirable due to performance and fragility concerns.
Guilherme_Carreiro joined the thread to work on the feature, initially raising concerns about the GitHub API’s 60 requests-per-hour limit for unauthenticated requests. He suggested a client-side JavaScript approach to avoid this bottleneck. However, mcwumbly clarified that the onebox content is baked into the cooked HTML, meaning the server only needs to hit the API once per unique link, making the rate limit a non-issue for most sites. sam confirmed this, noting that exceeding 60 gists per hour would be rare and offering GitHub OAuth as an optional enhancement.
With the concern resolved, Guilherme_Carreiro proceeded with the server-side implementation and submitted a pull request at PR #258. When digitalsurgeon asked if the topic could be closed, sam pointed out a specific Gist that was not rendering correctly, indicating the feature was not yet fully functional. Finally, codinghorror confirmed that the implementation was working as expected.
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.
I was following a similar approach to the blob oneboxer, that is to make requests to “Gist API” and build a HTML component on server side. It sounded clean for me.
However, I’m concerned about something that read here (GitHub REST API documentation - GitHub Docs):
“For unauthenticated requests, the rate limit allows you to make up to 60 requests per hour.”
I think that is a bad idea to make requests to Gist API from server side, considering that low limit. So, what do you think about to make these requests from the client side @sam?
Some JavaScript would be added in the mustache templete to keep the component decoupled.