Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

Commit

Permalink
Fix for issue #10, removing updateVersion check.
Browse files Browse the repository at this point in the history
  • Loading branch information
florianf committed Apr 23, 2017
1 parent 8e0b257 commit c5a8e56
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 73 deletions.
26 changes: 1 addition & 25 deletions controllers/Router.bones
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,7 @@ controller = Backbone.Controller.extend();
controller.prototype.initialize = function() {
if (Bones.server) return;
new views.App({ el: $('body') });

// Check whether there is a new version of TileMill or not.
$.ajax({
url: '/api/updatesVersion',
type: 'GET',
dataType: 'json',
success: function(data) {
if (window.abilities.platform === 'darwin') return;
if (!data.updates) return;
if (!semver.gt(data.updatesVersion,
window.abilities.tilemill.version)) return;
new views.Modal({
content:_('\
A new version of TileMill is available.<br />\
Update to TileMill <%=version%> today.<br/>\
<small>You can disable update notifications in the <strong>Settings</strong> panel.</small>\
').template({ version:data.updatesVersion }),
affirmative: 'Update',
negative: 'Later',
callback: function() { window.open('http://tilemill.com') }
});
}
});


// Add catchall routes for error page.
this.route(/^(.*?)/, 'error', this.error);
};
Expand Down Expand Up @@ -153,4 +130,3 @@ controller.prototype.oauthError = function() {
});
});
};

48 changes: 0 additions & 48 deletions servers/App.bones
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ server.prototype.initialize = function(app) {
// Used by the native Cocoa app to retrieve specific settings.
this.get('/api/Key/:key', this.getKey);

// Endpoint for checking for new TileMill version
this.get('/api/updatesVersion', this.updatesVersion);

// Custom Project sync endpoints.
this.get('/api/Project/:id.xml', this.projectXML);
this.get('/api/Project/:id.debug', this.projectDebug);
Expand Down Expand Up @@ -131,48 +128,3 @@ server.prototype.getKey = function(req, res, next) {
return res.send(Bones.plugin.abilities[key].toString());
return next(new Error.HTTP(404));
};

server.prototype.updatesVersion = function(req, res, next) {
var settings = Bones.plugin.config;

// Config values to save.
var attr = {};

// Skip latest TileMill version check if disabled or
// we've checked the npm repo in the past 24 hours.
var skip = !settings.updates || (settings.updatesTime > Date.now() - 864e5);
var npm = require('npm');
Step(function() {
if (skip) return this();

console.warn('Checking for new version of TileMill...');
var opts = settings.httpProxy ? {proxy: settings.httpProxy} : {};
npm.load(opts, this);
}, function(err) {
if (skip || err) return this(err);

npm.localPrefix = path.join(process.env.HOME, '.tilemill');
npm.commands.view(['tilemill'], true, this);
}, function(err, resp) {
if (skip || err) return this(err);

if (!_(resp).size()) throw new Error('Latest TileMill package not found.');
if (!_(resp).toArray()[0].version) throw new Error('No version for TileMill package.');
console.warn('Latest version of TileMill is %s.', _(resp).toArray()[0].version);
attr.updatesVersion = _(resp).toArray()[0].version;
attr.updatesTime = Date.now();
this();
}, function(err) {
// Continue despite errors but log them to the console.
if (err) console.error(err);
// Save any config attributes.
if (_(attr).keys().length) (new models.Config).save(attr, {
error: function(m, err) { console.error(err); }
});
// Send the current updates settings and version
res.send({
updates: settings.updates,
updatesVersion: attr.updatesVersion || settings.updatesVersion
});
});
}

0 comments on commit c5a8e56

Please sign in to comment.