Updated translation support
This commit is contained in:
parent
b1e8cd68cd
commit
d25565b6f8
114 changed files with 42095 additions and 1902 deletions
|
@ -11,6 +11,8 @@ let request = require('request');
|
|||
let router = new express.Router();
|
||||
let passport = require('../lib/passport');
|
||||
let marked = require('marked');
|
||||
let _ = require('../lib/translate')._;
|
||||
let util = require('util');
|
||||
|
||||
router.get('/:campaign/:list/:subscription', passport.csrfProtection, (req, res, next) => {
|
||||
settings.get('serviceUrl', (err, serviceUrl) => {
|
||||
|
@ -26,7 +28,7 @@ router.get('/:campaign/:list/:subscription', passport.csrfProtection, (req, res,
|
|||
}
|
||||
|
||||
if (!campaign) {
|
||||
err = new Error('Not Found');
|
||||
err = new Error(_('Not Found'));
|
||||
err.status = 404;
|
||||
return next(err);
|
||||
}
|
||||
|
@ -38,7 +40,7 @@ router.get('/:campaign/:list/:subscription', passport.csrfProtection, (req, res,
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
err = new Error('Not Found');
|
||||
err = new Error(_('Not Found'));
|
||||
err.status = 404;
|
||||
return next(err);
|
||||
}
|
||||
|
@ -50,7 +52,7 @@ router.get('/:campaign/:list/:subscription', passport.csrfProtection, (req, res,
|
|||
}
|
||||
|
||||
if (!subscription) {
|
||||
err = new Error('Not Found');
|
||||
err = new Error(_('Not Found'));
|
||||
err.status = 404;
|
||||
return next(err);
|
||||
}
|
||||
|
@ -105,7 +107,7 @@ router.get('/:campaign/:list/:subscription', passport.csrfProtection, (req, res,
|
|||
return next(err);
|
||||
}
|
||||
if (httpResponse.statusCode !== 200) {
|
||||
return next(new Error('Received status code ' + httpResponse.statusCode + ' from ' + campaign.sourceUrl));
|
||||
return next(new Error(util.format(_('Received status code %s from %s'), httpResponse.statusCode, campaign.sourceUrl)));
|
||||
}
|
||||
renderAndShow(body && body.toString(), false);
|
||||
});
|
||||
|
@ -129,7 +131,7 @@ router.post('/attachment/download', passport.parseForm, passport.csrfProtection,
|
|||
let url = '/archive/' + encodeURIComponent(req.body.campaign || '') + '/' + encodeURIComponent(req.body.list || '') + '/' + encodeURIComponent(req.body.subscription || '');
|
||||
campaigns.getByCid(req.body.campaign, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect(url);
|
||||
}
|
||||
campaigns.getAttachment(campaign.id, Number(req.body.attachment), (err, attachment) => {
|
||||
|
@ -137,7 +139,7 @@ router.post('/attachment/download', passport.parseForm, passport.csrfProtection,
|
|||
req.flash('danger', err && err.message || err);
|
||||
return res.redirect(url);
|
||||
} else if (!attachment) {
|
||||
req.flash('warning', 'Attachment not found');
|
||||
req.flash('warning', _('Attachment not found'));
|
||||
return res.redirect(url);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ let striptags = require('striptags');
|
|||
let passport = require('../lib/passport');
|
||||
let htmlescape = require('escape-html');
|
||||
let multer = require('multer');
|
||||
let _ = require('../lib/translate')._;
|
||||
let util = require('util');
|
||||
let uploadStorage = multer.memoryStorage();
|
||||
let uploads = multer({
|
||||
storage: uploadStorage
|
||||
|
@ -21,7 +23,7 @@ let uploads = multer({
|
|||
|
||||
router.all('/*', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
req.flash('danger', 'Need to be logged in to access restricted content');
|
||||
req.flash('danger', _('Need to be logged in to access restricted content'));
|
||||
return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
|
||||
}
|
||||
res.setSelectedMenu('campaigns');
|
||||
|
@ -30,7 +32,7 @@ router.all('/*', (req, res, next) => {
|
|||
|
||||
router.get('/', (req, res) => {
|
||||
res.render('campaigns/campaigns', {
|
||||
title: 'Campaigns'
|
||||
title: _('Campaigns')
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -112,13 +114,13 @@ router.get('/create', passport.csrfProtection, (req, res) => {
|
|||
router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
campaigns.create(req.body, false, (err, id) => {
|
||||
if (err || !id) {
|
||||
req.flash('danger', err && err.message || err || 'Could not create campaign');
|
||||
req.flash('danger', err && err.message || err || _('Could not create campaign'));
|
||||
return res.redirect('/campaigns/create?' + tools.queryParams(req.body));
|
||||
}
|
||||
req.flash('success', 'Campaign “' + req.body.name + '” created');
|
||||
res.redirect((req.body.type === 'rss')
|
||||
? '/campaigns/edit/' + id
|
||||
: '/campaigns/edit/' + id + '?tab=template'
|
||||
req.flash('success', util.format(_('Campaign “%s” created'), req.body.name));
|
||||
res.redirect((req.body.type === 'rss') ?
|
||||
'/campaigns/edit/' + id :
|
||||
'/campaigns/edit/' + id + '?tab=template'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -126,7 +128,7 @@ router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
router.get('/edit/:id', passport.csrfProtection, (req, res, next) => {
|
||||
campaigns.get(req.params.id, false, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
|
||||
|
@ -199,7 +201,7 @@ router.get('/edit/:id', passport.csrfProtection, (req, res, next) => {
|
|||
campaign.mergeTags = defaultMergeTags.concat(listMergeTags);
|
||||
campaign.type === 2 && campaign.mergeTags.push({
|
||||
key: 'RSS_ENTRY',
|
||||
value: 'content from an RSS entry'
|
||||
value: _('content from an RSS entry')
|
||||
});
|
||||
res.render(view, campaign);
|
||||
});
|
||||
|
@ -215,9 +217,9 @@ router.post('/edit', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
} else if (updated) {
|
||||
req.flash('success', 'Campaign settings updated');
|
||||
req.flash('success', _('Campaign settings updated'));
|
||||
} else {
|
||||
req.flash('info', 'Campaign settings not updated');
|
||||
req.flash('info', _('Campaign settings not updated'));
|
||||
}
|
||||
|
||||
if (req.body.id) {
|
||||
|
@ -233,9 +235,9 @@ router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'Campaign deleted');
|
||||
req.flash('success', _('Campaign deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete specified campaign');
|
||||
req.flash('info', _('Could not delete specified campaign'));
|
||||
}
|
||||
|
||||
return res.redirect('/campaigns');
|
||||
|
@ -254,22 +256,22 @@ router.post('/ajax', (req, res) => {
|
|||
let getStatusText = data => {
|
||||
switch (data.status) {
|
||||
case 1:
|
||||
return 'Idling';
|
||||
return _('Idling');
|
||||
case 2:
|
||||
if (data.scheduled && data.scheduled > new Date()) {
|
||||
return 'Scheduled';
|
||||
return _('Scheduled');
|
||||
}
|
||||
return '<span class="glyphicon glyphicon-refresh spinning"></span> Sending…';
|
||||
return '<span class="glyphicon glyphicon-refresh spinning"></span> ' + _('Sending') + '…';
|
||||
case 3:
|
||||
return 'Finished';
|
||||
return _('Finished');
|
||||
case 4:
|
||||
return 'Paused';
|
||||
return _('Paused');
|
||||
case 5:
|
||||
return 'Inactive';
|
||||
return _('Inactive');
|
||||
case 6:
|
||||
return 'Active';
|
||||
return _('Active');
|
||||
}
|
||||
return 'Other';
|
||||
return _('Other');
|
||||
};
|
||||
|
||||
res.json({
|
||||
|
@ -282,7 +284,7 @@ router.post('/ajax', (req, res) => {
|
|||
htmlescape(striptags(row.description) || ''),
|
||||
getStatusText(row),
|
||||
'<span class="datestring" data-date="' + row.created.toISOString() + '" title="' + row.created.toISOString() + '">' + row.created.toISOString() + '</span>'
|
||||
].concat('<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/campaigns/edit/' + row.id + '">Edit</a>'))
|
||||
].concat('<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/campaigns/edit/' + row.id + '">' + _('Edit') + '</a>'))
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -290,7 +292,7 @@ router.post('/ajax', (req, res) => {
|
|||
router.get('/view/:id', passport.csrfProtection, (req, res) => {
|
||||
campaigns.get(req.params.id, true, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
|
||||
|
@ -385,7 +387,7 @@ router.post('/preview/:id', passport.parseForm, passport.csrfProtection, (req, r
|
|||
router.get('/opened/:id', passport.csrfProtection, (req, res) => {
|
||||
campaigns.get(req.params.id, true, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
|
||||
|
@ -424,13 +426,13 @@ router.get('/status/:id/:status', passport.csrfProtection, (req, res) => {
|
|||
status = 4;
|
||||
break;
|
||||
default:
|
||||
req.flash('danger', 'Unknown status selector');
|
||||
req.flash('danger', _('Unknown status selector'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
|
||||
campaigns.get(id, true, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
|
||||
|
@ -470,7 +472,7 @@ router.get('/status/:id/:status', passport.csrfProtection, (req, res) => {
|
|||
router.get('/clicked/:id/:linkId', passport.csrfProtection, (req, res) => {
|
||||
campaigns.get(req.params.id, true, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
|
||||
|
@ -536,7 +538,7 @@ router.post('/clicked/ajax/:id/:linkId', (req, res) => {
|
|||
campaigns.get(req.params.id, true, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
return res.json({
|
||||
error: err && err.message || err || 'Campaign not found',
|
||||
error: err && err.message || err || _('Campaign not found'),
|
||||
data: []
|
||||
});
|
||||
}
|
||||
|
@ -571,7 +573,7 @@ router.post('/clicked/ajax/:id/:linkId', (req, res) => {
|
|||
htmlescape(row.lastName || ''),
|
||||
row.created && row.created.toISOString ? '<span class="datestring" data-date="' + row.created.toISOString() + '" title="' + row.created.toISOString() + '">' + row.created.toISOString() + '</span>' : 'N/A',
|
||||
row.count,
|
||||
'<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/lists/subscription/' + campaign.list + '/edit/' + row.cid + '">Edit</a>'
|
||||
'<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/lists/subscription/' + campaign.list + '/edit/' + row.cid + '">' + _('Edit') + '</a>'
|
||||
])
|
||||
});
|
||||
});
|
||||
|
@ -585,7 +587,7 @@ router.post('/status/ajax/:id/:status', (req, res) => {
|
|||
campaigns.get(req.params.id, true, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
return res.json({
|
||||
error: err && err.message || err || 'Campaign not found',
|
||||
error: err && err.message || err || _('Campaign not found'),
|
||||
data: []
|
||||
});
|
||||
}
|
||||
|
@ -621,7 +623,7 @@ router.post('/status/ajax/:id/:status', (req, res) => {
|
|||
htmlescape(row.lastName || ''),
|
||||
htmlescape(row.response || ''),
|
||||
row.updated && row.created.toISOString ? '<span class="datestring" data-date="' + row.updated.toISOString() + '" title="' + row.updated.toISOString() + '">' + row.updated.toISOString() + '</span>' : 'N/A',
|
||||
'<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/lists/subscription/' + campaign.list + '/edit/' + row.cid + '">Edit</a>'
|
||||
'<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/lists/subscription/' + campaign.list + '/edit/' + row.cid + '">' + _('Edit') + '</a>'
|
||||
])
|
||||
});
|
||||
});
|
||||
|
@ -634,9 +636,9 @@ router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'Campaign deleted');
|
||||
req.flash('success', _('Campaign deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete specified campaign');
|
||||
req.flash('info', _('Could not delete specified campaign'));
|
||||
}
|
||||
|
||||
return res.redirect('/campaigns');
|
||||
|
@ -652,9 +654,9 @@ router.post('/send', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (scheduled) {
|
||||
req.flash('success', 'Scheduled sending');
|
||||
req.flash('success', _('Scheduled sending'));
|
||||
} else {
|
||||
req.flash('info', 'Could not schedule sending');
|
||||
req.flash('info', _('Could not schedule sending'));
|
||||
}
|
||||
|
||||
return res.redirect('/campaigns/view/' + encodeURIComponent(req.body.id));
|
||||
|
@ -666,9 +668,9 @@ router.post('/resume', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (scheduled) {
|
||||
req.flash('success', 'Sending resumed');
|
||||
req.flash('success', _('Sending resumed'));
|
||||
} else {
|
||||
req.flash('info', 'Could not resume sending');
|
||||
req.flash('info', _('Could not resume sending'));
|
||||
}
|
||||
|
||||
return res.redirect('/campaigns/view/' + encodeURIComponent(req.body.id));
|
||||
|
@ -680,9 +682,9 @@ router.post('/reset', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (reset) {
|
||||
req.flash('success', 'Sending reset');
|
||||
req.flash('success', _('Sending reset'));
|
||||
} else {
|
||||
req.flash('info', 'Could not reset sending');
|
||||
req.flash('info', _('Could not reset sending'));
|
||||
}
|
||||
|
||||
return res.redirect('/campaigns/view/' + encodeURIComponent(req.body.id));
|
||||
|
@ -694,9 +696,9 @@ router.post('/pause', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (reset) {
|
||||
req.flash('success', 'Sending paused');
|
||||
req.flash('success', _('Sending paused'));
|
||||
} else {
|
||||
req.flash('info', 'Could not pause sending');
|
||||
req.flash('info', _('Could not pause sending'));
|
||||
}
|
||||
|
||||
return res.redirect('/campaigns/view/' + encodeURIComponent(req.body.id));
|
||||
|
@ -708,9 +710,9 @@ router.post('/activate', passport.parseForm, passport.csrfProtection, (req, res)
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (reset) {
|
||||
req.flash('success', 'Sending activated');
|
||||
req.flash('success', _('Sending activated'));
|
||||
} else {
|
||||
req.flash('info', 'Could not activate sending');
|
||||
req.flash('info', _('Could not activate sending'));
|
||||
}
|
||||
|
||||
return res.redirect('/campaigns/view/' + encodeURIComponent(req.body.id));
|
||||
|
@ -722,9 +724,9 @@ router.post('/inactivate', passport.parseForm, passport.csrfProtection, (req, re
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (reset) {
|
||||
req.flash('success', 'Sending paused');
|
||||
req.flash('success', _('Sending paused'));
|
||||
} else {
|
||||
req.flash('info', 'Could not pause sending');
|
||||
req.flash('info', _('Could not pause sending'));
|
||||
}
|
||||
|
||||
return res.redirect('/campaigns/view/' + encodeURIComponent(req.body.id));
|
||||
|
@ -734,7 +736,7 @@ router.post('/inactivate', passport.parseForm, passport.csrfProtection, (req, re
|
|||
router.post('/attachment', uploads.single('attachment'), passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
campaigns.get(req.body.id, false, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
campaigns.addAttachment(campaign.id, {
|
||||
|
@ -745,9 +747,9 @@ router.post('/attachment', uploads.single('attachment'), passport.parseForm, pas
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (attachmentId) {
|
||||
req.flash('success', 'Attachment uploaded');
|
||||
req.flash('success', _('Attachment uploaded'));
|
||||
} else {
|
||||
req.flash('info', 'Could not store attachment');
|
||||
req.flash('info', _('Could not store attachment'));
|
||||
}
|
||||
return res.redirect('/campaigns/edit/' + campaign.id + '?tab=attachments');
|
||||
});
|
||||
|
@ -757,16 +759,16 @@ router.post('/attachment', uploads.single('attachment'), passport.parseForm, pas
|
|||
router.post('/attachment/delete', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
campaigns.get(req.body.id, false, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
campaigns.deleteAttachment(campaign.id, Number(req.body.attachment), (err, deleted) => {
|
||||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'Attachment deleted');
|
||||
req.flash('success', _('Attachment deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete attachment');
|
||||
req.flash('info', _('Could not delete attachment'));
|
||||
}
|
||||
return res.redirect('/campaigns/edit/' + campaign.id + '?tab=attachments');
|
||||
});
|
||||
|
@ -776,7 +778,7 @@ router.post('/attachment/delete', passport.parseForm, passport.csrfProtection, (
|
|||
router.post('/attachment/download', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
campaigns.get(req.body.id, false, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
campaigns.getAttachment(campaign.id, Number(req.body.attachment), (err, attachment) => {
|
||||
|
@ -784,7 +786,7 @@ router.post('/attachment/download', passport.parseForm, passport.csrfProtection,
|
|||
req.flash('danger', err && err.message || err);
|
||||
return res.redirect('/campaigns/edit/' + campaign.id + '?tab=attachments');
|
||||
} else if (!attachment) {
|
||||
req.flash('warning', 'Attachment not found');
|
||||
req.flash('warning', _('Attachment not found'));
|
||||
return res.redirect('/campaigns/edit/' + campaign.id + '?tab=attachments');
|
||||
}
|
||||
|
||||
|
@ -798,7 +800,7 @@ router.post('/attachment/download', passport.parseForm, passport.csrfProtection,
|
|||
router.get('/attachment/:campaign', passport.csrfProtection, (req, res) => {
|
||||
campaigns.get(req.params.campaign, false, (err, campaign) => {
|
||||
if (err || !campaign) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
campaign.csrfToken = req.csrfToken();
|
||||
|
|
|
@ -6,10 +6,11 @@ let lists = require('../lib/models/lists');
|
|||
let fields = require('../lib/models/fields');
|
||||
let tools = require('../lib/tools');
|
||||
let passport = require('../lib/passport');
|
||||
let _ = require('../lib/translate')._;
|
||||
|
||||
router.all('/*', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
req.flash('danger', 'Need to be logged in to access restricted content');
|
||||
req.flash('danger', _('Need to be logged in to access restricted content'));
|
||||
return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
|
||||
}
|
||||
res.setSelectedMenu('lists');
|
||||
|
@ -24,7 +25,7 @@ router.get('/:list', (req, res) => {
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ router.get('/:list/create', passport.csrfProtection, (req, res) => {
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -98,7 +99,7 @@ router.get('/:list/create', passport.csrfProtection, (req, res) => {
|
|||
router.post('/:list/create', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
fields.create(req.params.list, req.body, (err, id) => {
|
||||
if (err || !id) {
|
||||
req.flash('danger', err && err.message || err || 'Could not create custom field');
|
||||
req.flash('danger', err && err.message || err || _('Could not create custom field'));
|
||||
return res.redirect('/fields/' + encodeURIComponent(req.params.list) + '/create?' + tools.queryParams(req.body));
|
||||
}
|
||||
req.flash('success', 'Custom field created');
|
||||
|
@ -114,7 +115,7 @@ router.get('/:list/edit/:field', passport.csrfProtection, (req, res) => {
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -125,7 +126,7 @@ router.get('/:list/edit/:field', passport.csrfProtection, (req, res) => {
|
|||
}
|
||||
|
||||
if (!field) {
|
||||
req.flash('danger', 'Selected field not found');
|
||||
req.flash('danger', _('Selected field not found'));
|
||||
return res.redirect('/fields/' + encodeURIComponent(req.params.list));
|
||||
}
|
||||
|
||||
|
@ -161,9 +162,9 @@ router.post('/:list/edit', passport.parseForm, passport.csrfProtection, (req, re
|
|||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
} else if (updated) {
|
||||
req.flash('success', 'Field settings updated');
|
||||
req.flash('success', _('Field settings updated'));
|
||||
} else {
|
||||
req.flash('info', 'Field settings not updated');
|
||||
req.flash('info', _('Field settings not updated'));
|
||||
}
|
||||
|
||||
if (req.body.id) {
|
||||
|
@ -179,9 +180,9 @@ router.post('/:list/delete', passport.parseForm, passport.csrfProtection, (req,
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'Custom field deleted');
|
||||
req.flash('success', _('Custom field deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete specified field');
|
||||
req.flash('info', _('Could not delete specified field'));
|
||||
}
|
||||
|
||||
return res.redirect('/fields/' + encodeURIComponent(req.params.list));
|
||||
|
|
|
@ -5,6 +5,7 @@ let settings = require('../lib/models/settings');
|
|||
let lists = require('../lib/models/lists');
|
||||
let subscriptions = require('../lib/models/subscriptions');
|
||||
let tools = require('../lib/tools');
|
||||
let _ = require('../lib/translate')._;
|
||||
|
||||
let log = require('npmlog');
|
||||
let express = require('express');
|
||||
|
@ -36,7 +37,7 @@ router.get('/:campaign/:list/:subscription/:link', (req, res) => {
|
|||
res.status(404);
|
||||
return res.render('archive/view', {
|
||||
layout: 'archive/layout',
|
||||
message: 'Oops, we couldn\'t find a link for the URL you clicked',
|
||||
message: _('Oops, we couldn\'t find a link for the URL you clicked'),
|
||||
campaign: {
|
||||
subject: 'Error 404'
|
||||
}
|
||||
|
|
108
routes/lists.js
108
routes/lists.js
|
@ -17,6 +17,8 @@ let humanize = require('humanize');
|
|||
let mkdirp = require('mkdirp');
|
||||
let pathlib = require('path');
|
||||
let log = require('npmlog');
|
||||
let _ = require('../lib/translate')._;
|
||||
let util = require('util');
|
||||
|
||||
let uploadStorage = multer.diskStorage({
|
||||
destination: (req, file, callback) => {
|
||||
|
@ -44,7 +46,7 @@ let moment = require('moment-timezone');
|
|||
|
||||
router.all('/*', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
req.flash('danger', 'Need to be logged in to access restricted content');
|
||||
req.flash('danger', _('Need to be logged in to access restricted content'));
|
||||
return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
|
||||
}
|
||||
res.setSelectedMenu('lists');
|
||||
|
@ -85,10 +87,10 @@ router.get('/create', passport.csrfProtection, (req, res) => {
|
|||
router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.create(req.body, (err, id) => {
|
||||
if (err || !id) {
|
||||
req.flash('danger', err && err.message || err || 'Could not create list');
|
||||
req.flash('danger', err && err.message || err || _('Could not create list'));
|
||||
return res.redirect('/lists/create?' + tools.queryParams(req.body));
|
||||
}
|
||||
req.flash('success', 'List created');
|
||||
req.flash('success', _('List created'));
|
||||
res.redirect('/lists/view/' + id);
|
||||
});
|
||||
});
|
||||
|
@ -96,7 +98,7 @@ router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
router.get('/edit/:id', passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
list.csrfToken = req.csrfToken();
|
||||
|
@ -110,9 +112,9 @@ router.post('/edit', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
} else if (updated) {
|
||||
req.flash('success', 'List settings updated');
|
||||
req.flash('success', _('List settings updated'));
|
||||
} else {
|
||||
req.flash('info', 'List settings not updated');
|
||||
req.flash('info', _('List settings not updated'));
|
||||
}
|
||||
|
||||
if (req.body.id) {
|
||||
|
@ -128,9 +130,9 @@ router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'List deleted');
|
||||
req.flash('success', _('List deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete specified list');
|
||||
req.flash('info', _('Could not delete specified list'));
|
||||
}
|
||||
|
||||
return res.redirect('/lists');
|
||||
|
@ -141,7 +143,7 @@ router.post('/ajax/:id', (req, res) => {
|
|||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
return res.json({
|
||||
error: err && err.message || err || 'List not found',
|
||||
error: err && err.message || err || _('List not found'),
|
||||
data: []
|
||||
});
|
||||
}
|
||||
|
@ -166,7 +168,7 @@ router.post('/ajax/:id', (req, res) => {
|
|||
row.customFields = fields.getRow(fieldList, row);
|
||||
});
|
||||
|
||||
let statuses = ['Unknown', 'Subscribed', 'Unsubscribed', 'Bounced', 'Complained'];
|
||||
let statuses = [_('Unknown'), _('Subscribed'), _('Unsubscribed'), _('Bounced'), _('Complained')];
|
||||
|
||||
res.json({
|
||||
draw: req.body.draw,
|
||||
|
@ -197,11 +199,11 @@ router.post('/ajax/:id', (req, res) => {
|
|||
let key = keys[i];
|
||||
switch (key.verifyPrimaryKey()) {
|
||||
case 0:
|
||||
return 'Invalid key';
|
||||
return _('Invalid key');
|
||||
case 1:
|
||||
return 'Expired key';
|
||||
return _('Expired key');
|
||||
case 2:
|
||||
return 'Revoked key';
|
||||
return _('Revoked key');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +219,7 @@ router.post('/ajax/:id', (req, res) => {
|
|||
} else {
|
||||
return htmlescape(cRow.value || '');
|
||||
}
|
||||
})).concat(statuses[row.status]).concat(row.created && row.created.toISOString ? '<span class="datestring" data-date="' + row.created.toISOString() + '" title="' + row.created.toISOString() + '">' + row.created.toISOString() + '</span>' : 'N/A').concat('<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/lists/subscription/' + list.id + '/edit/' + row.cid + '">Edit</a>'))
|
||||
})).concat(statuses[row.status]).concat(row.created && row.created.toISOString ? '<span class="datestring" data-date="' + row.created.toISOString() + '" title="' + row.created.toISOString() + '">' + row.created.toISOString() + '</span>' : 'N/A').concat('<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/lists/subscription/' + list.id + '/edit/' + row.cid + '">' + _('Edit') + '</a>'))
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -231,7 +233,7 @@ router.get('/view/:id', passport.csrfProtection, (req, res) => {
|
|||
|
||||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
|
@ -248,22 +250,22 @@ router.get('/view/:id', passport.csrfProtection, (req, res) => {
|
|||
|
||||
list.imports = imports.map((entry, i) => {
|
||||
entry.index = i + 1;
|
||||
entry.importType = entry.type === 1 ? 'Subscribe' : 'Unsubscribe';
|
||||
entry.importType = entry.type === 1 ? _('Subscribe') : _('Unsubscribe');
|
||||
switch (entry.status) {
|
||||
case 0:
|
||||
entry.importStatus = 'Initializing';
|
||||
entry.importStatus = _('Initializing');
|
||||
break;
|
||||
case 1:
|
||||
entry.importStatus = 'Initialized';
|
||||
entry.importStatus = _('Initialized');
|
||||
break;
|
||||
case 2:
|
||||
entry.importStatus = 'Importing...';
|
||||
entry.importStatus = _('Importing') + '…';
|
||||
break;
|
||||
case 3:
|
||||
entry.importStatus = 'Finished';
|
||||
entry.importStatus = _('Finished');
|
||||
break;
|
||||
default:
|
||||
entry.importStatus = 'Errored' + (entry.error ? ' (' + entry.error + ')' : '');
|
||||
entry.importStatus = _('Errored') + (entry.error ? ' (' + entry.error + ')' : '');
|
||||
entry.error = true;
|
||||
}
|
||||
entry.created = entry.created && entry.created.toISOString();
|
||||
|
@ -296,7 +298,7 @@ router.get('/view/:id', passport.csrfProtection, (req, res) => {
|
|||
router.get('/subscription/:id/add', passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
|
@ -335,13 +337,13 @@ router.get('/subscription/:id/add', passport.csrfProtection, (req, res) => {
|
|||
router.get('/subscription/:id/edit/:cid', passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
subscriptions.get(list.id, req.params.cid, (err, subscription) => {
|
||||
if (err || !subscription) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find subscriber with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find subscriber with specified ID'));
|
||||
return res.redirect('/lists/view/' + req.params.id);
|
||||
}
|
||||
|
||||
|
@ -387,14 +389,14 @@ router.get('/subscription/:id/edit/:cid', passport.csrfProtection, (req, res) =>
|
|||
router.post('/subscription/add', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
subscriptions.insert(req.body.list, false, req.body, (err, response) => {
|
||||
if (err) {
|
||||
req.flash('danger', err && err.message || err || 'Could not add subscription');
|
||||
req.flash('danger', err && err.message || err || _('Could not add subscription'));
|
||||
return res.redirect('/lists/subscription/' + encodeURIComponent(req.body.list) + '/add?' + tools.queryParams(req.body));
|
||||
}
|
||||
|
||||
if (response.entryId) {
|
||||
req.flash('success', req.body.email + ' was successfully added to your list');
|
||||
req.flash('success', util.format(_('%s was successfully added to your list'), req.body.email));
|
||||
} else {
|
||||
req.flash('warning', req.body.email + ' was not added to your list');
|
||||
req.flash('warning', util.format(_('%s was not added to your list'), req.body.email));
|
||||
}
|
||||
|
||||
res.redirect('/lists/subscription/' + encodeURIComponent(req.body.list) + '/add');
|
||||
|
@ -404,22 +406,22 @@ router.post('/subscription/add', passport.parseForm, passport.csrfProtection, (r
|
|||
router.post('/subscription/unsubscribe', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.body.list, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
subscriptions.get(list.id, req.body.cid, (err, subscription) => {
|
||||
if (err || !subscription) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find subscriber with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find subscriber with specified ID'));
|
||||
return res.redirect('/lists/view/' + list.id);
|
||||
}
|
||||
|
||||
subscriptions.unsubscribe(list.id, subscription.email, false, err => {
|
||||
if (err) {
|
||||
req.flash('danger', err && err.message || err || 'Could not unsubscribe user');
|
||||
req.flash('danger', err && err.message || err || _('Could not unsubscribe user'));
|
||||
return res.redirect('/lists/subscription/' + list.id + '/edit/' + subscription.cid);
|
||||
}
|
||||
req.flash('success', subscription.email + ' was successfully unsubscribed from your list');
|
||||
req.flash('success', util.format(_('%s was successfully unsubscribed from your list'), subscription.email));
|
||||
res.redirect('/lists/view/' + list.id);
|
||||
});
|
||||
});
|
||||
|
@ -429,17 +431,17 @@ router.post('/subscription/unsubscribe', passport.parseForm, passport.csrfProtec
|
|||
router.post('/subscription/delete', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.body.list, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
subscriptions.delete(list.id, req.body.cid, (err, email) => {
|
||||
if (err || !email) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find subscriber with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find subscriber with specified ID'));
|
||||
return res.redirect('/lists/view/' + list.id);
|
||||
}
|
||||
|
||||
req.flash('success', email + ' was successfully removed from your list');
|
||||
req.flash('success', util.format(_('%s was successfully removed from your list'), email));
|
||||
res.redirect('/lists/view/' + list.id);
|
||||
});
|
||||
});
|
||||
|
@ -451,16 +453,16 @@ router.post('/subscription/edit', passport.parseForm, passport.csrfProtection, (
|
|||
|
||||
if (err) {
|
||||
if (err.code === 'ER_DUP_ENTRY') {
|
||||
req.flash('danger', 'Another subscriber with email address ' + req.body.email + ' already exists');
|
||||
req.flash('danger', util.format(_('Another subscriber with email address %s already exists'), req.body.email));
|
||||
return res.redirect('/lists/subscription/' + encodeURIComponent(req.body.list) + '/edit/' + req.body.cid);
|
||||
} else {
|
||||
req.flash('danger', err.message || err);
|
||||
}
|
||||
|
||||
} else if (updated) {
|
||||
req.flash('success', 'Subscription settings updated');
|
||||
req.flash('success', _('Subscription settings updated'));
|
||||
} else {
|
||||
req.flash('info', 'Subscription settings not updated');
|
||||
req.flash('info', _('Subscription settings not updated'));
|
||||
}
|
||||
|
||||
if (req.body.list) {
|
||||
|
@ -474,7 +476,7 @@ router.post('/subscription/edit', passport.parseForm, passport.csrfProtection, (
|
|||
router.get('/subscription/:id/import', passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
|
@ -496,13 +498,13 @@ router.get('/subscription/:id/import', passport.csrfProtection, (req, res) => {
|
|||
router.get('/subscription/:id/import/:importId', passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
subscriptions.getImport(req.params.id, req.params.importId, (err, data) => {
|
||||
if (err || !data) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find import data with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find import data with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
|
@ -525,7 +527,7 @@ router.get('/subscription/:id/import/:importId', passport.csrfProtection, (req,
|
|||
router.post('/subscription/import', uploads.single('listimport'), passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.body.list, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
|
@ -533,7 +535,7 @@ router.post('/subscription/import', uploads.single('listimport'), passport.parse
|
|||
|
||||
getPreview(req.file.path, req.file.size, delimiter, (err, rows) => {
|
||||
if (err) {
|
||||
req.flash('danger', err && err.message || err || 'Could not process CSV');
|
||||
req.flash('danger', err && err.message || err || _('Could not process CSV'));
|
||||
return res.redirect('/lists');
|
||||
} else {
|
||||
|
||||
|
@ -542,7 +544,7 @@ router.post('/subscription/import', uploads.single('listimport'), passport.parse
|
|||
example: rows[1] || []
|
||||
}, (err, importId) => {
|
||||
if (err) {
|
||||
req.flash('danger', err && err.message || err || 'Could not create importer');
|
||||
req.flash('danger', err && err.message || err || _('Could not create importer'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
|
@ -593,7 +595,7 @@ function getPreview(path, size, delimiter, callback) {
|
|||
// just ignore
|
||||
});
|
||||
if (!data || !data.length) {
|
||||
return callback(null, new Error('Empty file'));
|
||||
return callback(null, new Error(_('Empty file')));
|
||||
}
|
||||
callback(err, data);
|
||||
});
|
||||
|
@ -604,13 +606,13 @@ function getPreview(path, size, delimiter, callback) {
|
|||
router.post('/subscription/import-confirm', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.body.list, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
subscriptions.getImport(list.id, req.body.import, (err, data) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find import data with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find import data with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
|
@ -646,11 +648,11 @@ router.post('/subscription/import-confirm', passport.parseForm, passport.csrfPro
|
|||
mapping: JSON.stringify(data.mapping)
|
||||
}, (err, importer) => {
|
||||
if (err || !importer) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find import data with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find import data with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
req.flash('success', 'Import started');
|
||||
req.flash('success', _('Import started'));
|
||||
res.redirect('/lists/view/' + list.id + '?tab=imports');
|
||||
});
|
||||
});
|
||||
|
@ -661,7 +663,7 @@ router.post('/subscription/import-confirm', passport.parseForm, passport.csrfPro
|
|||
router.post('/subscription/import-restart', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.body.list, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
|
@ -674,11 +676,11 @@ router.post('/subscription/import-restart', passport.parseForm, passport.csrfPro
|
|||
failed: 0
|
||||
}, (err, importer) => {
|
||||
if (err || !importer) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find import data with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find import data with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
req.flash('success', 'Import restarted');
|
||||
req.flash('success', _('Import restarted'));
|
||||
res.redirect('/lists/view/' + list.id + '?tab=imports');
|
||||
});
|
||||
});
|
||||
|
@ -688,13 +690,13 @@ router.get('/subscription/:id/import/:importId/failed', (req, res) => {
|
|||
let start = 0;
|
||||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find list with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find list with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
|
||||
subscriptions.getImport(req.params.id, req.params.importId, (err, data) => {
|
||||
if (err || !data) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find import data with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find import data with specified ID'));
|
||||
return res.redirect('/lists');
|
||||
}
|
||||
subscriptions.getFailedImports(req.params.importId, (err, rows) => {
|
||||
|
|
|
@ -6,10 +6,11 @@ let passport = require('../lib/passport');
|
|||
let lists = require('../lib/models/lists');
|
||||
let segments = require('../lib/models/segments');
|
||||
let tools = require('../lib/tools');
|
||||
let _ = require('../lib/translate')._;
|
||||
|
||||
router.all('/*', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
req.flash('danger', 'Need to be logged in to access restricted content');
|
||||
req.flash('danger', _('Need to be logged in to access restricted content'));
|
||||
return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
|
||||
}
|
||||
res.setSelectedMenu('lists');
|
||||
|
@ -24,7 +25,7 @@ router.get('/:list', (req, res) => {
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -55,7 +56,7 @@ router.get('/:list/create', passport.csrfProtection, (req, res) => {
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -82,10 +83,10 @@ router.get('/:list/create', passport.csrfProtection, (req, res) => {
|
|||
router.post('/:list/create', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
segments.create(req.params.list, req.body, (err, id) => {
|
||||
if (err || !id) {
|
||||
req.flash('danger', err && err.message || err || 'Could not create segment');
|
||||
req.flash('danger', err && err.message || err || _('Could not create segment'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list) + '/create?' + tools.queryParams(req.body));
|
||||
}
|
||||
req.flash('success', 'Segment created');
|
||||
req.flash('success', _('Segment created'));
|
||||
res.redirect('/segments/' + encodeURIComponent(req.params.list) + '/view/' + id);
|
||||
});
|
||||
});
|
||||
|
@ -98,7 +99,7 @@ router.get('/:list/view/:id', (req, res) => {
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -109,7 +110,7 @@ router.get('/:list/view/:id', (req, res) => {
|
|||
}
|
||||
|
||||
if (!segment) {
|
||||
req.flash('danger', 'Selected segment ID not found');
|
||||
req.flash('danger', _('Selected segment ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -147,7 +148,7 @@ router.get('/:list/edit/:segment', passport.csrfProtection, (req, res) => {
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -184,9 +185,9 @@ router.post('/:list/edit', passport.parseForm, passport.csrfProtection, (req, re
|
|||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
} else if (updated) {
|
||||
req.flash('success', 'Segment settings updated');
|
||||
req.flash('success', _('Segment settings updated'));
|
||||
} else {
|
||||
req.flash('info', 'Segment settings not updated');
|
||||
req.flash('info', _('Segment settings not updated'));
|
||||
}
|
||||
|
||||
if (req.body.id) {
|
||||
|
@ -202,9 +203,9 @@ router.post('/:list/delete', passport.parseForm, passport.csrfProtection, (req,
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'Segment deleted');
|
||||
req.flash('success', _('Segment deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete specified segment');
|
||||
req.flash('info', _('Could not delete specified segment'));
|
||||
}
|
||||
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list));
|
||||
|
@ -219,7 +220,7 @@ router.get('/:list/rules/:segment/create', passport.csrfProtection, (req, res) =
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -251,7 +252,7 @@ router.post('/:list/rules/:segment/next', passport.parseForm, passport.csrfProte
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -262,13 +263,13 @@ router.post('/:list/rules/:segment/next', passport.parseForm, passport.csrfProte
|
|||
}
|
||||
|
||||
if (!segment) {
|
||||
req.flash('danger', 'Selected segment not found');
|
||||
req.flash('danger', _('Selected segment not found'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list));
|
||||
}
|
||||
|
||||
let column = segment.columns.filter(column => column.column === req.body.column).pop();
|
||||
if (!column) {
|
||||
req.flash('danger', 'Invalid rule type');
|
||||
req.flash('danger', _('Invalid rule type'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list) + '/rules/' + segment.id + '/create?' + tools.queryParams(req.body));
|
||||
}
|
||||
|
||||
|
@ -285,7 +286,7 @@ router.get('/:list/rules/:segment/configure', passport.csrfProtection, (req, res
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -296,13 +297,13 @@ router.get('/:list/rules/:segment/configure', passport.csrfProtection, (req, res
|
|||
}
|
||||
|
||||
if (!segment) {
|
||||
req.flash('danger', 'Selected segment not found');
|
||||
req.flash('danger', _('Selected segment not found'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list));
|
||||
}
|
||||
|
||||
let column = segment.columns.filter(column => column.column === req.query.column).pop();
|
||||
if (!column) {
|
||||
req.flash('danger', 'Invalid rule type');
|
||||
req.flash('danger', _('Invalid rule type'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list) + '/rules/' + segment.id + '/create?' + tools.queryParams(req.body));
|
||||
}
|
||||
|
||||
|
@ -332,16 +333,16 @@ router.post('/:list/rules/:segment/create', passport.parseForm, passport.csrfPro
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
segments.createRule(req.params.segment, req.body, (err, id) => {
|
||||
if (err || !id) {
|
||||
req.flash('danger', err && err.message || err || 'Could not create rule');
|
||||
req.flash('danger', err && err.message || err || _('Could not create rule'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list) + '/rules/' + encodeURIComponent(req.params.segment) + '/configure?' + tools.queryParams(req.body));
|
||||
}
|
||||
req.flash('success', 'Rule created');
|
||||
req.flash('success', _('Rule created'));
|
||||
res.redirect('/segments/' + encodeURIComponent(req.params.list) + '/view/' + encodeURIComponent(req.params.segment));
|
||||
});
|
||||
});
|
||||
|
@ -355,7 +356,7 @@ router.get('/:list/rules/:segment/edit/:rule', passport.csrfProtection, (req, re
|
|||
}
|
||||
|
||||
if (!list) {
|
||||
req.flash('danger', 'Selected list ID not found');
|
||||
req.flash('danger', _('Selected list ID not found'));
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
|
@ -366,7 +367,7 @@ router.get('/:list/rules/:segment/edit/:rule', passport.csrfProtection, (req, re
|
|||
}
|
||||
|
||||
if (!segment) {
|
||||
req.flash('danger', 'Selected segment not found');
|
||||
req.flash('danger', _('Selected segment not found'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list));
|
||||
}
|
||||
|
||||
|
@ -377,13 +378,13 @@ router.get('/:list/rules/:segment/edit/:rule', passport.csrfProtection, (req, re
|
|||
}
|
||||
|
||||
if (!segment) {
|
||||
req.flash('danger', 'Selected segment not found');
|
||||
req.flash('danger', _('Selected segment not found'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list));
|
||||
}
|
||||
|
||||
let column = segment.columns.filter(column => column.column === rule.column).pop();
|
||||
if (!column) {
|
||||
req.flash('danger', 'Invalid rule type');
|
||||
req.flash('danger', _('Invalid rule type'));
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list) + '/view/' + segment.id);
|
||||
}
|
||||
|
||||
|
@ -406,9 +407,9 @@ router.post('/:list/rules/:segment/edit', passport.parseForm, passport.csrfProte
|
|||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
} else if (updated) {
|
||||
req.flash('success', 'Rule settings updated');
|
||||
req.flash('success', _('Rule settings updated'));
|
||||
} else {
|
||||
req.flash('info', 'Rule settings not updated');
|
||||
req.flash('info', _('Rule settings not updated'));
|
||||
}
|
||||
|
||||
if (req.params.segment) {
|
||||
|
@ -424,9 +425,9 @@ router.post('/:list/rules/:segment/delete', passport.parseForm, passport.csrfPro
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'Rule deleted');
|
||||
req.flash('success', _('Rule deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete specified rule');
|
||||
req.flash('info', _('Could not delete specified rule'));
|
||||
}
|
||||
|
||||
return res.redirect('/segments/' + encodeURIComponent(req.params.list) + '/view/' + encodeURIComponent(req.params.segment));
|
||||
|
|
|
@ -13,11 +13,13 @@ let fields = require('../lib/models/fields');
|
|||
let subscriptions = require('../lib/models/subscriptions');
|
||||
let settings = require('../lib/models/settings');
|
||||
let openpgp = require('openpgp');
|
||||
let _ = require('../lib/translate')._;
|
||||
let util = require('util');
|
||||
|
||||
router.get('/subscribe/:cid', (req, res, next) => {
|
||||
subscriptions.subscribe(req.params.cid, req.ip, (err, subscription) => {
|
||||
if (!err && !subscription) {
|
||||
err = new Error('Selected subscription not found');
|
||||
err = new Error(_('Selected subscription not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -27,7 +29,7 @@ router.get('/subscribe/:cid', (req, res, next) => {
|
|||
|
||||
lists.get(subscription.list, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -73,7 +75,7 @@ router.get('/subscribe/:cid', (req, res, next) => {
|
|||
name: [].concat(subscription.firstName || []).concat(subscription.lastName || []).join(' '),
|
||||
address: subscription.email
|
||||
},
|
||||
subject: list.name + ': Subscription Confirmed',
|
||||
subject: util.format(_('%s: Subscription Confirmed'), list.name),
|
||||
encryptionKeys
|
||||
}, {
|
||||
html: 'emails/subscription-confirmed-html.hbs',
|
||||
|
@ -98,7 +100,7 @@ router.get('/subscribe/:cid', (req, res, next) => {
|
|||
router.get('/:cid', passport.csrfProtection, (req, res, next) => {
|
||||
lists.getByCid(req.params.cid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -136,7 +138,7 @@ router.get('/:cid', passport.csrfProtection, (req, res, next) => {
|
|||
router.get('/:cid/confirm-notice', (req, res, next) => {
|
||||
lists.getByCid(req.params.cid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -161,7 +163,7 @@ router.get('/:cid/confirm-notice', (req, res, next) => {
|
|||
router.get('/:cid/updated-notice', (req, res, next) => {
|
||||
lists.getByCid(req.params.cid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -186,7 +188,7 @@ router.get('/:cid/updated-notice', (req, res, next) => {
|
|||
router.get('/:cid/unsubscribe-notice', (req, res, next) => {
|
||||
lists.getByCid(req.params.cid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -212,7 +214,7 @@ router.post('/:cid/subscribe', passport.parseForm, passport.csrfProtection, (req
|
|||
let email = (req.body.email || '').toString().trim();
|
||||
|
||||
if (!email) {
|
||||
req.flash('danger', 'Email address not set');
|
||||
req.flash('danger', _('Email address not set'));
|
||||
return res.redirect('/subscription/' + encodeURIComponent(req.params.cid) + '?' + tools.queryParams(req.body));
|
||||
}
|
||||
|
||||
|
@ -227,7 +229,7 @@ router.post('/:cid/subscribe', passport.parseForm, passport.csrfProtection, (req
|
|||
|
||||
lists.getByCid(req.params.cid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -250,7 +252,7 @@ router.post('/:cid/subscribe', passport.parseForm, passport.csrfProtection, (req
|
|||
|
||||
subscriptions.addConfirmation(list, email, req.ip, data, (err, confirmCid) => {
|
||||
if (!err && !confirmCid) {
|
||||
err = new Error('Could not store confirmation data');
|
||||
err = new Error(_('Could not store confirmation data'));
|
||||
}
|
||||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
|
@ -265,7 +267,7 @@ router.post('/:cid/subscribe', passport.parseForm, passport.csrfProtection, (req
|
|||
router.get('/:lcid/manage/:ucid', passport.csrfProtection, (req, res, next) => {
|
||||
lists.getByCid(req.params.lcid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -279,7 +281,7 @@ router.get('/:lcid/manage/:ucid', passport.csrfProtection, (req, res, next) => {
|
|||
}
|
||||
subscriptions.get(list.id, req.params.ucid, (err, subscription) => {
|
||||
if (!err && !subscription) {
|
||||
err = new Error('Subscription not found from this list');
|
||||
err = new Error(_('Subscription not found from this list'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -312,7 +314,7 @@ router.get('/:lcid/manage/:ucid', passport.csrfProtection, (req, res, next) => {
|
|||
router.post('/:lcid/manage', passport.parseForm, passport.csrfProtection, (req, res, next) => {
|
||||
lists.getByCid(req.params.lcid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -334,7 +336,7 @@ router.post('/:lcid/manage', passport.parseForm, passport.csrfProtection, (req,
|
|||
router.get('/:lcid/manage-address/:ucid', passport.csrfProtection, (req, res, next) => {
|
||||
lists.getByCid(req.params.lcid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -344,7 +346,7 @@ router.get('/:lcid/manage-address/:ucid', passport.csrfProtection, (req, res, ne
|
|||
|
||||
subscriptions.get(list.id, req.params.ucid, (err, subscription) => {
|
||||
if (!err && !subscription) {
|
||||
err = new Error('Subscription not found from this list');
|
||||
err = new Error(_('Subscription not found from this list'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -363,7 +365,7 @@ router.get('/:lcid/manage-address/:ucid', passport.csrfProtection, (req, res, ne
|
|||
router.post('/:lcid/manage-address', passport.parseForm, passport.csrfProtection, (req, res, next) => {
|
||||
lists.getByCid(req.params.lcid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -378,7 +380,7 @@ router.post('/:lcid/manage-address', passport.parseForm, passport.csrfProtection
|
|||
return res.redirect('/subscription/' + encodeURIComponent(req.params.lcid) + '/manage-address/' + encodeURIComponent(req.body.cid) + '?' + tools.queryParams(req.body));
|
||||
}
|
||||
|
||||
req.flash('info', 'Email address updated, check your mailbox for verification instructions');
|
||||
req.flash('info', _('Email address updated, check your mailbox for verification instructions'));
|
||||
res.redirect('/subscription/' + req.params.lcid + '/manage/' + req.body.cid);
|
||||
});
|
||||
});
|
||||
|
@ -387,7 +389,7 @@ router.post('/:lcid/manage-address', passport.parseForm, passport.csrfProtection
|
|||
router.get('/:lcid/unsubscribe/:ucid', passport.csrfProtection, (req, res, next) => {
|
||||
lists.getByCid(req.params.lcid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -397,7 +399,7 @@ router.get('/:lcid/unsubscribe/:ucid', passport.csrfProtection, (req, res, next)
|
|||
|
||||
subscriptions.get(list.id, req.params.ucid, (err, subscription) => {
|
||||
if (!err && !subscription) {
|
||||
err = new Error('Subscription not found from this list');
|
||||
err = new Error(_('Subscription not found from this list'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -419,7 +421,7 @@ router.get('/:lcid/unsubscribe/:ucid', passport.csrfProtection, (req, res, next)
|
|||
router.post('/:lcid/unsubscribe', passport.parseForm, passport.csrfProtection, (req, res, next) => {
|
||||
lists.getByCid(req.params.lcid, (err, list) => {
|
||||
if (!err && !list) {
|
||||
err = new Error('Selected list not found');
|
||||
err = new Error(_('Selected list not found'));
|
||||
err.status = 404;
|
||||
}
|
||||
|
||||
|
@ -467,7 +469,7 @@ router.post('/:lcid/unsubscribe', passport.parseForm, passport.csrfProtection, (
|
|||
name: [].concat(subscription.firstName || []).concat(subscription.lastName || []).join(' '),
|
||||
address: subscription.email
|
||||
},
|
||||
subject: list.name + ': Subscription Confirmed',
|
||||
subject: util.format(_('%s: Subscription Confirmed'), list.name),
|
||||
encryptionKeys
|
||||
}, {
|
||||
html: 'emails/unsubscribe-confirmed-html.hbs',
|
||||
|
@ -494,7 +496,7 @@ router.post('/publickey', passport.parseForm, passport.csrfProtection, (req, res
|
|||
return next(err);
|
||||
}
|
||||
if (!configItems.pgpPrivateKey) {
|
||||
err = new Error('Public key is not set');
|
||||
err = new Error(_('Public key is not set'));
|
||||
err.status = 404;
|
||||
return next(err);
|
||||
}
|
||||
|
@ -510,7 +512,7 @@ router.post('/publickey', passport.parseForm, passport.csrfProtection, (req, res
|
|||
}
|
||||
|
||||
if (!privKey) {
|
||||
err = new Error('Public key is not set');
|
||||
err = new Error(_('Public key is not set'));
|
||||
err.status = 404;
|
||||
return next(err);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,11 @@ let helpers = require('../lib/helpers');
|
|||
let striptags = require('striptags');
|
||||
let passport = require('../lib/passport');
|
||||
let mailer = require('../lib/mailer');
|
||||
let _ = require('../lib/translate')._;
|
||||
|
||||
router.all('/*', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
req.flash('danger', 'Need to be logged in to access restricted content');
|
||||
req.flash('danger', _('Need to be logged in to access restricted content'));
|
||||
return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
|
||||
}
|
||||
res.setSelectedMenu('templates');
|
||||
|
@ -68,19 +69,19 @@ router.get('/create', passport.csrfProtection, (req, res, next) => {
|
|||
data.text = data.text || rendererText(configItems);
|
||||
data.disableWysiwyg = configItems.disableWysiwyg;
|
||||
|
||||
data.editors = config.editors || [['summernote', 'Summernote']];
|
||||
data.editors = config.editors || [
|
||||
['summernote', 'Summernote']
|
||||
];
|
||||
data.editors = data.editors.map(ed => {
|
||||
let editor = {
|
||||
name: ed[0],
|
||||
label: ed[1],
|
||||
label: ed[1]
|
||||
};
|
||||
if (config[editor.name] && config[editor.name].templates) {
|
||||
editor.templates = config[editor.name].templates.map(tmpl => {
|
||||
return {
|
||||
name: tmpl[0],
|
||||
label: tmpl[1],
|
||||
}
|
||||
});
|
||||
editor.templates = config[editor.name].templates.map(tmpl => ({
|
||||
name: tmpl[0],
|
||||
label: tmpl[1]
|
||||
}));
|
||||
}
|
||||
return editor;
|
||||
});
|
||||
|
@ -94,10 +95,10 @@ router.get('/create', passport.csrfProtection, (req, res, next) => {
|
|||
router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
templates.create(req.body, (err, id) => {
|
||||
if (err || !id) {
|
||||
req.flash('danger', err && err.message || err || 'Could not create template');
|
||||
req.flash('danger', err && err.message || err || _('Could not create template'));
|
||||
return res.redirect('/templates/create?' + tools.queryParams(req.body));
|
||||
}
|
||||
req.flash('success', 'Template created');
|
||||
req.flash('success', _('Template created'));
|
||||
res.redirect('/templates/edit/' + id);
|
||||
});
|
||||
});
|
||||
|
@ -105,7 +106,7 @@ router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
router.get('/edit/:id', passport.csrfProtection, (req, res, next) => {
|
||||
templates.get(req.params.id, (err, template) => {
|
||||
if (err || !template) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find template with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find template with specified ID'));
|
||||
return res.redirect('/templates');
|
||||
}
|
||||
settings.list(['disableWysiwyg'], (err, configItems) => {
|
||||
|
@ -136,9 +137,9 @@ router.post('/edit', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
} else if (updated) {
|
||||
req.flash('success', 'Template settings updated');
|
||||
req.flash('success', _('Template settings updated'));
|
||||
} else {
|
||||
req.flash('info', 'Template settings not updated');
|
||||
req.flash('info', _('Template settings not updated'));
|
||||
}
|
||||
|
||||
if (req.body.id) {
|
||||
|
@ -154,9 +155,9 @@ router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'Template deleted');
|
||||
req.flash('success', _('Template deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete specified template');
|
||||
req.flash('info', _('Could not delete specified template'));
|
||||
}
|
||||
|
||||
return res.redirect('/templates');
|
||||
|
|
|
@ -10,10 +10,12 @@ let striptags = require('striptags');
|
|||
let passport = require('../lib/passport');
|
||||
let tools = require('../lib/tools');
|
||||
let htmlescape = require('escape-html');
|
||||
let _ = require('../lib/translate')._;
|
||||
let util = require('util');
|
||||
|
||||
router.all('/*', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
req.flash('danger', 'Need to be logged in to access restricted content');
|
||||
req.flash('danger', _('Need to be logged in to access restricted content'));
|
||||
return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
|
||||
}
|
||||
res.setSelectedMenu('triggers');
|
||||
|
@ -57,7 +59,7 @@ router.get('/create-select', passport.csrfProtection, (req, res, next) => {
|
|||
|
||||
router.post('/create-select', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
if (!req.body.list) {
|
||||
req.flash('danger', 'Could not find selected list');
|
||||
req.flash('danger', _('Could not find selected list'));
|
||||
return res.redirect('/triggers/create-select');
|
||||
}
|
||||
res.redirect('/triggers/' + encodeURIComponent(req.body.list) + '/create');
|
||||
|
@ -74,7 +76,7 @@ router.get('/:listId/create', passport.csrfProtection, (req, res, next) => {
|
|||
|
||||
lists.get(req.params.listId, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find selected list');
|
||||
req.flash('danger', err && err.message || err || _('Could not find selected list'));
|
||||
return res.redirect('/triggers/create-select');
|
||||
}
|
||||
fields.list(list.id, (err, fieldList) => {
|
||||
|
@ -126,14 +128,14 @@ router.get('/:listId/create', passport.csrfProtection, (req, res, next) => {
|
|||
router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
triggers.create(req.body, (err, id) => {
|
||||
if (err || !id) {
|
||||
req.flash('danger', err && err.message || err || 'Could not create trigger');
|
||||
req.flash('danger', err && err.message || err || _('Could not create trigger'));
|
||||
if (req.body.list) {
|
||||
return res.redirect('/triggers/' + encodeURIComponent(req.body.list) + '/create?' + tools.queryParams(req.body));
|
||||
} else {
|
||||
return res.redirect('/triggers');
|
||||
}
|
||||
}
|
||||
req.flash('success', 'Trigger “' + req.body.name + '” created');
|
||||
req.flash('success', util.format(_('Trigger “%s” created'), req.body.name));
|
||||
res.redirect('/triggers');
|
||||
});
|
||||
});
|
||||
|
@ -141,7 +143,7 @@ router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
router.get('/edit/:id', passport.csrfProtection, (req, res, next) => {
|
||||
triggers.get(req.params.id, (err, trigger) => {
|
||||
if (err || !trigger) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find campaign with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find campaign with specified ID'));
|
||||
return res.redirect('/campaigns');
|
||||
}
|
||||
trigger.csrfToken = req.csrfToken();
|
||||
|
@ -149,7 +151,7 @@ router.get('/edit/:id', passport.csrfProtection, (req, res, next) => {
|
|||
|
||||
lists.get(trigger.list, (err, list) => {
|
||||
if (err || !list) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find selected list');
|
||||
req.flash('danger', err && err.message || err || _('Could not find selected list'));
|
||||
return res.redirect('/triggers');
|
||||
}
|
||||
fields.list(list.id, (err, fieldList) => {
|
||||
|
@ -209,9 +211,9 @@ router.post('/edit', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
req.flash('danger', err.message || err);
|
||||
return res.redirect('/triggers/edit/' + encodeURIComponent(req.body.id));
|
||||
} else if (updated) {
|
||||
req.flash('success', 'Trigger settings updated');
|
||||
req.flash('success', _('Trigger settings updated'));
|
||||
} else {
|
||||
req.flash('info', 'Trigger settings not updated');
|
||||
req.flash('info', _('Trigger settings not updated'));
|
||||
}
|
||||
|
||||
return res.redirect('/triggers');
|
||||
|
@ -223,9 +225,9 @@ router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
if (err) {
|
||||
req.flash('danger', err && err.message || err);
|
||||
} else if (deleted) {
|
||||
req.flash('success', 'Trigger deleted');
|
||||
req.flash('success', _('Trigger deleted'));
|
||||
} else {
|
||||
req.flash('info', 'Could not delete specified trigger');
|
||||
req.flash('info', _('Could not delete specified trigger'));
|
||||
}
|
||||
|
||||
return res.redirect('/triggers');
|
||||
|
@ -237,7 +239,7 @@ router.get('/status/:id', passport.csrfProtection, (req, res) => {
|
|||
|
||||
triggers.get(id, (err, trigger) => {
|
||||
if (err || !trigger) {
|
||||
req.flash('danger', err && err.message || err || 'Could not find trigger with specified ID');
|
||||
req.flash('danger', err && err.message || err || _('Could not find trigger with specified ID'));
|
||||
return res.redirect('/triggers');
|
||||
}
|
||||
|
||||
|
@ -250,7 +252,7 @@ router.post('/status/ajax/:id', (req, res) => {
|
|||
triggers.get(req.params.id, (err, trigger) => {
|
||||
if (err || !trigger) {
|
||||
return res.json({
|
||||
error: err && err.message || err || 'Trigger not found',
|
||||
error: err && err.message || err || _('Trigger not found'),
|
||||
data: []
|
||||
});
|
||||
}
|
||||
|
@ -292,7 +294,7 @@ router.post('/status/ajax/:id', (req, res) => {
|
|||
htmlescape(row.firstName || ''),
|
||||
htmlescape(row.lastName || ''),
|
||||
'<span class="datestring" data-date="' + row.created.toISOString() + '" title="' + row.created.toISOString() + '">' + row.created.toISOString() + '</span>',
|
||||
'<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/lists/subscription/' + trigger.list + '/edit/' + row.cid + '">Edit</a>'
|
||||
'<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span><a href="/lists/subscription/' + trigger.list + '/edit/' + row.cid + '">' + _('Edit') + '</a>'
|
||||
])
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,6 +6,7 @@ let router = new express.Router();
|
|||
let users = require('../lib/models/users');
|
||||
let fields = require('../lib/models/fields');
|
||||
let settings = require('../lib/models/settings');
|
||||
let _ = require('../lib/translate')._;
|
||||
|
||||
router.get('/logout', (req, res) => passport.logout(req, res));
|
||||
|
||||
|
@ -28,7 +29,7 @@ router.post('/forgot', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
req.flash('danger', err.message || err);
|
||||
return res.redirect('/users/forgot');
|
||||
} else {
|
||||
req.flash('success', 'An email with password reset instructions has been sent to your email address, if it exists on our system.');
|
||||
req.flash('success', _('An email with password reset instructions has been sent to your email address, if it exists on our system.'));
|
||||
}
|
||||
return res.redirect('/users/login');
|
||||
});
|
||||
|
@ -42,7 +43,7 @@ router.get('/reset', passport.csrfProtection, (req, res) => {
|
|||
}
|
||||
|
||||
if (!status) {
|
||||
req.flash('danger', 'Unknown or expired reset token');
|
||||
req.flash('danger', _('Unknown or expired reset token'));
|
||||
return res.redirect('/users/login');
|
||||
}
|
||||
|
||||
|
@ -60,9 +61,9 @@ router.post('/reset', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
req.flash('danger', err.message || err);
|
||||
return res.redirect('/users/reset?username=' + encodeURIComponent(req.body.username) + '&token=' + encodeURIComponent(req.body['reset-token']));
|
||||
} else if (!status) {
|
||||
req.flash('danger', 'Unknown or expired reset token');
|
||||
req.flash('danger', _('Unknown or expired reset token'));
|
||||
} else {
|
||||
req.flash('success', 'Your password has been changed successfully');
|
||||
req.flash('success', _('Your password has been changed successfully'));
|
||||
}
|
||||
|
||||
return res.redirect('/users/login');
|
||||
|
@ -71,7 +72,7 @@ router.post('/reset', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
|
||||
router.all('/api', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
req.flash('danger', 'Need to be logged in to access restricted content');
|
||||
req.flash('danger', _('Need to be logged in to access restricted content'));
|
||||
return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
|
||||
}
|
||||
next();
|
||||
|
@ -83,7 +84,7 @@ router.get('/api', passport.csrfProtection, (req, res, next) => {
|
|||
return next(err);
|
||||
}
|
||||
if (!user) {
|
||||
return next(new Error('User data not found'));
|
||||
return next(new Error(_('User data not found')));
|
||||
}
|
||||
settings.list(['serviceUrl'], (err, configItems) => {
|
||||
if (err) {
|
||||
|
@ -106,9 +107,9 @@ router.post('/api/reset-token', passport.parseForm, passport.csrfProtection, (re
|
|||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
} else if (success) {
|
||||
req.flash('success', 'Access token updated');
|
||||
req.flash('success', _('Access token updated'));
|
||||
} else {
|
||||
req.flash('info', 'Access token not updated');
|
||||
req.flash('info', _('Access token not updated'));
|
||||
}
|
||||
return res.redirect('/users/api');
|
||||
});
|
||||
|
@ -116,7 +117,7 @@ router.post('/api/reset-token', passport.parseForm, passport.csrfProtection, (re
|
|||
|
||||
router.all('/account', (req, res, next) => {
|
||||
if (!req.user) {
|
||||
req.flash('danger', 'Need to be logged in to access restricted content');
|
||||
req.flash('danger', _('Need to be logged in to access restricted content'));
|
||||
return res.redirect('/users/login?next=' + encodeURIComponent(req.originalUrl));
|
||||
}
|
||||
next();
|
||||
|
@ -135,9 +136,9 @@ router.post('/account', passport.parseForm, passport.csrfProtection, (req, res)
|
|||
if (err) {
|
||||
req.flash('danger', err.message || err);
|
||||
} else if (success) {
|
||||
req.flash('success', 'Account information updated');
|
||||
req.flash('success', _('Account information updated'));
|
||||
} else {
|
||||
req.flash('info', 'Account information not updated');
|
||||
req.flash('info', _('Account information not updated'));
|
||||
}
|
||||
return res.redirect('/users/account');
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue