Skip to content

Instantly share code, notes, and snippets.

@sinky
Last active October 10, 2015 19:58
Show Gist options
  • Save sinky/3742591 to your computer and use it in GitHub Desktop.
Save sinky/3742591 to your computer and use it in GitHub Desktop.
load gihub repos starred by user
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<span id="gh"></span>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
var githubStars, link, repoDesc, desc, listItem;
githubStars = jQuery("<ul id='githubStars'/>");
jQuery.getJSON('https://api.github.com/users/sinky/starred?per_page=500&callback=?', function(r) {
jQuery.each(r.data, function(i, repo) {
link = jQuery("<a target='_blank'/>").attr("href", repo.html_url).text(repo.name);
repoDesc = repo.description;
if(repoDesc.length > 80) {
repoDesc = repoDesc.substring(0, 80) + "...";
}
desc = jQuery("<span style='display:block; margin-bottom: .5em;' class='desc'/>").text(repoDesc);
listItem = jQuery("<li class='repo'/>").append(link).append(desc);
githubStars.append(listItem);
});
jQuery("#gh").append(githubStars);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment