Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,7 +69,7 @@ Windows, Unix systems and macOS are supported. For Windows, you'll need to call

Wait a bit while it reads the tutorial from the disk and builds static assets.

Then access the site at `http://127.0.0.1:3000`.
Then access the site at `http://127.0.0.1:3000`. **[Change Server Port](#change-server-port)**

7. Edit the tutorial

Expand All@@ -92,6 +92,14 @@ cd /js/server

Please note, the server must support that language. There must be corresponding locale files for that language in the code of the server, otherwise it exists with an error. As of now, `ru`, `en`, `zh`, `tr` and `ja` are fully supported.


# Change Server Port

The server uses port `3000` by default.

In case, if you want to change the port, you can change it by editing `PORT` in `/js/server/modules/config/index.js`


# Translating images

Most pictures are in SVG format. Strings inside it are usually just text, they can be replaced.
Expand DownExpand Up@@ -210,6 +218,7 @@ If it still doesn't work – [file an issue](https://github.com/javascript-tutor

Please pull the very latest git code and install latest NPM modules before publishing an issue.


--
Yours,
Ilya Kantor
Expand Down
41 changes: 21 additions & 20 deletions modules/config/index.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ let path = require('path');
let fs = require('fs-extra');
let yaml = require('js-yaml');
let env = process.env;
const PORT = 3000;

// NODE_ENV = development || test || production
env.NODE_ENV = env.NODE_ENV || 'development'
Expand All@@ -21,46 +22,46 @@ if (env.DEV_TRACE){
let config = module.exports ={
urlBase:{
// node may be behind nginx, use this in documents
main: new URL(env.URL_BASE_MAIN || env.URL_BASE || 'http://localhost:3000'),
static: new URL(env.URL_BASE_STATIC || env.URL_BASE || 'http://localhost:3000'),
main: new URL(env.URL_BASE_MAIN || env.URL_BASE || `http://localhost:${PORT}`),
static: new URL(env.URL_BASE_STATIC || env.URL_BASE || `http://localhost:${PORT}`),
},
urlBaseProduction:{
// when even in dev mode we must reference prod, use this (maybe remove it?)
main: new URL(env.URL_BASE_PRODUCTION_MAIN || env.URL_BASE || 'http://localhost:3000'),
static: new URL(env.URL_BASE_PRODUCTION_STATIC || env.URL_BASE || 'http://localhost:3000')
main: new URL(env.URL_BASE_PRODUCTION_MAIN || env.URL_BASE || `http://localhost:${PORT}`),
static: new URL(env.URL_BASE_PRODUCTION_STATIC || env.URL_BASE || `http://localhost:${PORT}`)
},

server:{
port: env.PORT || 3000,
port: env.PORT || PORT,
host: env.HOST || 'localhost'
},

appKeys: [secret.sessionKey],
appKeys: [secret.sessionKey],
adminKey: secret.adminKey,

lang: lang,
lang: lang,

plnkrAuthId: secret.plnkrAuthId,

assetVersioning: env.ASSET_VERSIONING === 'file' ? 'file' :
env.ASSET_VERSIONING === 'query' ? 'query' : null,
env.ASSET_VERSIONING === 'query' ? 'query' : null,

pug: {
pug:{
basedir: path.join(process.cwd(), 'templates'),
cache: env.NODE_ENV !== 'development'
cache: env.NODE_ENV !== 'development'
},

supportEmail: '[email protected]',

projectRoot: process.cwd(),
projectRoot: process.cwd(),
// public files, served by nginx
publicRoot: path.join(process.cwd(), 'public', lang),
publicRoot: path.join(process.cwd(), 'public', lang),
// private files, for expiring links, not directly accessible
tutorialRoot: env.TUTORIAL_ROOT || path.join(process.cwd(), '..', lang + '.javascript.info'),
tmpRoot: path.join(process.cwd(), 'tmp', lang),
tutorialRoot: env.TUTORIAL_ROOT || path.join(process.cwd(), '..', lang + '.javascript.info'),
tmpRoot: path.join(process.cwd(), 'tmp', lang),
// js/css build versions
cacheRoot: path.join(process.cwd(), 'cache', lang),
assetsRoot: path.join(process.cwd(), 'assets'),
cacheRoot: path.join(process.cwd(), 'cache', lang),
assetsRoot: path.join(process.cwd(), 'assets'),

handlers: require('./handlers')
};
Expand All@@ -69,13 +70,13 @@ let repo = `javascript-tutorial/${config.lang}.javascript.info`;

config.tutorialRepo ={
github: repo,
url: new URL('https://github.com/' + repo),
tree: new URL('https://github.com/' + repo + '/tree/master'),
blob: new URL('https://github.com/' + repo + '/blob/master')
url: new URL('https://github.com/' + repo),
tree: new URL('https://github.com/' + repo + '/tree/master'),
blob: new URL('https://github.com/' + repo + '/blob/master')
};


require.extensions['.yml'] = function(module, filename){
require.extensions['.yml'] = function(module, filename){
module.exports = yaml.safeLoad(fs.readFileSync(filename, 'utf-8'));
};

Expand Down