Skip to content

Commit c04a4c5

Browse files
committed
nodejs12: move BASE_URL to misc/ and use it in frame-tree/print
1 parent 43b0951 commit c04a4c5

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/smc-webapp/frame-editors/frame-tree/print.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { HTML } from "smc-webapp/r_misc";
1414
//import ReactDOMServer from "react-dom/server";
1515
const ReactDOMServer = require("react-dom/server");
1616
import { React, Redux, redux } from "../../app-framework";
17-
const misc_page = require("../../misc_page");
17+
import { BASE_URL } from "../../misc/base-url";
1818
import { resource_links_string } from "smc-webapp/misc/resource-links";
1919

2020
let BLOCKED: boolean | undefined = undefined;
@@ -106,8 +106,7 @@ function write_content(w, opts: PrintOptions): void {
106106
}
107107

108108
function html_with_deps(html: string, title: string): string {
109-
const BASE_URL = misc_page.BASE_URL;
110-
const links = resource_links_string(BASE_URL)
109+
const links = resource_links_string(BASE_URL);
111110
return `\
112111
<html lang="en">
113112
<head>

src/smc-webapp/misc/base-url.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3+
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
4+
*/
5+
6+
import { DOMAIN_NAME } from "../../smc-util/theme";
7+
import { join } from "path";
8+
9+
export const APP_BASE_URL =
10+
window != null && window.app_base_url != null ? window.app_base_url : "";
11+
12+
const BASE_PATH = join(window.location.hostname, APP_BASE_URL);
13+
export const BASE_URL =
14+
window != null ? `${window.location.protocol}//${BASE_PATH}` : DOMAIN_NAME;

src/smc-webapp/misc_page.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ exports.is_enter = (e) -> e.which is 13 and not e.shiftKey
6161
exports.is_ctrl_enter = (e) -> e.which is 13 and e.ctrlKey
6262
exports.is_escape = (e) -> e.which is 27
6363

64-
{join} = require('path')
65-
exports.APP_BASE_URL = window?.app_base_url ? ''
66-
exports.BASE_URL = if window? then "#{window.location.protocol}//#{join(window.location.hostname, window.app_base_url ? '')}" else theme.DOMAIN_NAME
64+
base_url_lib = require("./misc/base-url")
65+
exports.APP_BASE_URL = exports.APP_BASE_URL
66+
exports.BASE_URL = exports.BASE_URL
6767

6868
local_diff = exports.local_diff = (before, after) ->
6969
# Return object

0 commit comments

Comments
 (0)