Move contact page to its own route handler

This commit is contained in:
calzoneman 2015-10-27 22:04:21 -07:00
parent 88236e036c
commit 13d4a49976
5 changed files with 62 additions and 30 deletions

26
src/web/routes/contact.js Normal file
View file

@ -0,0 +1,26 @@
import CyTubeUtil from '../../utilities';
import { sendJade } from '../jade';
export default function initialize(app, webConfig) {
app.get('/contact', (req, res) => {
// Basic obfuscation of email addresses to prevent spambots
// from picking them up. Not real encryption.
// Deobfuscated by clientside JS.
const contacts = webConfig.getEmailContacts().map(contact => {
const emkey = CyTubeUtil.randomSalt(16);
let email = new Array(contact.email.length);
for (let i = 0; i < contact.email.length; i++) {
email[i] = String.fromCharCode(
contact.email.charCodeAt(i) ^ emkey.charCodeAt(i % emkey.length)
);
}
contact.email = escape(email.join(""));
contact.emkey = escape(emkey);
return contact;
});
return sendJade(res, 'contact', {
contacts: contacts
});
});
}