From 90357f6a7729e82d5498835d92bf86e8e07d3478 Mon Sep 17 00:00:00 2001 From: INOUE Daisuke Date: Sun, 23 Mar 2025 16:22:10 +0900 Subject: instance description etc. fix translation --- src/lib/config.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/lib/config.ts') diff --git a/src/lib/config.ts b/src/lib/config.ts index e8b774a..406775d 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -3,6 +3,7 @@ import toml from "toml"; import { exitWithError } from "./process.js"; import { Response } from "express"; import { markdownToSanitizedHTML } from "../util/markdown.js"; +import i18next from "i18next"; interface StaticPage { title: string; @@ -109,44 +110,44 @@ export const instanceRules = (): InstanceRule[] => { rules.push( config.general.show_public_event_list ? { - text: "Public events and groups are displayed on the homepage", + text: i18next.t("config.instancerule.showpubliceventlist-true"), icon: "fas fa-eye", } : { - text: "Events and groups can only be accessed by direct link", + text: i18next.t("config.instancerule..showpubliceventlist-false"), icon: "fas fa-eye-slash", }, ); rules.push( config.general.creator_email_addresses?.length ? { - text: "Only specific people can create events and groups", + text: i18next.t("config.instancerule.creatoremail-true"), icon: "fas fa-user-check", } : { - text: "Anyone can create events and groups", + text: i18next.t("config.instancerule.creatoremail-false"), icon: "fas fa-users", }, ); rules.push( config.general.delete_after_days > 0 ? { - text: `Events are automatically deleted ${config.general.delete_after_days} days after they end`, + text: i18next.t("config.instancerule.deleteafterdays-true", { days: config.general.delete_after_days } ), icon: "far fa-calendar-times", } : { - text: "Events are permanent, and are never automatically deleted", + text: i18next.t("config.instancerule.deleteafterdays-false"), icon: "far fa-calendar-check", }, ); rules.push( config.general.is_federated ? { - text: "This instance federates with other instances using ActivityPub", + text: i18next.t("config.instancerule.isfederated-true"), icon: "fas fa-globe", } : { - text: "This instance does not federate with other instances", + text: i18next.t("config.instancerule.isfederated-false"), icon: "fas fa-globe", }, ); @@ -156,12 +157,13 @@ export const instanceRules = (): InstanceRule[] => { export const instanceDescription = (): string => { const config = getConfig(); const defaultInstanceDescription = - "**{{ siteName }}** is running on Gathio — a simple, federated, privacy-first event hosting platform."; + i18next.t("config.defaultinstancedesc"); let instanceDescription = defaultInstanceDescription; + let instancedescfile = "./static/instance-description-" + i18next.language + ".md"; try { - if (fs.existsSync("./static/instance-description.md")) { + if (fs.existsSync(instancedescfile)) { const fileBody = fs.readFileSync( - "./static/instance-description.md", + instancedescfile, "utf-8", ); instanceDescription = markdownToSanitizedHTML(fileBody); -- cgit v1.2.3 From 14041a319cace03cfc23c0a919ed81fb141f88ce Mon Sep 17 00:00:00 2001 From: Gavin Mogan Date: Fri, 25 Apr 2025 21:43:39 -0700 Subject: Refactor to have email service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move hbsInstance back to app * Add email and hbs to req so typescript 🎉🎉🎉 * Init Email and config once --- src/lib/config.ts | 70 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 26 deletions(-) (limited to 'src/lib/config.ts') diff --git a/src/lib/config.ts b/src/lib/config.ts index 003a714..6642eef 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -110,46 +110,46 @@ export const instanceRules = (): InstanceRule[] => { rules.push( config.general.show_public_event_list ? { - text: "Public events and groups are displayed on the homepage", - icon: "fas fa-eye", - } + text: "Public events and groups are displayed on the homepage", + icon: "fas fa-eye", + } : { - text: "Events and groups can only be accessed by direct link", - icon: "fas fa-eye-slash", - }, + text: "Events and groups can only be accessed by direct link", + icon: "fas fa-eye-slash", + }, ); rules.push( config.general.creator_email_addresses?.length ? { - text: "Only specific people can create events and groups", - icon: "fas fa-user-check", - } + text: "Only specific people can create events and groups", + icon: "fas fa-user-check", + } : { - text: "Anyone can create events and groups", - icon: "fas fa-users", - }, + text: "Anyone can create events and groups", + icon: "fas fa-users", + }, ); rules.push( config.general.delete_after_days > 0 ? { - text: `Events are automatically deleted ${config.general.delete_after_days} days after they end`, - icon: "far fa-calendar-times", - } + text: `Events are automatically deleted ${config.general.delete_after_days} days after they end`, + icon: "far fa-calendar-times", + } : { - text: "Events are permanent, and are never automatically deleted", - icon: "far fa-calendar-check", - }, + text: "Events are permanent, and are never automatically deleted", + icon: "far fa-calendar-check", + }, ); rules.push( config.general.is_federated ? { - text: "This instance federates with other instances using ActivityPub", - icon: "fas fa-globe", - } + text: "This instance federates with other instances using ActivityPub", + icon: "fas fa-globe", + } : { - text: "This instance does not federate with other instances", - icon: "fas fa-globe", - }, + text: "This instance does not federate with other instances", + icon: "fas fa-globe", + }, ); return rules; }; @@ -179,17 +179,35 @@ export const instanceDescription = (): string => { } }; +let _resolvedConfig: GathioConfig | null = null; // Attempt to load our global config. Will stop the app if the config file // cannot be read (there's no point trying to continue!) export const getConfig = (): GathioConfig => { + if (_resolvedConfig) { + return _resolvedConfig; + } + try { const config = toml.parse( fs.readFileSync("./config/config.toml", "utf-8"), ) as GathioConfig; - return { + const resolvedConfig = { ...defaultConfig, ...config, - }; + } + if (process.env.CYPRESS || process.env.CI) { + config.general.mail_service = "none"; + console.log( + "Running in Cypress or CI, not initializing email service.", + ); + } else if (config.general.mail_service === "none") { + console.warn( + "You have not configured this Gathio instance to send emails! This means that event creators will not receive emails when their events are created, which means they may end up locked out of editing events. Consider setting up an email service.", + ); + } + + _resolvedConfig = resolvedConfig; + return resolvedConfig; } catch { exitWithError( "Configuration file not found! Have you renamed './config/config-example.toml' to './config/config.toml'?", -- cgit v1.2.3 From b2e8547dc9c91bf48bd5743e1bda2c9e507da908 Mon Sep 17 00:00:00 2001 From: INOUE Daisuke Date: Mon, 19 May 2025 00:16:39 +0900 Subject: Fix to parse markdown, default instance description --- src/lib/config.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lib/config.ts') diff --git a/src/lib/config.ts b/src/lib/config.ts index 5b74e4a..b08fa31 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -157,8 +157,9 @@ export const instanceRules = (): InstanceRule[] => { export const instanceDescription = (): string => { const config = getConfig(); - const defaultInstanceDescription = - i18next.t("config.defaultinstancedesc"); + const defaultInstanceDescription = markdownToSanitizedHTML( + i18next.t("config.defaultinstancedesc", "Welcome to this Gathio instance!") + ); let instanceDescription = defaultInstanceDescription; let instancedescfile = "./static/instance-description-" + i18next.language + ".md"; try { -- cgit v1.2.3 From bc9e983b16d9ac2d27a4458c0a87f9d11aa80c0e Mon Sep 17 00:00:00 2001 From: Raphael Kabo Date: Tue, 27 May 2025 19:07:27 +0100 Subject: Add Mailgun email service --- src/lib/config.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lib/config.ts') diff --git a/src/lib/config.ts b/src/lib/config.ts index 6642eef..3fd6eb7 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -21,7 +21,7 @@ export interface GathioConfig { email_logo_url: string; show_kofi: boolean; show_public_event_list: boolean; - mail_service: "nodemailer" | "sendgrid" | "none"; + mail_service: "nodemailer" | "sendgrid" | "mailgun" | "none"; creator_email_addresses: string[]; }; database: { @@ -37,6 +37,11 @@ export interface GathioConfig { sendgrid?: { api_key: string; }; + mailgun?: { + api_key: string; + api_url: string; + domain: string; + }; static_pages?: StaticPage[]; } -- cgit v1.2.3