Skip to content

Commit

Permalink
Fix error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed May 9, 2012
1 parent 4987347 commit 45a92a3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ tmp/
bin/
fonts/
assets/vendor/
assets/embedded_fonts/
public/
src/
support/
6 changes: 4 additions & 2 deletions assets/js/nodeca.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
nodeca.runtime.sio.emit('server', msg, function (res) {
if (res.version !== nodeca.runtime.version) {
// TODO: implement software upgrade here
nodeca.client.fontomas.util.notify('error',
'Application server/client version mismatch. Please reload.');
nodeca.client.fontomas.util.notify('error', {layout: 'bottom'},
'<strong>Application is outdated. Please ' +
'<a href="/" style="text-decoration:underline">reload</a>' +
' page.</strong>');
return;
}

Expand Down
8 changes: 7 additions & 1 deletion client/fontomas/models/glyphs_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module.exports = Backbone.Collection.extend({


add: function (models, options) {
// FIXME: this seems to be buggy - we need to leave only "valid" glyphs
// to pass to the original add function of Backbone. _.filter
// should be used instead.
_.each(_.isArray(models) ? models.slice() : [models], function (model) {
var code = model.get('source_glyph').code,
css = model.get('source_glyph').css || 'unknown';
Expand All @@ -23,7 +26,9 @@ module.exports = Backbone.Collection.extend({

// no more free codes
if (null === code) {
nodeca.client.fontomas.util.notify('alert', 'No more space for glyphs.');
// this should never happen in real life.
nodeca.client.fontomas.util.notify('error',
"Internal Error. Can't allocate code for glyph.");
return;
}
}
Expand All @@ -46,6 +51,7 @@ module.exports = Backbone.Collection.extend({
var code = model.get('unicode_code'), css = model.get('css');

if (!this.used_codes[code]) {
// this should never happen in real life.
nodeca.client.fontomas.logger.error(
"models.glyphs_collection.remove: code <" + code + "> " +
"not found in used_codes map"
Expand Down
7 changes: 4 additions & 3 deletions client/fontomas/models/result_font.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"use strict";

var raise_max_glyphs_reached = _.throttle(function () {
nodeca.client.fontomas.util.notify('alert',
'You have reached maximum allowed glyphs limit. Maximum ' +
nodeca.client.fontomas.util.notify('error',
"You can't select more than " +
nodeca.config.fontomas.max_glyphs +
' glyphs per font allowed.');
" icons at once. If you have a real use-case," +
" please, create ticket in issue tracker.");
}, 1000);


Expand Down
12 changes: 8 additions & 4 deletions client/fontomas/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
"use strict";


module.exports.notify = function (type, message) {
$.noty({
module.exports.notify = function (type, options, message) {
if (!message) {
message = options;
options = {};
}

$.noty(_.extend({layout: 'topRight'}, options, {
type: type,
text: message,
theme: 'noty_theme_twitter',
layout: 'topRight',
});
}));
};


Expand Down
2 changes: 1 addition & 1 deletion lib/init/http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var socket_io = require('socket.io');


function attach_connect_app(server) {
var app = connect(), static_helpers = {}, download_root;
var app = connect(), static_helpers = {};

app.use("/assets/", connect.compress());
app.use("/assets/", nodeca.runtime.assets_server);
Expand Down
9 changes: 6 additions & 3 deletions server/fontomas/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,23 @@ module.exports.status = function (params, callback) {

// request font generation
module.exports.generate = function (params, callback) {
var self = this, glyphs = get_glyphs_config(params), font_id, user;
var self = this, glyphs = get_glyphs_config(params), font_id, user, errmsg;

if (!glyphs) {
callback("Invalid request");
return;
}

if (nodeca.config.fontomas.max_glyphs < glyphs.length) {
errmsg = 'Too many icons requested: ' + glyphs.length +
' of ' + nodeca.config.fontomas.max_glyphs + ' allowed.';

this.response.error = {
code: 'MAX_GLYPHS_LIMIT',
message: 'Too much glyphs requested.'
message: errmsg
};

nodeca.logger.warn("Too much glyphs requested: " + glyphs.length);
nodeca.logger.warn(errmsg);
callback();
return;
}
Expand Down

0 comments on commit 45a92a3

Please sign in to comment.