1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Server: Link to Joplin Cloud signup page on login page

This commit is contained in:
Laurent Cozic 2021-09-19 18:45:16 +01:00
parent 9429b51694
commit d850eedd78
8 changed files with 22 additions and 17 deletions

View File

@ -90,14 +90,6 @@ async function main() {
const app = new Koa();
// app.use(async function responseTime(ctx:AppContext, next:Function) {
// const start = Date.now();
// await next();
// const ms = Date.now() - start;
// console.info('Response time', ms)
// //ctx.set('X-Response-Time', `${ms}ms`);
// });
// Note: the order of middlewares is important. For example, ownerHandler
// loads the user, which is then used by notificationHandler. And finally
// routeHandler uses data from both previous middlewares. It would be good to

View File

@ -10,6 +10,7 @@ export interface EnvVariables {
APP_BASE_URL?: string;
USER_CONTENT_BASE_URL?: string;
API_BASE_URL?: string;
JOPLINAPP_BASE_URL?: string;
APP_PORT?: string;
DB_CLIENT?: string;
@ -59,11 +60,15 @@ export function runningInDocker(): boolean {
return runningInDocker_;
}
function envParseBool(s: string): boolean {
function envReadString(s: string, defaultValue: string = ''): string {
return s === undefined || s === null ? defaultValue : s;
}
function envReadBool(s: string): boolean {
return s === '1';
}
function envParseInt(s: string, defaultValue: number = null): number {
function envReadInt(s: string, defaultValue: number = null): number {
if (!s) return defaultValue === null ? 0 : defaultValue;
const output = Number(s);
if (isNaN(output)) throw new Error(`Invalid number: ${s}`);
@ -89,8 +94,8 @@ function databaseConfigFromEnv(runningInDocker: boolean, env: EnvVariables): Dat
const baseConfig: DatabaseConfig = {
client: DatabaseConfigClient.Null,
name: '',
slowQueryLogEnabled: envParseBool(env.SLOW_QUERY_LOG_ENABLED),
slowQueryLogMinDuration: envParseInt(env.SLOW_QUERY_LOG_MIN_DURATION, 10000),
slowQueryLogEnabled: envReadBool(env.SLOW_QUERY_LOG_ENABLED),
slowQueryLogMinDuration: envReadInt(env.SLOW_QUERY_LOG_MIN_DURATION, 10000),
};
if (env.DB_CLIENT === 'pg') {
@ -187,6 +192,7 @@ export async function initConfig(envType: Env, env: EnvVariables, overrides: any
showErrorStackTraces: (env.ERROR_STACK_TRACES === undefined && envType === Env.Dev) || env.ERROR_STACK_TRACES === '1',
apiBaseUrl,
userContentBaseUrl: env.USER_CONTENT_BASE_URL ? env.USER_CONTENT_BASE_URL : baseUrl,
joplinAppBaseUrl: envReadString(env.JOPLINAPP_BASE_URL, 'https://joplinapp.org'),
signupEnabled: env.SIGNUP_ENABLED === '1',
termsEnabled: env.TERMS_ENABLED === '1',
accountTypesEnabled: env.ACCOUNT_TYPES_ENABLED === '1',

View File

@ -13,7 +13,7 @@ function makeView(error: any = null): View {
const view = defaultView('login', 'Login');
view.content = {
error,
signupUrl: config().signupEnabled ? makeUrl(UrlType.Signup) : '',
signupUrl: config().signupEnabled || config().isJoplinCloud ? makeUrl(UrlType.Signup) : '',
};
return view;
}

View File

@ -30,6 +30,7 @@ export interface View {
interface GlobalParams {
baseUrl?: string;
joplinAppBaseUrl?: string;
prefersDarkEnabled?: boolean;
notifications?: NotificationView[];
hasNotifications?: boolean;
@ -92,6 +93,7 @@ export default class MustacheService {
private get defaultLayoutOptions(): GlobalParams {
return {
baseUrl: config().baseUrl,
joplinAppBaseUrl: config().joplinAppBaseUrl,
prefersDarkEnabled: this.prefersDarkEnabled_,
appVersion: config().appVersion,
appName: config().appName,

View File

@ -1,4 +1,4 @@
import { baseUrl } from '../config';
import config, { baseUrl } from '../config';
import { Item, ItemAddressingType, Uuid } from '../services/database/types';
import { ErrorBadRequest, ErrorForbidden, ErrorNotFound } from './errors';
import Router from './Router';
@ -275,5 +275,9 @@ export enum UrlType {
}
export function makeUrl(urlType: UrlType): string {
return `${baseUrl(RouteType.Web)}/${urlType}`;
if (config().isJoplinCloud && urlType === UrlType.Signup) {
return `${config().joplinAppBaseUrl}/plans`;
} else {
return `${baseUrl(RouteType.Web)}/${urlType}`;
}
}

View File

@ -138,5 +138,5 @@ export function betaUserTrialPeriodDays(userCreatedTime: number, fromDateTime: n
}
export function betaStartSubUrl(email: string, accountType: AccountType): string {
return `https://joplinapp.org/plans/?email=${encodeURIComponent(email)}&account_type=${encodeURIComponent(accountType)}`;
return `${globalConfig().joplinAppBaseUrl}/plans/?email=${encodeURIComponent(email)}&account_type=${encodeURIComponent(accountType)}`;
}

View File

@ -101,6 +101,7 @@ export interface Config {
baseUrl: string;
apiBaseUrl: string;
userContentBaseUrl: string;
joplinAppBaseUrl: string;
signupEnabled: boolean;
termsEnabled: boolean;
accountTypesEnabled: boolean;

View File

@ -9,7 +9,7 @@
<h2 class="title">Welcome to {{global.appName}}</h2>
<div class="block readable-block">
<p class="block">To start using {{global.appName}}, make sure to <a href="https://joplinapp.org/download">download one of the Joplin applications</a>, either for desktop or for your mobile phone.</p>
<p class="block">To start using {{global.appName}}, make sure to <a href="{{{global.joplinAppBaseUrl}}}/download">download one of the Joplin applications</a>, either for desktop or for your mobile phone.</p>
<p class="block">Once the app is installed, open the <strong>Configuration</strong> screen, then the <strong>Synchronisation</strong> section. {{{setupMessageHtml}}}<p>
<p class="block">Once it is setup {{global.appName}} allows you to synchronise your devices, to publish notes, or to collaborate on notebooks with other {{global.appName}} users.</p>
</div>