Skip to content

Commit

Permalink
added config option tutorials_root_url
Browse files Browse the repository at this point in the history
  • Loading branch information
pmgl committed Oct 27, 2022
1 parent f19ce01 commit 689608e
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 201 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@ You can clone this repository and start your own microStudio server, for a team

For active development use:
* `npm run dev` instead of `npm start`

### Configuration
To use specific configuration options, create a JSON file `config.json` in the root folder (same folder as this README.md).
You can find partial examples in this folder as config_local.json and config_prod.json.

#### Configuration options

|option|description|
|-|-|
|realm|`"local"` or `"production"`|
|run_domain|The run domain if you are running this in production ; must include protocol (e.g. `"https://microstudio.io"`)|
|dev_domain|The dev domain if you are running this in production ; must include protocol (e.g. `"https://microstudio.dev"`)|
|delegate_relay_service|set to true if you are running a separate relay server for the microStudio Networking features|
|relay-key|a secret key to use with the delegated relay service|
|default_project_language|The default language selected when a user creates a project. Can be set to `"microscript_v2"` (default), `"microscript"`, `"javascript"`, `"lua"` or `"python"`|
|tutorials_root_url|Sets a different URL for loading your own set of tutorials (note: if you use this option, in the toc.md, you must specify a complete URL with domain name for each tutorial)|
4 changes: 2 additions & 2 deletions config_prod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"realm": "production",
"dev-domain": "yourdevdomain.com",
"run-domain": "youroutputdomain.com",
"dev_domain": "yourdevdomain.com",
"run_domain": "youroutputdomain.com",
"backup-key": "your_backup_service_key",
"builder-key": "your_builder_service_key",
"relay-key": "your_relay_key"
Expand Down
2 changes: 2 additions & 0 deletions server/webapp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class @WebApp
dev_domain: dev_domain
run_domain: run_domain
default_project_language: @server.config.default_project_language
tutorials_root_url: @server.config.tutorials_root_url

return res.send page
else if not @home_page[lang]? or not @server.use_cache
Expand All @@ -138,6 +139,7 @@ class @WebApp
dev_domain: dev_domain
run_domain: run_domain
default_project_language: @server.config.default_project_language
tutorials_root_url: @server.config.tutorials_root_url

res.send @home_page[lang]

Expand Down
6 changes: 4 additions & 2 deletions server/webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ this.WebApp = class WebApp {
project_moderation: this.server.config.project_moderation === true,
dev_domain: dev_domain,
run_domain: run_domain,
default_project_language: this.server.config.default_project_language
default_project_language: this.server.config.default_project_language,
tutorials_root_url: this.server.config.tutorials_root_url
});
return res.send(page);
} else if ((this.home_page[lang] == null) || !this.server.use_cache) {
Expand All @@ -150,7 +151,8 @@ this.WebApp = class WebApp {
project_moderation: this.server.config.project_moderation === true,
dev_domain: dev_domain,
run_domain: run_domain,
default_project_language: this.server.config.default_project_language
default_project_language: this.server.config.default_project_language,
tutorials_root_url: this.server.config.tutorials_root_url
});
}
return res.send(this.home_page[lang]);
Expand Down
10 changes: 6 additions & 4 deletions static/js/tutorial/tutorials.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ class @Tutorials
if req.status == 200
@update(req.responseText)

origin = window.ms_tutorials_root_url or location.origin+"/tutorials/"

switch @app.translator.lang
when "fr"
req.open "GET",location.origin+"/tutorials/fr/toc.md"
req.open "GET",origin+"fr/toc.md"
when "it"
req.open "GET",location.origin+"/tutorials/it/toc.md"
req.open "GET",origin+"it/toc.md"
when "pt"
req.open "GET",location.origin+"/tutorials/pt/toc.md"
req.open "GET",origin+"pt/toc.md"
else
req.open "GET",location.origin+"/tutorials/en/toc.md"
req.open "GET",origin+"en/toc.md"

req.send()

Expand Down
Loading

0 comments on commit 689608e

Please sign in to comment.