mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-22 03:57:47 -04:00
[sources] generate default id
This commit is contained in:
parent
83ab39bf63
commit
94de0572f7
@ -1,12 +1,17 @@
|
||||
import { Router } from 'express';
|
||||
import mailer from "../../src/mailer";
|
||||
import {camelCase, capitalise} from "../../src/helpers";
|
||||
|
||||
const generateId = title => {
|
||||
return camelCase(title.split(' ').slice(0, 2));
|
||||
}
|
||||
|
||||
const buildEmail = (data, user) => {
|
||||
const human = [
|
||||
`<li><strong>user:</strong> ${user ? user.username : ''}</li>`,
|
||||
`<li><strong>templates:</strong> ${data.templates}</li>`,
|
||||
];
|
||||
const tsv = ['???'];
|
||||
const tsv = [generateId(data.title) || '???'];
|
||||
|
||||
for (let field of ['type','author','title','extra','year','fragments','comment','link']) {
|
||||
human.push(`<li><strong>${field}:</strong> ${field === 'fragments' ? `<pre>${data[field]}</pre>`: data[field]}</li>`);
|
||||
|
@ -119,6 +119,11 @@ export const capitalise = function (word) {
|
||||
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
||||
}
|
||||
|
||||
export const camelCase = function (words) {
|
||||
const text = words.map(capitalise).join('');
|
||||
return text.substring(0, 1).toLowerCase() + text.substring(1);
|
||||
}
|
||||
|
||||
export const now = function () {
|
||||
return Math.floor(Date.now() / 1000);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user