Files
NodeBB/src/controllers/index.js

415 lines
11 KiB
JavaScript
Raw Normal View History

2017-02-18 01:56:23 -07:00
'use strict';
2016-01-06 12:49:14 +02:00
var async = require('async');
var nconf = require('nconf');
var validator = require('validator');
var meta = require('../meta');
var user = require('../user');
var plugins = require('../plugins');
Squashed commit of the following: commit 9c86d9b2904e14927cd7e9679b92aec0951d1063 Merge: ebfa63a 5a7f811 Author: Julian Lam <julian@nodebb.org> Date: Thu Jul 20 08:41:39 2017 -0400 Merge branch 'noscript-login' of https://github.com/An-dz/NodeBB into noscript commit 5a7f81185e8f9bd7d2d011c3d495988be7e437a3 Author: André Zanghelini <an_dz@simutrans-forum> Date: Mon Jul 17 23:07:14 2017 -0300 Rename clashing variable 'next' commit ebfa63a984073a58c17aa408c363cdb03ef89985 Merge: c1801cd f159d0d Author: Julian Lam <julian@nodebb.org> Date: Mon Jul 17 16:30:40 2017 -0400 Merge branch 'noscript-logout' of https://github.com/An-dz/NodeBB into noscript commit c1801cda14e6363491e30b659902e2ae71f7e1f7 Merge: 7a5f9f3 9fd542d Author: Julian Lam <julian@nodebb.org> Date: Mon Jul 17 16:30:31 2017 -0400 Merge branch 'noscript-register' of https://github.com/An-dz/NodeBB into noscript commit 7a5f9f35abc834bb72ddddc9ca07d34f2fde8353 Merge: 44851f9 d37b95c Author: Julian Lam <julian@nodebb.org> Date: Mon Jul 17 16:30:10 2017 -0400 Merge branch 'noscript-compose' of https://github.com/An-dz/NodeBB into noscript commit f159d0d9ef1b7f600e830a96fdb4b9c87c79bb4a Author: André Zanghelini <an_dz@simutrans-forum> Date: Thu Jul 6 12:16:38 2017 -0300 Prevent form submit Required for theme change commit d37b95cb71d32d4483190609798e244c331db165 Author: André Zanghelini <an_dz@simutrans-forum> Date: Thu Jul 6 01:49:52 2017 -0300 Prevent link action with scripts Required for the theme change that changes the buttons to `a` tags. commit 9fd542d8970b7d1a4126f4edc4b44eab7d708fb0 Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 19:57:56 2017 -0300 Fix tests commit cdad5bf8c2891ad76f7441fd4d8a74b058a14e6d Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 19:09:17 2017 -0300 Update error handling commit 4ff11cd136a4fb98483f837e2cebc741380dfe76 Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 17:29:08 2017 -0300 Remove async waterfall commit df01d44e821a70c984b89e9585a325c3e02c6e37 Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 16:59:43 2017 -0300 Set noscript compose as noscript at start commit 4bcc380da72239b8315cc849a77a3036e06e4a12 Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 16:59:12 2017 -0300 Remove last useless next commit b5eac6fea11e209934c0648a7e75ad07a2167123 Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 18:35:08 2017 -0300 Last function requires no next commit 20a5cce6e6e32a454c304c448383707ec44c75a8 Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 18:06:58 2017 -0300 Remove more useless next calls commit 85ee22a79bcbbb1995106f43d4c74d6ba9206cab Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 17:46:07 2017 -0300 Remove useless next calls commit 7d984c47ad24faac1fe537dee4a5a7d697e8634c Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 15:45:31 2017 -0300 Support old themes commit 4a09dfbd08253115c342a9e829c4e6940cecb8cc Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 15:37:23 2017 -0300 Moved all error handling into helpers function commit 391aa6e67ef9ab67304005e14ac0633cdb630713 Author: André Zanghelini <an_dz@simutrans-forum> Date: Thu Jun 8 15:37:37 2017 -0300 ESLint - Fix mixed conditionals commit 80ccc6fd581d791f31e7ab62de8de611837bfc3c Author: André Zanghelini <an_dz@simutrans-forum> Date: Sat Jun 3 18:08:15 2017 -0300 Compose without scripts commit 2aca811256721238ca0cede4954213d369009885 Author: André Zanghelini <an_dz@simutrans-forum> Date: Sat Jun 3 18:00:44 2017 -0300 Register without scripts commit 097bb51577fb26f8e22f86dc274cb670ab606a8a Author: André Zanghelini <an_dz@simutrans-forum> Date: Sat Jun 3 16:42:15 2017 -0300 Logout without scripts commit d497e08109891079656fee1c145043a9c0e55f2e Author: André Zanghelini <an_dz@simutrans-forum> Date: Sat Jun 3 16:27:10 2017 -0300 Login without script
2017-07-20 08:51:04 -04:00
var topics = require('../topics');
2016-01-06 12:49:14 +02:00
var helpers = require('./helpers');
2014-02-27 14:56:14 -05:00
2017-03-02 14:57:33 +03:00
var Controllers = module.exports;
Controllers.topics = require('./topics');
Controllers.posts = require('./posts');
Controllers.categories = require('./categories');
Controllers.category = require('./category');
Controllers.unread = require('./unread');
Controllers.recent = require('./recent');
Controllers.popular = require('./popular');
Controllers.tags = require('./tags');
Controllers.search = require('./search');
2017-03-02 16:11:11 +03:00
Controllers.user = require('./user');
2017-03-02 14:57:33 +03:00
Controllers.users = require('./users');
Controllers.groups = require('./groups');
Controllers.accounts = require('./accounts');
Controllers.authentication = require('./authentication');
Controllers.api = require('./api');
Controllers.admin = require('./admin');
Controllers.globalMods = require('./globalmods');
Controllers.mods = require('./mods');
Controllers.sitemap = require('./sitemap');
2017-03-06 21:00:20 +01:00
Controllers.osd = require('./osd');
2017-03-02 14:57:33 +03:00
Controllers['404'] = require('./404');
Controllers.errors = require('./errors');
2014-02-27 14:56:14 -05:00
Controllers.home = function (req, res, next) {
2016-04-20 16:12:55 -04:00
var route = meta.config.homePageRoute || (meta.config.homePageCustom || '').replace(/^\/+/, '') || 'categories';
2015-02-27 15:00:38 -05:00
user.getSettings(req.uid, function (err, settings) {
2016-01-06 12:49:14 +02:00
if (err) {
return next(err);
}
2016-03-07 18:55:30 +00:00
if (parseInt(meta.config.allowUserHomePage, 10) === 1 && settings.homePageRoute !== 'undefined' && settings.homePageRoute !== 'none') {
2016-01-06 12:49:14 +02:00
route = settings.homePageRoute || route;
}
2015-09-17 15:31:05 -04:00
var hook = 'action:homepage.get:' + route;
if (plugins.hasListeners(hook)) {
2017-04-07 20:57:00 +00:00
return plugins.fireHook(hook, {
req: req,
res: res,
next: next,
});
2016-01-13 09:25:49 +02:00
}
if (route === 'categories' || route === '/') {
Controllers.categories.list(req, res, next);
2016-07-15 12:39:54 +03:00
} else if (route === 'unread') {
Controllers.unread.get(req, res, next);
2016-01-13 09:25:49 +02:00
} else if (route === 'recent') {
Controllers.recent.get(req, res, next);
} else if (route === 'popular') {
Controllers.popular.get(req, res, next);
2015-02-27 15:00:38 -05:00
} else {
2016-01-13 09:25:49 +02:00
var match = /^category\/(\d+)\/(.*)$/.exec(route);
2016-01-13 09:25:49 +02:00
if (match) {
2017-02-18 01:56:23 -07:00
req.params.topic_index = '1';
2016-01-13 09:25:49 +02:00
req.params.category_id = match[1];
req.params.slug = match[2];
Controllers.category.get(req, res, next);
} else {
res.redirect(route);
2015-09-17 15:31:05 -04:00
}
2015-02-27 15:00:38 -05:00
}
2015-09-17 15:31:05 -04:00
});
2014-02-27 14:56:14 -05:00
};
Controllers.reset = function (req, res, next) {
2015-01-29 01:06:48 -05:00
if (req.params.code) {
user.reset.validate(req.params.code, function (err, valid) {
2015-03-17 15:53:05 -04:00
if (err) {
return next(err);
}
2015-02-08 21:06:38 -05:00
res.render('reset_code', {
valid: valid,
2015-04-01 17:26:22 -04:00
displayExpiryNotice: req.session.passwordExpired,
2016-10-18 15:32:28 +03:00
code: req.params.code,
2016-02-10 12:53:39 +02:00
minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10),
2017-04-07 21:39:22 +00:00
breadcrumbs: helpers.buildBreadcrumbs([
{
text: '[[reset_password:reset_password]]',
url: '/reset',
},
{
text: '[[reset_password:update_password]]',
},
]),
2017-02-17 19:31:21 -07:00
title: '[[pages:reset]]',
2015-02-08 21:06:38 -05:00
});
2015-04-01 17:26:22 -04:00
delete req.session.passwordExpired;
2015-01-29 01:06:48 -05:00
});
} else {
res.render('reset', {
2016-10-18 15:32:28 +03:00
code: null,
2017-04-07 20:57:00 +00:00
breadcrumbs: helpers.buildBreadcrumbs([{
text: '[[reset_password:reset_password]]',
}]),
2017-02-17 19:31:21 -07:00
title: '[[pages:reset]]',
2015-01-29 01:06:48 -05:00
});
}
};
2014-02-27 14:56:14 -05:00
Controllers.login = function (req, res, next) {
2016-05-03 19:13:10 +03:00
var data = {};
var loginStrategies = require('../routes/authentication').getLoginStrategies();
var registrationType = meta.config.registrationType || 'normal';
var allowLoginWith = (meta.config.allowLoginWith || 'username-email');
var returnTo = (req.headers['x-return-to'] || '').replace(nconf.get('base_url'), '');
2015-06-27 21:26:19 -04:00
2016-05-09 11:40:42 -04:00
var errorText;
if (req.query.error === 'csrf-invalid') {
errorText = '[[error:csrf-invalid]]';
} else if (req.query.error) {
2016-08-30 13:19:04 +03:00
errorText = validator.escape(String(req.query.error));
2016-05-09 11:40:42 -04:00
}
2016-10-25 16:52:03 -04:00
if (returnTo) {
req.session.returnTo = returnTo;
}
2014-11-12 16:15:44 -05:00
data.alternate_logins = loginStrategies.length > 0;
data.authentication = loginStrategies;
2015-04-22 12:13:14 -04:00
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1 || parseInt(req.query.local, 10) === 1;
data.allowRegistration = registrationType === 'normal' || registrationType === 'admin-approval' || registrationType === 'admin-approval-ip';
2016-05-03 19:13:10 +03:00
data.allowLoginWith = '[[login:' + allowLoginWith + ']]';
2017-04-07 20:57:00 +00:00
data.breadcrumbs = helpers.buildBreadcrumbs([{
text: '[[global:login]]',
}]);
2016-05-09 11:40:42 -04:00
data.error = req.flash('error')[0] || errorText;
data.title = '[[pages:login]]';
2014-02-27 16:52:46 -05:00
2016-04-13 11:58:14 -04:00
if (!data.allowLocalLogin && !data.allowRegistration && data.alternate_logins && data.authentication.length === 1) {
2016-07-12 11:39:51 -04:00
if (res.locals.isAPI) {
return helpers.redirect(res, {
external: nconf.get('relative_path') + data.authentication[0].url,
2016-07-12 11:39:51 -04:00
});
}
return res.redirect(nconf.get('relative_path') + data.authentication[0].url);
2016-04-13 11:58:14 -04:00
}
2016-05-03 19:13:10 +03:00
if (req.uid) {
user.getUserFields(req.uid, ['username', 'email'], function (err, user) {
2016-05-03 19:13:10 +03:00
if (err) {
return next(err);
}
data.username = allowLoginWith === 'email' ? user.email : user.username;
data.alternate_logins = false;
2016-05-03 19:13:10 +03:00
res.render('login', data);
});
} else {
res.render('login', data);
}
2014-02-27 16:52:46 -05:00
};
Controllers.register = function (req, res, next) {
2015-06-27 21:26:19 -04:00
var registrationType = meta.config.registrationType || 'normal';
if (registrationType === 'disabled') {
2015-08-28 14:31:35 -04:00
return next();
2014-09-25 11:29:53 -04:00
}
2014-03-11 04:10:00 -04:00
2016-05-09 11:40:42 -04:00
var errorText;
if (req.query.error === 'csrf-invalid') {
errorText = '[[error:csrf-invalid]]';
}
2015-06-28 21:54:21 -04:00
async.waterfall([
function (next) {
2015-11-28 15:33:17 -07:00
if (registrationType === 'invite-only' || registrationType === 'admin-invite-only') {
2015-06-28 21:54:21 -04:00
user.verifyInvitation(req.query, next);
} else {
next();
}
},
function (next) {
2017-04-07 20:57:00 +00:00
plugins.fireHook('filter:parse.post', {
postData: {
content: meta.config.termsOfUse || '',
},
}, next);
2017-02-17 19:31:21 -07:00
},
], function (err, termsOfUse) {
2015-06-28 21:54:21 -04:00
if (err) {
2014-11-08 14:51:05 -05:00
return next(err);
}
2016-04-30 10:47:28 +03:00
var loginStrategies = require('../routes/authentication').getLoginStrategies();
var data = {
'register_window:spansize': loginStrategies.length ? 'col-md-6' : 'col-md-12',
2017-02-18 01:19:20 -07:00
alternate_logins: !!loginStrategies.length,
2016-04-30 10:47:28 +03:00
};
data.authentication = loginStrategies;
data.minimumUsernameLength = parseInt(meta.config.minimumUsernameLength, 10);
data.maximumUsernameLength = parseInt(meta.config.maximumUsernameLength, 10);
data.minimumPasswordLength = parseInt(meta.config.minimumPasswordLength, 10);
2017-04-07 20:57:00 +00:00
data.minimumPasswordStrength = parseInt(meta.config.minimumPasswordStrength || 0, 10);
2016-04-30 10:47:28 +03:00
data.termsOfUse = termsOfUse.postData.content;
2017-04-07 20:57:00 +00:00
data.breadcrumbs = helpers.buildBreadcrumbs([{
text: '[[register:register]]',
}]);
2016-04-30 10:47:28 +03:00
data.regFormEntry = [];
2016-05-09 11:40:42 -04:00
data.error = req.flash('error')[0] || errorText;
2016-04-30 10:47:28 +03:00
data.title = '[[pages:register]]';
res.render('register', data);
});
2014-02-27 16:52:46 -05:00
};
Controllers.registerInterstitial = function (req, res, next) {
2016-06-08 16:05:40 -04:00
if (!req.session.hasOwnProperty('registration')) {
return res.redirect(nconf.get('relative_path') + '/register');
}
2017-02-28 16:42:10 +03:00
async.waterfall([
function (next) {
plugins.fireHook('filter:register.interstitial', {
userData: req.session.registration,
interstitials: [],
}, next);
},
function (data, next) {
if (!data.interstitials.length) {
// No interstitials, redirect to home
delete req.session.registration;
return res.redirect('/');
2016-08-16 19:46:59 +02:00
}
2017-02-28 16:42:10 +03:00
var renders = data.interstitials.map(function (interstitial) {
return async.apply(req.app.render.bind(req.app), interstitial.template, interstitial.data || {});
});
2016-08-16 19:46:59 +02:00
2017-02-28 16:42:10 +03:00
async.parallel(renders, next);
},
function (sections) {
var errors = req.flash('error');
2016-06-08 16:05:40 -04:00
res.render('registerComplete', {
2016-09-28 20:06:16 +03:00
title: '[[pages:registration-complete]]',
errors: errors,
2017-02-17 19:31:21 -07:00
sections: sections,
2016-06-08 16:05:40 -04:00
});
2017-02-28 16:42:10 +03:00
},
], next);
2016-06-08 16:05:40 -04:00
};
Controllers.compose = function (req, res, next) {
plugins.fireHook('filter:composer.build', {
req: req,
res: res,
next: next,
2017-02-17 19:31:21 -07:00
templateData: {},
}, function (err, data) {
if (err) {
return next(err);
}
2015-06-10 15:56:43 -04:00
if (data.templateData.disabled) {
2016-01-12 12:01:17 -05:00
res.render('', {
2017-02-17 19:31:21 -07:00
title: '[[modules:composer.compose]]',
2016-01-12 12:01:17 -05:00
});
} else {
2016-01-12 12:01:17 -05:00
data.templateData.title = '[[modules:composer.compose]]';
res.render('compose', data.templateData);
}
});
2015-05-21 16:24:40 -04:00
};
2014-02-27 16:52:46 -05:00
Squashed commit of the following: commit 9c86d9b2904e14927cd7e9679b92aec0951d1063 Merge: ebfa63a 5a7f811 Author: Julian Lam <julian@nodebb.org> Date: Thu Jul 20 08:41:39 2017 -0400 Merge branch 'noscript-login' of https://github.com/An-dz/NodeBB into noscript commit 5a7f81185e8f9bd7d2d011c3d495988be7e437a3 Author: André Zanghelini <an_dz@simutrans-forum> Date: Mon Jul 17 23:07:14 2017 -0300 Rename clashing variable 'next' commit ebfa63a984073a58c17aa408c363cdb03ef89985 Merge: c1801cd f159d0d Author: Julian Lam <julian@nodebb.org> Date: Mon Jul 17 16:30:40 2017 -0400 Merge branch 'noscript-logout' of https://github.com/An-dz/NodeBB into noscript commit c1801cda14e6363491e30b659902e2ae71f7e1f7 Merge: 7a5f9f3 9fd542d Author: Julian Lam <julian@nodebb.org> Date: Mon Jul 17 16:30:31 2017 -0400 Merge branch 'noscript-register' of https://github.com/An-dz/NodeBB into noscript commit 7a5f9f35abc834bb72ddddc9ca07d34f2fde8353 Merge: 44851f9 d37b95c Author: Julian Lam <julian@nodebb.org> Date: Mon Jul 17 16:30:10 2017 -0400 Merge branch 'noscript-compose' of https://github.com/An-dz/NodeBB into noscript commit f159d0d9ef1b7f600e830a96fdb4b9c87c79bb4a Author: André Zanghelini <an_dz@simutrans-forum> Date: Thu Jul 6 12:16:38 2017 -0300 Prevent form submit Required for theme change commit d37b95cb71d32d4483190609798e244c331db165 Author: André Zanghelini <an_dz@simutrans-forum> Date: Thu Jul 6 01:49:52 2017 -0300 Prevent link action with scripts Required for the theme change that changes the buttons to `a` tags. commit 9fd542d8970b7d1a4126f4edc4b44eab7d708fb0 Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 19:57:56 2017 -0300 Fix tests commit cdad5bf8c2891ad76f7441fd4d8a74b058a14e6d Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 19:09:17 2017 -0300 Update error handling commit 4ff11cd136a4fb98483f837e2cebc741380dfe76 Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 17:29:08 2017 -0300 Remove async waterfall commit df01d44e821a70c984b89e9585a325c3e02c6e37 Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 16:59:43 2017 -0300 Set noscript compose as noscript at start commit 4bcc380da72239b8315cc849a77a3036e06e4a12 Author: André Zanghelini <an_dz@simutrans-forum> Date: Wed Jul 5 16:59:12 2017 -0300 Remove last useless next commit b5eac6fea11e209934c0648a7e75ad07a2167123 Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 18:35:08 2017 -0300 Last function requires no next commit 20a5cce6e6e32a454c304c448383707ec44c75a8 Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 18:06:58 2017 -0300 Remove more useless next calls commit 85ee22a79bcbbb1995106f43d4c74d6ba9206cab Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 17:46:07 2017 -0300 Remove useless next calls commit 7d984c47ad24faac1fe537dee4a5a7d697e8634c Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 15:45:31 2017 -0300 Support old themes commit 4a09dfbd08253115c342a9e829c4e6940cecb8cc Author: André Zanghelini <an_dz@simutrans-forum> Date: Sun Jul 2 15:37:23 2017 -0300 Moved all error handling into helpers function commit 391aa6e67ef9ab67304005e14ac0633cdb630713 Author: André Zanghelini <an_dz@simutrans-forum> Date: Thu Jun 8 15:37:37 2017 -0300 ESLint - Fix mixed conditionals commit 80ccc6fd581d791f31e7ab62de8de611837bfc3c Author: André Zanghelini <an_dz@simutrans-forum> Date: Sat Jun 3 18:08:15 2017 -0300 Compose without scripts commit 2aca811256721238ca0cede4954213d369009885 Author: André Zanghelini <an_dz@simutrans-forum> Date: Sat Jun 3 18:00:44 2017 -0300 Register without scripts commit 097bb51577fb26f8e22f86dc274cb670ab606a8a Author: André Zanghelini <an_dz@simutrans-forum> Date: Sat Jun 3 16:42:15 2017 -0300 Logout without scripts commit d497e08109891079656fee1c145043a9c0e55f2e Author: André Zanghelini <an_dz@simutrans-forum> Date: Sat Jun 3 16:27:10 2017 -0300 Login without script
2017-07-20 08:51:04 -04:00
Controllers.composePost = function (req, res) {
var body = req.body;
var data = {
uid: req.uid,
req: req,
timestamp: Date.now(),
content: body.content,
};
req.body.noscript = 'true';
if (!data.content) {
return helpers.noScriptErrors(req, res, '[[error:invalid-data]]', 400);
}
if (body.tid) {
data.tid = body.tid;
topics.reply(data, function (err, result) {
if (err) {
return helpers.noScriptErrors(req, res, err.message, 400);
}
user.updateOnlineUsers(result.uid);
res.redirect(nconf.get('relative_path') + '/post/' + result.pid);
});
} else if (body.cid) {
data.cid = body.cid;
data.title = body.title;
data.tags = [];
data.thumb = '';
topics.post(data, function (err, result) {
if (err) {
return helpers.noScriptErrors(req, res, err.message, 400);
}
res.redirect(nconf.get('relative_path') + '/topic/' + result.topicData.slug);
});
}
};
Controllers.confirmEmail = function (req, res) {
2015-02-25 14:10:00 -05:00
user.email.confirm(req.params.code, function (err) {
res.render('confirm', {
2016-02-25 23:04:19 -05:00
error: err ? err.message : '',
title: '[[pages:confirm]]',
2015-02-25 14:10:00 -05:00
});
2014-02-27 17:04:41 -05:00
});
};
2014-02-27 15:06:39 -05:00
2014-02-27 17:16:06 -05:00
Controllers.robots = function (req, res) {
res.set('Content-Type', 'text/plain');
2017-07-10 14:55:57 -04:00
if (meta.config['robots:txt']) {
res.send(meta.config['robots:txt']);
2014-02-27 17:16:06 -05:00
} else {
2017-02-18 01:56:23 -07:00
res.send('User-agent: *\n' +
'Disallow: ' + nconf.get('relative_path') + '/admin/\n' +
'Sitemap: ' + nconf.get('url') + '/sitemap.xml');
2014-02-27 17:16:06 -05:00
}
};
Controllers.manifest = function (req, res) {
var manifest = {
2016-10-18 15:32:28 +03:00
name: meta.config.title || 'NodeBB',
start_url: nconf.get('relative_path') + '/',
display: 'standalone',
orientation: 'portrait',
2017-02-17 19:31:21 -07:00
icons: [],
2016-10-18 15:32:28 +03:00
};
if (meta.config['brand:touchIcon']) {
manifest.icons.push({
src: nconf.get('relative_path') + '/assets/uploads/system/touchicon-36.png',
sizes: '36x36',
type: 'image/png',
2017-02-17 19:31:21 -07:00
density: 0.75,
}, {
src: nconf.get('relative_path') + '/assets/uploads/system/touchicon-48.png',
sizes: '48x48',
type: 'image/png',
2017-02-17 19:31:21 -07:00
density: 1.0,
}, {
src: nconf.get('relative_path') + '/assets/uploads/system/touchicon-72.png',
sizes: '72x72',
type: 'image/png',
2017-02-17 19:31:21 -07:00
density: 1.5,
}, {
src: nconf.get('relative_path') + '/assets/uploads/system/touchicon-96.png',
sizes: '96x96',
type: 'image/png',
2017-02-17 19:31:21 -07:00
density: 2.0,
}, {
src: nconf.get('relative_path') + '/assets/uploads/system/touchicon-144.png',
sizes: '144x144',
type: 'image/png',
2017-02-17 19:31:21 -07:00
density: 3.0,
}, {
src: nconf.get('relative_path') + '/assets/uploads/system/touchicon-192.png',
sizes: '192x192',
type: 'image/png',
2017-02-17 19:31:21 -07:00
density: 4.0,
2016-01-06 12:49:14 +02:00
});
}
res.status(200).json(manifest);
};
2017-03-02 14:57:33 +03:00
Controllers.outgoing = function (req, res, next) {
2016-09-05 22:12:02 +03:00
var url = req.query.url || '';
2017-03-02 14:57:33 +03:00
if (!url || url.startsWith('javascript:')) {
2017-03-02 14:57:33 +03:00
return next();
}
res.render('outgoing', {
2016-09-05 22:12:02 +03:00
outgoing: validator.escape(String(url)),
2016-04-25 21:53:56 +03:00
title: meta.config.title,
2017-04-07 20:57:00 +00:00
breadcrumbs: helpers.buildBreadcrumbs([{
text: '[[notifications:outgoing_link]]',
}]),
2017-03-02 14:57:33 +03:00
});
};
Controllers.termsOfUse = function (req, res, next) {
2014-11-14 12:17:24 -05:00
if (!meta.config.termsOfUse) {
2015-08-28 14:31:35 -04:00
return next();
2014-11-14 12:17:24 -05:00
}
2017-04-07 20:57:00 +00:00
res.render('tos', {
termsOfUse: meta.config.termsOfUse,
});
2014-11-14 12:17:24 -05:00
};