2013-02-20 13:15:50 -05:00
|
|
|
(function() {
|
|
|
|
|
2013-02-21 14:09:28 -05:00
|
|
|
/**
|
|
|
|
Our data model for determining whether there's a new version of Discourse
|
|
|
|
|
2013-02-21 15:03:43 -05:00
|
|
|
@class VersionCheck
|
2013-02-21 14:09:28 -05:00
|
|
|
@extends Discourse.Model
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
2013-02-21 15:03:43 -05:00
|
|
|
**/
|
|
|
|
window.Discourse.VersionCheck = Discourse.Model.extend({
|
|
|
|
upToDate: function() {
|
|
|
|
return this.get('latest_version') === this.get('installed_version');
|
|
|
|
}.property('latest_version', 'installed_version'),
|
|
|
|
|
|
|
|
gitLink: function() {
|
|
|
|
return "https://github.com/discourse/discourse/tree/" + this.get('installed_sha');
|
|
|
|
}.property('installed_sha'),
|
|
|
|
|
|
|
|
shortSha: function() {
|
|
|
|
return this.get('installed_sha').substr(0,10);
|
|
|
|
}.property('installed_sha')
|
|
|
|
});
|
2013-02-20 13:15:50 -05:00
|
|
|
|
|
|
|
Discourse.VersionCheck.reopenClass({
|
|
|
|
find: function() {
|
2013-02-21 13:26:30 -05:00
|
|
|
var promise = new RSVP.Promise();
|
2013-02-21 12:54:40 -05:00
|
|
|
jQuery.ajax({
|
2013-02-20 13:15:50 -05:00
|
|
|
url: '/admin/version_check',
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(json) {
|
2013-02-21 12:54:40 -05:00
|
|
|
promise.resolve(Discourse.VersionCheck.create(json));
|
2013-02-20 13:15:50 -05:00
|
|
|
}
|
|
|
|
});
|
2013-02-21 12:54:40 -05:00
|
|
|
return promise;
|
2013-02-20 13:15:50 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}).call(this);
|