Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
plugin.onMessageInsertion = function(event){
// regex is probably wrong
var github_status_expression = /https*:\/\/\/(.*)\/(.*)/i;
var last_anchor = Talker.getLastInsertion().find('a');
var last_href = last_anchor.attr('href') || '';
if (github_status_expression.test(last_href)){
var author = last_href.match(github_status_expression)[1];
var repo = last_href.match(github_status_expression)[2];
var url = ''+author+'/'+repo+'?callback=?';
if (last_anchor.hasClass('transformed')){
return true; // Do not transform the link a second time.
$.getJSON(url, function(data){
if (!last_anchor.hasClass('transformed')){
var repo = data.repository;
// todo some styling
var widget = '<a href=' + repo.url + '>''</a>'+'<p>'+repo.description+'</p>'+'<p>'+'<span=\'watchers\'>'+repo.watchers+'</span>'+'</p>';
clear: 'both',
float: 'left'
$('<div>').attr({'class': 'github-repo'}).append(widget)
).addClass('transformed'); // tag as tranformed so we don't do it again
// syntax error somewhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.