Skip to content

Instantly share code, notes, and snippets.

@soemarko
Created November 26, 2011 16:18
Show Gist options
  • Select an option

  • Save soemarko/1395926 to your computer and use it in GitHub Desktop.

Select an option

Save soemarko/1395926 to your computer and use it in GitHub Desktop.
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@chrishough
Copy link
Copy Markdown

works perfectly, thanks!

@edipofederle
Copy link
Copy Markdown

@suzel
Copy link
Copy Markdown

suzel commented Jan 21, 2013

Thanks :)

@abbeycode
Copy link
Copy Markdown

My code looks like edipofederle's a couple posts above (whether I use this embed, or the embed provided on the Gist sidebar).

@mapio
Copy link
Copy Markdown

mapio commented Jan 25, 2013

Perhaps a simpler solution can be obtained using the .pibb secret extension, instead of the .js one + writecapture… see for example https://gist.github.com/1395926.pibb

@likejazz
Copy link
Copy Markdown

thanks a lot!

@zmcartor
Copy link
Copy Markdown

Receiving 'control-allow-origin' errors when attempting to load gists. Requests return 404 from Github, although it appears Chrome smacks them down. Any ideas or workaround ?
Gists are accessible when requested via GET in browser or cURL.

@neilvcarvalho
Copy link
Copy Markdown

Thank you!

@soemarko
Copy link
Copy Markdown
Author

soemarko commented Apr 3, 2013

For those having interface problems, they're caused by the inherited CSS from the theme.

In this case, inspect element is your friend. If the theme is done right, you should be able to override it from {CustomCSS}

@calvinmetcalf
Copy link
Copy Markdown

this really screwed up my page, gists are available as jsonp which means you can do https://gist.github.com/calvinmetcalf/5910196

@hamedqaderi
Copy link
Copy Markdown

It shows me just nothing. Why?

@kroneldo28
Copy link
Copy Markdown

Thank you. It worked for me.

@metasansana
Copy link
Copy Markdown

forking!

@otkrsk
Copy link
Copy Markdown

otkrsk commented Nov 20, 2013

Awesome! Thanks for this!

@glennblock
Copy link
Copy Markdown

Cool! I took a slightly different approach and did this on the server. It requires a slight mod to posts.js.

https://gist.github.com/glennblock/8662218

The difference here is that it supports the terse Wordpress gist plugin model i.e. [gist id=xxxxxxx]

@davidmurray
Copy link
Copy Markdown

Awesome, thanks!

@djabif
Copy link
Copy Markdown

djabif commented Jun 12, 2014

thanks!!!!

@btcrooks
Copy link
Copy Markdown

btcrooks commented Oct 3, 2014

I rather use this than embed with prettify.js. Thanks for the work mate!

@lzubiaur
Copy link
Copy Markdown

lzubiaur commented Jan 6, 2015

Thank you. Works great!

@swbuehler
Copy link
Copy Markdown

This is awesome, guys; keep up the great work!

@ivanhjc
Copy link
Copy Markdown

ivanhjc commented Sep 11, 2015

How about Blogspot? I haven't found any way yet to embed code into posts. Please help!

@AbhimanyuAryan
Copy link
Copy Markdown

After I add this there .js links in my theme the post starts repeating over my blog "Same post appear twice". Please consider fixing it.

You can have look.

rubygemer.tumblr.com

@tryvin
Copy link
Copy Markdown

tryvin commented Nov 1, 2015

A little update to this code, as Tumblr Rich text editor kindas mess with the "div' tag

https://gist.github.com/tryvin/74c72bdae96f21e844a0

@acedubs
Copy link
Copy Markdown

acedubs commented Sep 17, 2016

:: nasa-mems.tumblr.com .C("foo", n=as.integer(5), x=as.double(rnorm(5)))
with fooz implemented as

void fooz(int *nin, double *x)
{
int n = nin[0];

int i;

for (i=0; i<n; i++)
x[i] = x[i] * x[i];
}

@zbroyar
Copy link
Copy Markdown

zbroyar commented Apr 11, 2017

Using this I can see my gist embedded only for a second. Then it changes to the following message:
window['__document_write_ajax_callbacks__']['1']();
What am I doing wrong?

@raphaelyancey
Copy link
Copy Markdown

raphaelyancey commented Jun 29, 2017

Works on desktop but seems to be broken on mobile: only the URL is displayed. Anyone else experiencing it?

Edit
It's Tumblr custom mobile theme that somehow break the gist. You must disable it in the blog appearance settings, under Advanced options at the bottom of the sidebar (where you can set custom CSS). But then the embed will take full width and break the page on mobile. To correct that : .gist-data { max-width: 90vw; }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment