Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/database/settings/customize.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import getStrategies from "@cocalc/database/settings/get-sso-strategies";6import {7KUCALC_COCALC_COM,8KucalcValues,9} from "@cocalc/util/db-schema/site-defaults";10import { Strategy } from "@cocalc/util/types/sso";11import { ServerSettings, getServerSettings } from "./server-settings";12import siteURL from "./site-url";1314export interface Customize {15siteName?: string;16siteDescription?: string;17organizationName?: string;18organizationEmail?: string;19organizationURL?: string;20termsOfServiceURL?: string;21helpEmail?: string;22contactEmail?: string;23isCommercial?: boolean;24kucalc?: KucalcValues;25sshGateway?: boolean;26sshGatewayDNS?: string;27logoSquareURL?: string;28logoRectangularURL?: string;29splashImage?: string;30indexInfo?: string;31indexTagline?: string;32imprint?: string;33policies?: string;34shareServer?: boolean;35landingPages?: boolean;36dns?: string;37siteURL?: string;38googleAnalytics?: string;39anonymousSignup?: boolean;40anonymousSignupLicensedShares?: boolean;41emailSignup?: boolean;42accountCreationInstructions?: string;43zendesk?: boolean; // true if zendesk support is configured.44stripePublishableKey?: string;45imprint_html?: string;46policies_html?: string;47reCaptchaKey?: string;48sandboxProjectsEnabled?: boolean;49sandboxProjectId?: string;50verifyEmailAddresses?: boolean;51strategies?: Strategy[];52openaiEnabled?: boolean;53googleVertexaiEnabled?: boolean;54mistralEnabled?: boolean;55anthropicEnabled?: boolean;56ollamaEnabled?: boolean;57neuralSearchEnabled?: boolean;58jupyterApiEnabled?: boolean;59computeServersEnabled?: boolean;60cloudFilesystemsEnabled?: boolean;61githubProjectId?: string;62support?: string;63}6465const fallback = (a?: string, b?: string): string =>66typeof a == "string" && a.length > 0 ? a : `${b}`;6768/*69Create a Javascript object that describes properties of the server.70This is used on the next.js server landing pages and the share server71to customize their look and behavior.7273This function is cached via the parameters in ./server-settings, i.e.,74for a few seconds.75*/7677let cachedSettings: ServerSettings | undefined = undefined;78let cachedCustomize: Customize | undefined = undefined;79export default async function getCustomize(): Promise<Customize> {80const [settings, strategies]: [ServerSettings, Strategy[]] =81await Promise.all([getServerSettings(), getStrategies()]);8283if (settings === cachedSettings && cachedCustomize != null) {84return cachedCustomize;85}86cachedSettings = settings;87cachedCustomize = {88siteName: fallback(settings.site_name, "On Premises CoCalc"),89siteDescription: fallback(90settings.site_description,91"Collaborative Calculation using Python, Sage, R, Julia, and more.",92),9394organizationName: settings.organization_name,95organizationEmail: settings.organization_email,96organizationURL: settings.organization_url,97termsOfServiceURL: settings.terms_of_service_url,9899helpEmail: settings.help_email,100contactEmail: fallback(settings.organization_email, settings.help_email),101102isCommercial: settings.commercial,103104kucalc: settings.kucalc,105sshGateway: settings.ssh_gateway,106sshGatewayDNS: settings.ssh_gateway_dns,107108anonymousSignup: settings.anonymous_signup,109anonymousSignupLicensedShares: settings.anonymous_signup_licensed_shares,110emailSignup: settings.email_signup,111accountCreationInstructions: settings.account_creation_email_instructions,112113logoSquareURL: settings.logo_square,114logoRectangularURL: settings.logo_rectangular,115splashImage: settings.splash_image,116117shareServer: !!settings.share_server,118119// additionally restrict showing landing pages only in cocalc.com-mode120landingPages:121!!settings.landing_pages && settings.kucalc === KUCALC_COCALC_COM,122123googleAnalytics: settings.google_analytics,124125indexInfo: settings.index_info_html,126indexTagline: settings.index_tagline,127imprint: settings.imprint,128policies: settings.policies,129support: settings.support,130131// Is important for invite emails, password reset, etc. (e.g., so we can construct a url to our site).132// This *can* start with http:// to explicitly use http instead of https, and can end133// in something like :3594 to indicate a port.134dns: settings.dns,135// siteURL is derived from settings.dns and the basePath -- it combines the dns, https://136// and the basePath. It never ends in a slash. This is used in practice for137// things like invite emails, password reset, etc.138siteURL: await siteURL(settings.dns),139140zendesk:141settings.zendesk_token &&142settings.zendesk_username &&143settings.zendesk_uri,144145// obviously only the public key here!146stripePublishableKey: settings.stripe_publishable_key,147148// obviously only the public key here too!149reCaptchaKey: settings.re_captcha_v3_publishable_key,150151// a sandbox project152sandboxProjectId: settings.sandbox_project_id,153sandboxProjectsEnabled: settings.sandbox_projects_enabled,154155// true if openai integration is enabled -- this impacts the UI only, and can be156// turned on and off independently of whether there is an api key set.157openaiEnabled: settings.openai_enabled,158// same for google vertex (exposed as gemini), and others159googleVertexaiEnabled: settings.google_vertexai_enabled,160mistralEnabled: settings.mistral_enabled,161anthropicEnabled: settings.anthropic_enabled,162ollamaEnabled: settings.ollama_enabled,163164neuralSearchEnabled: settings.neural_search_enabled,165166// if extra Jupyter API functionality for sandboxed ephemeral code execution is available.167jupyterApiEnabled: settings.jupyter_api_enabled,168169computeServersEnabled: settings.compute_servers_enabled,170cloudFilesystemsEnabled: settings.cloud_filesystems_enabled,171172// GitHub proxy project173githubProjectId: settings.github_project_id,174175// public info about SSO strategies176strategies,177178verifyEmailAddresses: settings.verify_emails && settings.email_enabled,179};180181return cachedCustomize;182}183184185