From 2cd295e783ccbcd5479b83a0106375d413b010c1 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sun, 25 May 2025 19:05:12 +0200 Subject: [PATCH] make meta data configurable --- backend/src/config/index.ts | 8 ++++++-- backend/src/config/metadata.ts | 10 ---------- backend/src/constants/categories.ts | 2 +- backend/src/emails/sendEmail.ts | 3 +-- backend/tools/replace-constants.sh | 1 - webapp/components/LoginForm/LoginForm.vue | 6 ++++-- webapp/components/Logo/Logo.vue | 6 ++++-- .../components/Registration/RegistrationSlider.vue | 11 ++++++++--- webapp/config/index.js | 12 +++++++++++- webapp/constants/categories.js | 2 +- webapp/constants/dateTime.js | 2 +- webapp/constants/manifest.js | 11 +++++------ webapp/constants/metadata.js | 10 ---------- webapp/maintenance/source/pages/index.vue | 8 ++++---- webapp/nuxt.config.js | 3 +-- webapp/pages/password-reset.vue | 6 ++++-- webapp/plugins/apollo-config.js | 3 +-- webapp/store/auth.js | 4 ++-- 18 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 backend/src/config/metadata.ts delete mode 100644 webapp/constants/metadata.js diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 1aa7991eb..44db57919 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -7,7 +7,6 @@ import { config } from 'dotenv' import * as SMTPTransport from 'nodemailer/lib/smtp-pool' import emails from './emails' -import metadata from './metadata' // Load env file config() @@ -110,11 +109,15 @@ const s3 = { env.AWS_BUCKET, } +const meta = { + APPLICATION_NAME: process.env.APPLICATION_NAME ?? 'ocelot.social', + ORGANIZATION_NAME: process.env.ORGANIZATION_NAME ?? 'ocelot.social Community', +} + const options = { EMAIL_DEFAULT_SENDER: env.EMAIL_DEFAULT_SENDER, SUPPORT_EMAIL: env.SUPPORT_EMAIL, SUPPORT_URL: emails.SUPPORT_LINK, - APPLICATION_NAME: metadata.APPLICATION_NAME, ORGANIZATION_URL: emails.ORGANIZATION_LINK, PUBLIC_REGISTRATION: env.PUBLIC_REGISTRATION === 'true' || false, INVITE_REGISTRATION: env.INVITE_REGISTRATION !== 'false', // default = true @@ -147,6 +150,7 @@ export default { ...s3, ...options, ...language, + ...meta, } export { nodemailerTransportOptions } diff --git a/backend/src/config/metadata.ts b/backend/src/config/metadata.ts deleted file mode 100644 index 9c87818ae..000000000 --- a/backend/src/config/metadata.ts +++ /dev/null @@ -1,10 +0,0 @@ -// this file is duplicated in `backend/src/config/metadata` and `webapp/constants/metadata.js` and replaced on rebranding -export default { - APPLICATION_NAME: 'ocelot.social', - APPLICATION_SHORT_NAME: 'ocelot.social', - APPLICATION_DESCRIPTION: 'ocelot.social Community Network', - COOKIE_NAME: 'ocelot-social-token', - ORGANIZATION_NAME: 'ocelot.social Community', - ORGANIZATION_JURISDICTION: 'City of Angels', - THEME_COLOR: 'rgb(23, 181, 63)', // $color-primary – as the main color in general. e.g. the color in the background of the app that is visible behind the transparent iPhone status bar to name one use case, or the current color of SVGs to name another use case -} diff --git a/backend/src/constants/categories.ts b/backend/src/constants/categories.ts index b6fce03ca..db458857c 100644 --- a/backend/src/constants/categories.ts +++ b/backend/src/constants/categories.ts @@ -1,4 +1,4 @@ -// this file is duplicated in `backend/src/constants/metadata` and `webapp/constants/metadata.js` +// this file is duplicated in `backend/src/constants/categories` and `webapp/constants/categories.js` export const CATEGORIES_MIN = 1 export const CATEGORIES_MAX = 3 diff --git a/backend/src/emails/sendEmail.ts b/backend/src/emails/sendEmail.ts index 61a5ba951..98a32b30d 100644 --- a/backend/src/emails/sendEmail.ts +++ b/backend/src/emails/sendEmail.ts @@ -12,7 +12,6 @@ import { createTransport } from 'nodemailer' import CONFIG, { nodemailerTransportOptions } from '@config/index' import logosWebapp from '@config/logosBranded' -import metadata from '@config/metadata' import { UserDbProperties } from '@db/types/User' const welcomeImageUrl = new URL(logosWebapp.LOGO_WELCOME_PATH, CONFIG.CLIENT_URI) @@ -21,7 +20,7 @@ const settingsUrl = new URL('/settings/notifications', CONFIG.CLIENT_URI) export const defaultParams = { welcomeImageUrl, APPLICATION_NAME: CONFIG.APPLICATION_NAME, - ORGANIZATION_NAME: metadata.ORGANIZATION_NAME, + ORGANIZATION_NAME: CONFIG.ORGANIZATION_NAME, ORGANIZATION_URL: CONFIG.ORGANIZATION_URL, SUPPORT_EMAIL: CONFIG.SUPPORT_EMAIL, supportUrl: CONFIG.SUPPORT_URL, diff --git a/backend/tools/replace-constants.sh b/backend/tools/replace-constants.sh index 5454d3ae8..6a62b2325 100755 --- a/backend/tools/replace-constants.sh +++ b/backend/tools/replace-constants.sh @@ -3,6 +3,5 @@ # TODO: this is a hack, we should find a better way to share files between backend and webapp [ -f src/config/tmp/emails.js ] && mv src/config/tmp/emails.js src/config/emails.ts [ -f src/config/tmp/logos.js ] && mv src/config/tmp/logos.js src/config/logos.ts -[ -f src/config/tmp/metadata.js ] && mv src/config/tmp/metadata.js src/config/metadata.ts [ -f src/constants/categories.js ] && mv src/constants/categories.js src/constants/categories.ts exit 0 diff --git a/webapp/components/LoginForm/LoginForm.vue b/webapp/components/LoginForm/LoginForm.vue index ab64c5a3b..39d293cb2 100644 --- a/webapp/components/LoginForm/LoginForm.vue +++ b/webapp/components/LoginForm/LoginForm.vue @@ -53,7 +53,7 @@ diff --git a/webapp/nuxt.config.js b/webapp/nuxt.config.js index 263c3f149..e4e25041a 100644 --- a/webapp/nuxt.config.js +++ b/webapp/nuxt.config.js @@ -1,6 +1,5 @@ import path from 'path' import manifest from './constants/manifest.js' -import metadata from './constants/metadata.js' const CONFIG = require('./config').default // we need to use require since this is only evaluated at compile time. @@ -211,7 +210,7 @@ export default { // Give apollo module options apollo: { - tokenName: metadata.COOKIE_NAME, // optional, default: apollo-token + tokenName: CONFIG.COOKIE_NAME, // optional, default: apollo-token cookieAttributes: { expires: CONFIG.COOKIE_EXPIRE_TIME, // optional, default: 7 (days) /** * Define the path where the cookie is available. Defaults to '/' */ diff --git a/webapp/pages/password-reset.vue b/webapp/pages/password-reset.vue index fa3223f6d..c918e6834 100644 --- a/webapp/pages/password-reset.vue +++ b/webapp/pages/password-reset.vue @@ -16,11 +16,11 @@