Last active
December 15, 2015 15:29
-
-
Save treffynnon/5281853 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- In the HTML of your posts: Replace ID number with ID of your gist --> | |
<p class="embed_gist"><a href="http://gist.github.com/367154">http://gist.github.com/367154</a></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- uses jQuery --> | |
<!-- cannot find original JS code source, but I didn't write it --> | |
{block:IfGitHubGists} | |
<script type="text/javascript"> | |
//<![CDATA[ | |
$(document).ready(function() { | |
var gist_injectors = $.map($('p.embed_gist').get(), (function(p){ | |
return function(){ | |
gist_injectors.shift(); | |
var atag = $(p).find('a:first'); | |
var gist_id = atag.attr('href').replace(/.*gist.github.com\//g,''); | |
document.write = function(gist_style_link){ | |
$('head').append(gist_style_link); | |
document.write = function(gist_html){ | |
$(p).replaceWith(gist_html); | |
if (gist_injectors[0]) gist_injectors[0](); | |
}; | |
}; | |
if(gist_id.match(/#/)){ | |
gist_id = gist_id.substr(0, gist_id.indexOf('#')); | |
} | |
if(!gist_id.match(/.js/)){ | |
gist_id += '.js'; | |
} | |
if(atag.attr('title')) { | |
gist_id += '?file=' + atag.attr('title'); | |
} | |
$(document.body).append('<scr'+ | |
'ipt src="http://gist.github.com/'+gist_id+'"></scr'+ | |
'ipt>'); | |
}; | |
})); | |
if (gist_injectors[0]) gist_injectors[0](); | |
}); | |
//]]> | |
</script> | |
{/block:IfGitHubGists} | |
<meta name="if:GitHub Gists" content="0"/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment