Skip to content

Commit 7f9122c

Browse files
authored
static page support for modules (source-academy#1098)
Add modules repository as a submodule and change the module backend URL according to the .env file.
1 parent 4cc8f2d commit 7f9122c

File tree

8 files changed

+28
-10
lines changed

8 files changed

+28
-10
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ REACT_APP_LUMINUS_CLIENT_ID=your_luminus_client_id_here
22
REACT_APP_VERSION=$npm_package_version
33
REACT_APP_BACKEND_URL=http://localhost:4001
44
REACT_APP_USE_BACKEND=TRUE
5-
REACT_APP_CHATKIT_INSTANCE_LOCATOR=instance_locator_here_otherwise_empty_string
5+
REACT_APP_CHATKIT_INSTANCE_LOCATOR=instance_locator_here_otherwise_empty_string
6+
7+
MODULE_BACKEND_URL=http://ec2-54-169-81-133.ap-southeast-1.compute.amazonaws.com

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "public/modules"]
2+
path = public/modules
3+
url = https://github.com/source-academy/modules.git

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"draft-js": "^0.10.5",
4848
"flexboxgrid": "^6.3.1",
4949
"flexboxgrid-helpers": "^1.1.3",
50-
"js-slang": "^0.4.44",
50+
"js-slang": "^0.4.45",
5151
"jwt-decode": "^2.2.0",
5252
"lodash": "^4.17.15",
5353
"lz-string": "^1.4.4",

public/modules

Submodule modules added at cf6ae63

src/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import { setBackendStaticURL } from 'js-slang/dist/modules/moduleLoader';
2+
13
import * as React from 'react';
24
import { render } from 'react-dom';
35
import { Provider } from 'react-redux';
46
import { ConnectedRouter } from 'react-router-redux';
57

68
import ApplicationContainer from './containers/ApplicationContainer';
79
import { store } from './createStore';
8-
import { LINKS, SOURCE_ACADEMY_VERSION } from './utils/constants';
10+
import { LINKS, MODULE_BACKEND_URL, SOURCE_ACADEMY_VERSION } from './utils/constants';
911
import { history } from './utils/history';
1012
import registerServiceWorker from './utils/registerServiceWorker';
1113

@@ -20,6 +22,10 @@ console.log(
2022
'font-weight: bold;'
2123
);
2224

25+
setBackendStaticURL(MODULE_BACKEND_URL);
26+
// tslint:disable-next-line
27+
console.log(`Using module backend: ${MODULE_BACKEND_URL}`);
28+
2329
render(
2430
<Provider store={store}>
2531
<ConnectedRouter history={history}>

src/utils/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export const INSTANCE_LOCATOR = process.env.REACT_APP_CHATKIT_INSTANCE_LOCATOR;
1616
export const DEFAULT_SOURCE_CHAPTER = 4;
1717
export const DEFAULT_SOURCE_VARIANT = 'default';
1818

19+
export const MODULE_BACKEND_URL =
20+
process.env.MODULE_BACKEND_URL === undefined || process.env.MODULE_BACKEND_URL === ''
21+
? 'modules'
22+
: process.env.MODULE_BACKEND_URL;
23+
1924
export enum LINKS {
2025
GITHUB_ISSUES = 'https://github.com/source-academy/cadet-frontend/issues',
2126
GITHUB_ORG = 'https://github.com/source-academy',

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"exclude": [
2222
"node_modules",
2323
"public/externalLibs",
24+
"public/modules",
2425
"build",
2526
"scripts",
2627
"acceptance-tests",

0 commit comments

Comments
 (0)