Skip to content

Instantly share code, notes, and snippets.

@darkhelmet
Created March 4, 2010 04:49
Show Gist options
  • Save darkhelmet/321408 to your computer and use it in GitHub Desktop.
Save darkhelmet/321408 to your computer and use it in GitHub Desktop.
function GithubBadge(json) {
if (json) {
var badge = new Object();
badge['username'] = json.user.login;
badge['repos'] = _.select(json.user.repositories, function(r) {
return !r.fork && '' != r.description;
}).sort(function() {
return (Math.round(Math.random()) - 0.5);
}).slice(0, 12);
$('#github-badge').html(Jaml.render('github-badge', badge));
if (!$.browser.msie) { $('a.github').tooltip(); }
}
}
Jaml.register('repo', function(repo) {
li(a({ title: repo.description, cls: 'github', href: repo.url }, repo.name));
});
Jaml.register('github-badge', function(badge) {
div({ cls: 'github-badge' },
h1({ cls: 'center' }, "What I'm Hacking"),
ul(
Jaml.render('repo', badge.repos),
li(a({ href: 'http://github.com/' + badge.username }, 'Fork me on Github, and see the rest of my code'))
)
);
});
Jaml.register('simple', function() {
div(
h1("Some title"),
p("Some exciting paragraph text"),
br(),
ul(
li("First item"),
li("Second item"),
li("Third item")
)
);
});
<div>
<h1>Some title</h1>
<p>Some exciting paragraph text</p>
<br />
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment