mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
fa8a84f20c
bring in latest ace from local so we don't mess up with https
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
/**
|
|
A model for a git commit to the discourse repo, fetched from the github.com api.
|
|
|
|
@class GithubCommit
|
|
@extends Discourse.Model
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
Discourse.GithubCommit = Discourse.Model.extend({
|
|
gravatarUrl: function(){
|
|
if( this.get('author') && this.get('author.gravatar_id') ){
|
|
return("https://www.gravatar.com/avatar/" + this.get('author.gravatar_id') + ".png?s=38&r=pg&d=identicon");
|
|
} else {
|
|
return "https://www.gravatar.com/avatar/b30fff48d257cdd17c4437afac19fd30.png?s=38&r=pg&d=identicon";
|
|
}
|
|
}.property("commit"),
|
|
|
|
commitUrl: function(){
|
|
return("https://github.com/discourse/discourse/commit/" + this.get('sha'));
|
|
}.property("sha"),
|
|
|
|
timeAgo: function() {
|
|
return Discourse.Formatter.relativeAge(new Date(this.get('commit.committer.date'), {format: 'medium', leaveAgo: true}));
|
|
}.property("commit.committer.date")
|
|
});
|
|
|
|
Discourse.GithubCommit.reopenClass({
|
|
findAll: function() {
|
|
var result = Em.A();
|
|
Discourse.ajax( "https://api.github.com/repos/discourse/discourse/commits?callback=callback", {
|
|
dataType: 'jsonp',
|
|
type: 'get',
|
|
data: { per_page: 40 }
|
|
}).then(function (response) {
|
|
_.each(response.data,function(commit) {
|
|
result.pushObject( Discourse.GithubCommit.create(commit) );
|
|
});
|
|
});
|
|
return result;
|
|
}
|
|
});
|