2020-11-10 14:41:56 -08:00
|
|
|
import { loadSuml } from './server/loader';
|
2020-10-13 12:49:08 -07:00
|
|
|
import fs from 'fs';
|
2021-08-22 14:53:22 -07:00
|
|
|
import {buildDict, buildList, buildLocaleList} from "./src/helpers";
|
2020-09-28 08:51:26 -07:00
|
|
|
|
2020-11-10 14:41:56 -08:00
|
|
|
const config = loadSuml('config');
|
|
|
|
const translations = loadSuml('translations');
|
|
|
|
|
2020-10-12 07:41:25 -07:00
|
|
|
const locale = config.locale;
|
2020-12-21 11:59:18 -08:00
|
|
|
const locales = buildLocaleList(locale);
|
2020-09-28 08:51:26 -07:00
|
|
|
const title = translations.title;
|
|
|
|
const description = translations.description;
|
2020-11-11 13:07:19 -08:00
|
|
|
const banner = process.env.BASE_URL + '/api/banner/zaimki.png';
|
2020-07-24 12:15:33 -07:00
|
|
|
const colour = '#C71585';
|
2020-07-22 13:19:23 -07:00
|
|
|
|
2021-07-09 11:42:39 -07:00
|
|
|
process.env.LOCALE = locale;
|
|
|
|
|
2021-08-22 14:53:22 -07:00
|
|
|
const allVersionsUrls = buildList(function*() {
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
yield 'http://pronouns.test:3000';
|
|
|
|
yield 'http://localhost:3000';
|
2021-08-23 01:55:07 -07:00
|
|
|
} else if (process.env.NODE_ENV === 'test') {
|
2021-08-29 15:03:59 -07:00
|
|
|
yield 'https://test.pronouns.page';
|
2021-08-22 14:53:22 -07:00
|
|
|
} else {
|
2021-08-23 00:43:23 -07:00
|
|
|
yield 'https://pronouns.page';
|
2021-08-22 14:53:22 -07:00
|
|
|
for (let loc in locales) {
|
|
|
|
yield locales[loc].url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
process.env.ALL_LOCALES_URLS = allVersionsUrls.join(',');
|
|
|
|
|
2020-08-04 07:15:41 -07:00
|
|
|
const bodyParser = require('body-parser');
|
|
|
|
|
2020-12-08 11:42:56 -08:00
|
|
|
const buildFlags = () => {
|
|
|
|
const flags = [];
|
|
|
|
for (let flag of fs.readdirSync(__dirname + '/static/flags/')) {
|
|
|
|
let flagDisplay = flag
|
|
|
|
.replace(new RegExp('\.png$'), '')
|
|
|
|
.replace(new RegExp('_', 'g'), '')
|
|
|
|
.trim();
|
|
|
|
|
|
|
|
if (flag.startsWith('.')) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag.startsWith('-')) {
|
|
|
|
const tell = '-' + config.locale + '-';
|
|
|
|
if (flag.startsWith(tell)) {
|
|
|
|
flagDisplay = flagDisplay.substring(tell.length);
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.push([
|
|
|
|
flag.replace(new RegExp('\.png$'), ''),
|
|
|
|
flagDisplay,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.sort((a, b) => a[1].localeCompare(b[1]));
|
|
|
|
|
|
|
|
return buildDict(function *() {
|
|
|
|
for (let [key, display] of flags) {
|
|
|
|
yield [key, display];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-03-02 02:24:23 -08:00
|
|
|
const postCssPlugins = [
|
|
|
|
require('autoprefixer'),
|
|
|
|
];
|
|
|
|
|
|
|
|
if (config.dir === 'rtl') {
|
|
|
|
postCssPlugins.push(require('rtlcss'));
|
|
|
|
}
|
|
|
|
|
2020-07-22 13:19:23 -07:00
|
|
|
export default {
|
|
|
|
target: 'server',
|
|
|
|
head: {
|
2021-01-22 14:54:24 -08:00
|
|
|
htmlAttrs: {
|
|
|
|
dir: config.dir || 'ltr',
|
|
|
|
},
|
2020-07-22 13:19:23 -07:00
|
|
|
title: title,
|
|
|
|
meta: [
|
|
|
|
{ charset: 'utf-8' },
|
|
|
|
|
|
|
|
{ hid: 'description', name: 'description', content: description },
|
|
|
|
|
|
|
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
|
|
|
{ hid: 'apple-mobile-web-app-title', name: 'apple-mobile-web-app-title', content: title },
|
2020-07-24 12:15:33 -07:00
|
|
|
{ hid: 'theme-color', name: 'theme-color', content: colour },
|
2020-07-22 13:19:23 -07:00
|
|
|
|
|
|
|
{ hid: 'og:type', property: 'og:type', content: 'article' },
|
|
|
|
{ hid: 'og:title', property: 'og:title', content: title },
|
|
|
|
{ hid: 'og:description', property: 'og:description', content: description },
|
|
|
|
{ hid: 'og:site_name', property: 'og:site_name', content: title },
|
2020-11-29 09:36:57 -08:00
|
|
|
{ hid: 'og:image', property: 'og:image', content: banner },
|
2020-07-22 13:19:23 -07:00
|
|
|
|
|
|
|
{ hid: 'twitter:card', property: 'twitter:card', content: 'summary_large_image' },
|
|
|
|
{ hid: 'twitter:title', property: 'twitter:title', content: title },
|
|
|
|
{ hid: 'twitter:description', property: 'twitter:description', content: description },
|
|
|
|
{ hid: 'twitter:site', property: 'twitter:site', content: process.env.BASE_URL },
|
|
|
|
{ hid: 'twitter:image', property: 'twitter:image', content: banner },
|
|
|
|
],
|
|
|
|
link: [
|
|
|
|
{ rel: 'icon', type: 'image/svg', href: '/favicon.svg' }
|
|
|
|
],
|
|
|
|
},
|
|
|
|
css: [],
|
|
|
|
plugins: [
|
|
|
|
{ src: '~/plugins/vue-matomo.js', ssr: false },
|
2020-09-28 09:29:13 -07:00
|
|
|
{ src: '~/plugins/globals.js' },
|
2020-10-15 09:50:32 -07:00
|
|
|
{ src: '~/plugins/auth.js' },
|
2020-07-22 13:19:23 -07:00
|
|
|
],
|
|
|
|
components: true,
|
|
|
|
buildModules: [],
|
|
|
|
modules: [
|
|
|
|
'@nuxtjs/pwa',
|
2020-08-04 07:15:41 -07:00
|
|
|
'@nuxtjs/axios',
|
2020-10-12 07:41:25 -07:00
|
|
|
['@nuxtjs/redirect-module', {
|
|
|
|
rules: config.redirects,
|
2020-10-15 10:23:53 -07:00
|
|
|
}],
|
|
|
|
'cookie-universal-nuxt',
|
2020-07-22 13:19:23 -07:00
|
|
|
],
|
2020-07-24 12:15:33 -07:00
|
|
|
pwa: {
|
|
|
|
manifest: {
|
|
|
|
name: title,
|
|
|
|
short_name: title,
|
|
|
|
description: description,
|
|
|
|
background_color: '#ffffff',
|
|
|
|
theme_color: colour,
|
2020-10-12 07:41:25 -07:00
|
|
|
lang: locale,
|
2020-07-24 12:15:33 -07:00
|
|
|
}
|
|
|
|
},
|
2020-07-25 10:21:52 -07:00
|
|
|
build: {
|
2021-03-01 14:14:42 -08:00
|
|
|
postcss: {
|
2021-03-02 02:24:23 -08:00
|
|
|
plugins: postCssPlugins,
|
2021-03-01 14:14:42 -08:00
|
|
|
},
|
2020-07-25 10:21:52 -07:00
|
|
|
extend (config, ctx) {
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.csv|\.tsv$/,
|
|
|
|
loader: 'csv-loader',
|
|
|
|
options: {
|
|
|
|
dynamicTyping: true,
|
|
|
|
header: true,
|
|
|
|
skipEmptyLines: true,
|
2020-08-25 05:58:11 -07:00
|
|
|
delimiter: '\t',
|
2020-07-25 10:21:52 -07:00
|
|
|
}
|
2020-09-28 05:12:20 -07:00
|
|
|
});
|
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.suml$/,
|
2020-11-13 13:57:23 -08:00
|
|
|
loader: 'suml-loader',
|
2020-09-28 05:12:20 -07:00
|
|
|
});
|
2020-11-13 13:57:23 -08:00
|
|
|
config.module.rules.push({
|
|
|
|
test: /\.md$/,
|
|
|
|
use: ['html-loader', 'markdown-loader']
|
|
|
|
})
|
2020-07-25 10:21:52 -07:00
|
|
|
},
|
|
|
|
},
|
2020-07-22 13:19:23 -07:00
|
|
|
env: {
|
2020-10-13 12:49:08 -07:00
|
|
|
BASE_URL: process.env.BASE_URL,
|
2020-10-31 13:33:59 -07:00
|
|
|
TITLE: title,
|
2020-10-13 12:49:08 -07:00
|
|
|
PUBLIC_KEY: fs.readFileSync(__dirname + '/keys/public.pem').toString(),
|
2020-11-15 00:39:26 -08:00
|
|
|
CONFIG: config,
|
2020-10-24 12:50:08 -07:00
|
|
|
LOCALE: config.locale,
|
2020-11-12 12:32:07 -08:00
|
|
|
LOCALES: locales,
|
2020-12-08 11:42:56 -08:00
|
|
|
FLAGS: buildFlags(),
|
2021-01-06 06:21:20 -08:00
|
|
|
BUCKET: `https://${process.env.AWS_S3_BUCKET}.s3-${process.env.AWS_REGION}.amazonaws.com`,
|
2021-06-09 23:45:13 -07:00
|
|
|
STATS_FILE: process.env.STATS_FILE,
|
2021-08-07 03:03:49 -07:00
|
|
|
HCAPTCHA_SITEKEY: process.env.HCAPTCHA_SITEKEY,
|
2021-08-22 14:53:22 -07:00
|
|
|
ALL_LOCALES_URLS: process.env.ALL_LOCALES_URLS,
|
2020-07-22 13:19:23 -07:00
|
|
|
},
|
2021-06-25 15:51:43 -07:00
|
|
|
serverMiddleware: ['~/server/no-ssr.js', '~/server/index.js'],
|
2020-08-04 07:15:41 -07:00
|
|
|
axios: {
|
2021-04-03 13:16:05 -07:00
|
|
|
baseURL: process.env.BASE_URL + '/api',
|
2020-09-28 05:12:20 -07:00
|
|
|
},
|
2020-09-28 10:22:36 -07:00
|
|
|
router: {
|
|
|
|
extendRoutes(routes, resolve) {
|
2021-08-06 04:30:58 -07:00
|
|
|
if (config.pronouns.enabled) {
|
|
|
|
routes.push({ path: '/' + config.pronouns.route, component: resolve(__dirname, 'routes/pronouns.vue') });
|
|
|
|
}
|
|
|
|
|
2020-09-28 10:22:36 -07:00
|
|
|
if (config.sources.enabled) {
|
|
|
|
routes.push({ path: '/' + config.sources.route, component: resolve(__dirname, 'routes/sources.vue') });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.nouns.enabled) {
|
|
|
|
routes.push({ path: '/' + config.nouns.route, component: resolve(__dirname, 'routes/nouns.vue') });
|
2021-01-17 11:43:21 -08:00
|
|
|
for (let subroute of config.nouns.subroutes || []) {
|
2021-08-28 14:51:45 -07:00
|
|
|
routes.push({ path: `/${subroute}`, component: resolve(__dirname, `data/nouns/${subroute}.vue`) });
|
2021-01-17 11:43:21 -08:00
|
|
|
}
|
2020-09-28 10:22:36 -07:00
|
|
|
}
|
|
|
|
|
2021-08-28 14:51:45 -07:00
|
|
|
if (config.inclusive.enabled) {
|
|
|
|
routes.push({path: `/${config.inclusive.route}`, component: resolve(__dirname, 'routes/inclusive.vue')});
|
|
|
|
}
|
|
|
|
if (config.terminology.enabled) {
|
|
|
|
routes.push({path: `/${config.terminology.route}`, component: resolve(__dirname, 'routes/terminology.vue')});
|
2021-08-29 00:14:41 -07:00
|
|
|
|
|
|
|
// TODO remove later
|
|
|
|
routes.push({path: `/${config.nouns.route}/${config.terminology.route}`, component: resolve(__dirname, 'routes/terminology.vue')});
|
2021-08-28 14:51:45 -07:00
|
|
|
}
|
|
|
|
|
2020-09-29 08:59:23 -07:00
|
|
|
if (config.names.enabled) {
|
|
|
|
routes.push({ path: '/' + config.names.route, component: resolve(__dirname, 'routes/names.vue') });
|
|
|
|
}
|
|
|
|
|
2020-10-10 09:31:31 -07:00
|
|
|
if (config.faq.enabled) {
|
|
|
|
routes.push({ path: '/' + config.faq.route, component: resolve(__dirname, 'routes/faq.vue') });
|
|
|
|
}
|
|
|
|
|
2020-09-28 10:22:36 -07:00
|
|
|
if (config.links.enabled) {
|
|
|
|
routes.push({ path: '/' + config.links.route, component: resolve(__dirname, 'routes/links.vue') });
|
2021-05-13 04:54:13 -07:00
|
|
|
if (config.links.academicRoute) {
|
|
|
|
routes.push({ path: '/' + config.links.academicRoute, component: resolve(__dirname, 'routes/academic.vue') });
|
|
|
|
}
|
|
|
|
if (config.links.mediaRoute) {
|
|
|
|
routes.push({ path: '/' + config.links.mediaRoute, component: resolve(__dirname, 'routes/media.vue') });
|
|
|
|
}
|
2020-09-28 10:22:36 -07:00
|
|
|
}
|
|
|
|
|
2021-06-23 10:25:56 -07:00
|
|
|
if (config.links.blog) {
|
2021-05-14 07:05:22 -07:00
|
|
|
routes.push({ path: '/' + config.links.blogRoute, component: resolve(__dirname, 'routes/blog.vue'), name: 'blog' });
|
|
|
|
}
|
2021-06-23 10:25:56 -07:00
|
|
|
routes.push({ path: '/' + config.links.blogRoute + '/:slug', component: resolve(__dirname, 'routes/blogEntry.vue'), name: 'blogEntry' });
|
2021-05-14 07:05:22 -07:00
|
|
|
|
2020-09-29 10:11:46 -07:00
|
|
|
if (config.people.enabled) {
|
|
|
|
routes.push({ path: '/' + config.people.route, component: resolve(__dirname, 'routes/people.vue') });
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:34:47 -07:00
|
|
|
if (config.english.enabled) {
|
|
|
|
routes.push({ path: '/' + config.english.route, component: resolve(__dirname, 'routes/english.vue') });
|
|
|
|
}
|
|
|
|
|
2020-09-28 10:22:36 -07:00
|
|
|
if (config.contact.enabled) {
|
|
|
|
routes.push({ path: '/' + config.contact.route, component: resolve(__dirname, 'routes/contact.vue') });
|
|
|
|
}
|
2021-01-12 11:06:59 -08:00
|
|
|
if (config.contact.team.enabled) {
|
|
|
|
routes.push({ path: '/' + config.contact.team.route, component: resolve(__dirname, 'routes/team.vue') });
|
|
|
|
}
|
2020-09-28 10:22:36 -07:00
|
|
|
|
2020-12-18 02:34:58 -08:00
|
|
|
if (config.census.enabled) {
|
|
|
|
routes.push({ path: '/' + config.census.route, component: resolve(__dirname, 'routes/census.vue') });
|
|
|
|
}
|
|
|
|
|
2020-10-13 12:49:08 -07:00
|
|
|
if (config.user.enabled) {
|
|
|
|
routes.push({path: '/' + config.user.route, component: resolve(__dirname, 'routes/user.vue')});
|
2020-10-27 00:52:11 -07:00
|
|
|
routes.push({path: '/' + config.user.termsRoute, component: resolve(__dirname, 'routes/terms.vue')});
|
2020-10-13 12:49:08 -07:00
|
|
|
}
|
2020-10-29 15:41:40 -07:00
|
|
|
routes.push({ path: '/admin', component: resolve(__dirname, 'routes/admin.vue') });
|
2020-09-28 10:22:36 -07:00
|
|
|
|
2020-10-28 08:22:29 -07:00
|
|
|
if (config.profile.enabled) {
|
|
|
|
routes.push({path: '/@*', component: resolve(__dirname, 'routes/profile.vue')});
|
2021-07-10 07:46:29 -07:00
|
|
|
routes.push({path: '/card/@*', component: resolve(__dirname, 'routes/profileCard.vue')});
|
2020-10-28 08:22:29 -07:00
|
|
|
if (config.profile.editorEnabled) {
|
2020-11-03 14:11:01 -08:00
|
|
|
routes.push({path: '/editor', component: resolve(__dirname, 'routes/profileEditor.vue')});
|
2020-10-28 08:22:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-10 15:47:44 -08:00
|
|
|
if (config.pronouns.enabled) {
|
2020-11-15 07:10:03 -08:00
|
|
|
routes.push({ path: '/' + config.pronouns.any, component: resolve(__dirname, 'routes/any.vue') });
|
2020-11-29 02:03:01 -08:00
|
|
|
if (config.pronouns.avoiding) {
|
|
|
|
routes.push({ path: '/' + config.pronouns.avoiding, component: resolve(__dirname, 'routes/avoiding.vue') });
|
|
|
|
}
|
2020-10-28 08:22:29 -07:00
|
|
|
}
|
2020-10-16 11:17:50 -07:00
|
|
|
|
2021-08-14 01:42:49 -07:00
|
|
|
if (config.calendar && config.calendar.enabled) {
|
|
|
|
routes.push({ path: '/' + config.calendar.route, component: resolve(__dirname, 'routes/calendar.vue') });
|
2021-08-18 05:39:08 -07:00
|
|
|
routes.push({ path: '/calendar-wide', component: resolve(__dirname, 'routes/calendarWide.vue') });
|
2021-08-14 01:42:49 -07:00
|
|
|
}
|
|
|
|
|
2021-05-21 09:39:14 -07:00
|
|
|
if (config.api !== null) {
|
|
|
|
routes.push({ path: '/api', component: resolve(__dirname, 'routes/api.vue') });
|
|
|
|
}
|
2020-11-10 14:41:56 -08:00
|
|
|
|
2020-11-10 15:47:44 -08:00
|
|
|
routes.push({ name: 'all', path: '*', component: resolve(__dirname, 'routes/pronoun.vue') });
|
2020-09-28 10:22:36 -07:00
|
|
|
},
|
|
|
|
},
|
2020-07-22 13:19:23 -07:00
|
|
|
}
|