diff --git a/src/routes/api.js b/src/routes/api.js index f77771ff97..9502a96f08 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -68,39 +68,44 @@ var path = require('path'), async.each(data.categories, iterator, function (err) { // Assemble the MOTD - var motdString; + var motdString, + assemble = function() { + data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none'; + data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default'); + data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : ''; + + data.motd = require('marked')(motdString); + res.json(data); + }; if (!meta.config.motd) { // Construct default MOTD - translator.mget(['global:motd.welcome', 'global:motd.get', 'global:motd.fork', 'global:motd.like', 'global:motd.follow'], function(err, strings) { - motdString = '\n\n# NodeBB \nv' + pkg.version + '\n\n' + strings[0] + - '
\ + translator.translate('\n\n# NodeBB \nv' + pkg.version + '\n\n[[global:motd.welcome]]\ +
\ \ \ -  ' + strings[1] + '\ +  [[global:motd.get]]\ \ \ \ -  ' + strings[2] + '\ +  [[global:motd.fork]]\ \ \ \ -  ' + strings[3] + '\ +  [[global:motd.like]]\ \ \ \ -  ' + strings[4] + '\ +  [[global:motd.follow]]\ \ -
'; +
\ + ', function(motd) { + motdString = motd; + assemble(); }); } else { motdString = meta.config.motd; + assemble(); } - data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none'; - data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default'); - data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : ''; - - data.motd = require('marked')(motdString); - res.json(data); }); }); });