Skip to content

Instantly share code, notes, and snippets.

@dinks
Created October 22, 2013 15:07
Show Gist options
  • Save dinks/7102379 to your computer and use it in GitHub Desktop.
Save dinks/7102379 to your computer and use it in GitHub Desktop.
A Pen by Dinesh Vasudevan.
<div id="gists" class="gists" data-username="dinks"></div>
(function() {
var url = 'https://api.github.com/users/__USERNAME__/gists';
$.fn.gistify = function() {
var selfer = $(this);
var glDesc = '<h2><a href="__URL__">__DESCRIPTION__</a></h2>';
var name = selfer.data('username');
if (name === null) {
return;
}
var constructedUrl = url.replace(/__USERNAME__/, name);
$.when($.ajax(constructedUrl, {
dataType: 'jsonp'
})).done(function(data) {
$.each(data.data, function() {
selfer.append(glDesc.replace(/__DESCRIPTION__/, this.description).replace('__URL__', this.url));
});
});
};
})();
$(document).ready(function() {
$('#gists').gistify();
});
@import "compass";
.gists {
background-color: #AAEEAA;
h2 {
border-bottom: 1px solid #EEEEEE;
a {
color: #AAAAAA;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment