mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
Handle when github api returns a null author, and other missing info
This commit is contained in:
parent
590bb2acac
commit
3af2ab9022
|
@ -39,11 +39,23 @@ $(function(){
|
||||||
var data = response.data;
|
var data = response.data;
|
||||||
$.each(data, function(i, commit){
|
$.each(data, function(i, commit){
|
||||||
var $li = $('<li></li>').appendTo( $commitsList );
|
var $li = $('<li></li>').appendTo( $commitsList );
|
||||||
|
if( commit.sha && commit.commit && commit.commit.message && commit.commit.author && commit.commit.committer && commit.commit.committer.date ) {
|
||||||
|
if( commit.author && commit.author.gravatar_id ) {
|
||||||
$('<div class="left"><img src="https://www.gravatar.com/avatar/' + commit.author.gravatar_id + '.png?s=38&r=pg&d=identicon"></div>').appendTo( $li );
|
$('<div class="left"><img src="https://www.gravatar.com/avatar/' + commit.author.gravatar_id + '.png?s=38&r=pg&d=identicon"></div>').appendTo( $li );
|
||||||
|
} else {
|
||||||
|
$('<div class="left"><img src="https://www.gravatar.com/avatar/b30fff48d257cdd17c4437afac19fd30.png?s=38&r=pg&d=identicon"></div>').appendTo( $li );
|
||||||
|
}
|
||||||
$right = $('<div class="right"></div>').appendTo( $li );
|
$right = $('<div class="right"></div>').appendTo( $li );
|
||||||
$('<span class="commit-message"><a href="https://github.com/discourse/discourse/commit/' + commit.sha + '" target="_blank">' + commit.commit.message + '</a></span><br/>').appendTo( $right );
|
$('<span class="commit-message"><a href="https://github.com/discourse/discourse/commit/' + commit.sha + '" target="_blank">' + commit.commit.message + '</a></span><br/>').appendTo( $right );
|
||||||
$('<span class="commit-meta">by <span class="committer-name">' + commit.committer.login + '</span> - <span class="commit-time">' + $.timeago(commit.commit.committer.date) + '</span></span>').appendTo( $right );
|
$('<span class="commit-meta">by <span class="committer-name">' + commit.commit.author.name + '</span> - <span class="commit-time">' + $.timeago(commit.commit.committer.date) + '</span></span>').appendTo( $right );
|
||||||
$('<div class="clearfix"></div>').appendTo( $li );
|
$('<div class="clearfix"></div>').appendTo( $li );
|
||||||
|
} else {
|
||||||
|
// Render nothing. Or render a message:
|
||||||
|
// $('<div class="left"> </div>').appendTo( $li );
|
||||||
|
// $right = $('<div class="right"></div>').appendTo( $li );
|
||||||
|
// $('<span class="commit-meta">this commit cannot be rendered</span>').appendTo( $right );
|
||||||
|
// $('<div class="clearfix"></div>').appendTo( $li );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user