Skip to content

Commit

Permalink
API Update. See CHANGELOG.md.
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Lesieur <bruno.lesieur@gmail.com>
  • Loading branch information
MachinisteWeb committed Dec 21, 2016
1 parent 79764d3 commit 8c66044
Show file tree
Hide file tree
Showing 28 changed files with 349 additions and 267 deletions.
27 changes: 17 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Features:

- Gitter Chat for both fr (Aide) and en (Help) language: `https://gitter.im/NodeAtlas/`.
- `NA#currentVariation.urlRootPath` is added (same as `NA#webconfig.urlRoot`).
- `NA#currentVariation.urlSubPath` is added (same as `NA#webconfig.urlRelativeSubPath`).
- `NA#currentVariation.urlFilePath` is added.
- `NA#currentVariation.urlPath` is added.
- `NA#variations.urlRootPath` is added (same as `NA#webconfig.urlRoot`).
- `NA#variations.urlSubPath` is added (same as `NA#webconfig.urlRelativeSubPath`).
- `NA#variations.urlFilePath` is added.
- `NA#variations.urlPath` is added.
- `NA#webconfig.mimeType` is added.
- `NA#webconfig.charset` is added.
- `NA#webconfig.headers` is added.
Expand All @@ -19,15 +19,20 @@ Features:

Updates:

- `NA#appLanguage` become `NA#cliLanguage`.
- `NA#appLabels` become `NA#cliLabels`.
- `NA#websiteController[]` become `NA#controllers[]`.
- `NA#websiteController[].changeVariation` become `NA#controllers[].changeVariations`.
- `NA#changeVariationCommon` become `NA#changeVariationsCommon`.
- `NA#changeVariationSpecific` become `NA#changeVariationsSpecific`.
- `NA#currentVariation` become `NA#variations`.
- `NA#currentRouteParameters` become `NA#routeParameters`.
- `NA#currentVariation.currentRoute` become `NA#currentVariation.route`.
- `NA#currentVariation.currentRouteParameters` become `NA#currentVariation.routeParameters`.
- `NA#currentVariation.currentRouteName` become `NA#currentVariation.routePath`.
- `NA#variations.currentRoute` become `NA#variations.route`.
- `NA#variations.currentRouteParameters` become `NA#variations.routeParameters`.
- `NA#variations.currentRouteName` become `NA#variations.routePath`.
- `NA#webconfig.urlWithoutFileName` become `NA#webconfig.urlRoot`.
- `NA#currentVariation.urlBasePathSlice` removed.
- `NA#currentVariation.urlBasePath` become `NA#webconfig.urlRoot + NA#webconfig.urlRelativeSubPath` (without ending "/").
- `NA#variations.urlBasePathSlice` removed.
- `NA#variations.urlBasePath` become `NA#webconfig.urlRoot + NA#webconfig.urlRelativeSubPath` (without ending "/").
- `NA#afterGenerates` become `NA#afterGeneration`.
- `NA#webconfig.generatesRelativePath` become `NA#webconfig.serverlessRelativePath`.
- `NA#webconfig.serverlessRelativePath` default value become `"serverless"`.
Expand All @@ -51,12 +56,14 @@ Updates:
- EJS engine become ATLAS engine and `<% %>` become `<? ?>`.
- `NA#webconfig.componentsRelativePath` removed.
- `NA#webconfig.viewsRelativePath` replace removed `NA#webconfig.componentsRelativePath`.
- `NA#webconfig.viewsRelativePath` replace removed `NA#webconfig.componentsRelativePath`.

Removed:

- `NA#modulesRequired` and `NA#downloadAllModules` removed. Use `npm install` manually instead if you download package manually.
- Original `NA#variations` removed.
- `NA#templateEngineConfiguration` removed.
- `NA#controllers[].changeVariations(params.variation...` become `NA#controllers[].changeVariations(params.variations...`
- `NA#controllers[].changeDom(params.variation...` become `NA#controllers[].changeVariations(params.variations...`



Expand Down
4 changes: 2 additions & 2 deletions bin/node-atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ NA = function () {
this.prepareRenderPath = frontEndPart.prepareRenderPath;
this.prepareRenderVariation = frontEndPart.prepareRenderVariation;
this.prepareRenderParameters = frontEndPart.prepareRenderParameters;
this.changeVariationCommon = frontEndPart.changeVariationCommon;
this.changeVariationSpecific = frontEndPart.changeVariationSpecific;
this.changeVariationsCommon = frontEndPart.changeVariationsCommon;
this.changeVariationsSpecific = frontEndPart.changeVariationsSpecific;
this.changeDomCommon = frontEndPart.changeDomCommon;
this.changeDomSpecific = frontEndPart.changeDomSpecific;
this.intoBrowserAndFiles = frontEndPart.intoBrowserAndFiles;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @requires {@link NA#modules.external:mkpath}
* @requires {@link NA#modules.external:open}
* @requires {@link NA#modules.external:pug}
* @requires {@link NA#modules.external:socket.io}
* @requires {@link NA#modules.external:socketio}
* @requires {@link NA#modules.external:stylus}
* @requires {@link NA#modules.external:traverse-directory}
* @requires {@link NA#modules.external:uglify-js}
Expand Down
18 changes: 9 additions & 9 deletions lib/assets-generation.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ exports.urlGeneratingPages = function () {
});
} else {
data.templatePath = path.join(NA.serverPath, NA.webconfig.serverlessRelativePath);
NA.log(NA.appLabels.templateDirectoryNotExist.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
NA.log(NA.cliLabels.templateDirectoryNotExist.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
}
});
}
Expand Down Expand Up @@ -91,7 +91,7 @@ exports.urlGeneratingAssets = function () {
});

traverse.on('complete', function () {
NA.log(NA.appLabels.assetsCopy);
NA.log(NA.cliLabels.assetsCopy);
if (NA.afterGeneration) {
NA.afterGeneration();
}
Expand Down Expand Up @@ -157,12 +157,12 @@ exports.emulatedIndexPage = function () {

data.page = decodeURIComponent(data.page);

data.render += NA.appLabels.emulatedIndexPage.line.replace(/%([\-a-zA-Z0-9_]+)%/g, matches);
data.render += NA.cliLabels.emulatedIndexPage.line.replace(/%([\-a-zA-Z0-9_]+)%/g, matches);
});

/* ...and provide a page. */
response.writeHead(200, NA.appLabels.emulatedIndexPage.charsetAndType);
response.write(NA.appLabels.emulatedIndexPage.data.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
response.writeHead(200, NA.cliLabels.emulatedIndexPage.charsetAndType);
response.write(NA.cliLabels.emulatedIndexPage.data.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
response.end();
});

Expand Down Expand Up @@ -240,12 +240,12 @@ exports.saveTemplateRender = function (data, templateRenderName) {
fs.writeFile(pathToSaveFileComplete, innerHTML, function (error) {
if (error) {
if (error.code === 'EISDIR' || error.code === 'ENOENT') {
NA.log(NA.appLabels.templateNotGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return dataError[matches]; }));
NA.log(NA.cliLabels.templateNotGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return dataError[matches]; }));
} else {
throw error;
}
} else {
NA.log(NA.appLabels.templateGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return dataError[matches]; }));
NA.log(NA.cliLabels.templateGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return dataError[matches]; }));
}
});

Expand Down Expand Up @@ -290,7 +290,7 @@ exports.generateStartingProject = function (fallback) {

traverse.on('complete', function () {
data.pathName = sourcePath;
NA.log(NA.appLabels.initCopy.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
NA.log(NA.cliLabels.initCopy.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
if (NA.afterNewProject) {
NA.afterNewProject();
}
Expand All @@ -299,7 +299,7 @@ exports.generateStartingProject = function (fallback) {
traverse.run();
} else {
data.initPath = source;
NA.log(NA.appLabels.initNotFound.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
NA.log(NA.cliLabels.initNotFound.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
}
} else {

Expand Down
29 changes: 21 additions & 8 deletions lib/back-end-part.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ exports.lessCompilation = function (callback) {

data.pathName = path.join(NA.serverPath, NA.webconfig.assetsRelativePath, compiledFile.replace(/\.less$/g,'.css'));
fs.writeFileSync(path.join(NA.serverPath, NA.webconfig.assetsRelativePath, compiledFile.replace(/\.less$/g,'.css')), output.css);
NA.log(NA.appLabels.lessGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
NA.log(NA.cliLabels.lessGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
next();
});
}, function () {
Expand Down Expand Up @@ -318,7 +318,7 @@ exports.stylusCompilation = function (callback) {

data.pathName = path.join(NA.serverPath, NA.webconfig.assetsRelativePath, compiledFile.replace(/\.styl$/g,'.css'));
fs.writeFileSync(path.join(NA.serverPath, NA.webconfig.assetsRelativePath, compiledFile.replace(/\.styl$/g,'.css')), output);
NA.log(NA.appLabels.stylusGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
NA.log(NA.cliLabels.stylusGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
next();
});
}, function () {
Expand Down Expand Up @@ -403,11 +403,11 @@ exports.cssMinification = function (callback) {
for (var i = 0; i < results.length; i++) {
output += results[i];
}

output = (new cleanCss().minify(output)).styles;
fs.writeFileSync(path.join(NA.serverPath, NA.webconfig.assetsRelativePath, compressedFile), output);
data.pathName = path.join(NA.serverPath, NA.webconfig.assetsRelativePath, compressedFile);
NA.log(NA.appLabels.cssGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
NA.log(NA.cliLabels.cssGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
output = "";

firstCallback();
Expand Down Expand Up @@ -497,7 +497,7 @@ exports.imgOptimization = function (callback) {
] }).then(function () {
data.pathName = path.normalize(source);

NA.log(NA.appLabels.imgGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
NA.log(NA.cliLabels.imgGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));

firstCallback();
});
Expand Down Expand Up @@ -573,15 +573,28 @@ exports.jsObfuscation = function (callback) {
async.each(allJsMinified, function (compressedFile, firstCallback) {

async.map(bundles.javascript[compressedFile], function (sourceFile, secondCallback) {
secondCallback(null, uglifyJs.minify(path.join(NA.serverPath, NA.webconfig.assetsRelativePath, sourceFile)).code);
var code,
file;
/* For the NA.socket and NA.io auto configuration. */
if (path.join("/", NA.webconfig.urlSocketsFile) === path.join("/", sourceFile)) {
file = fs.readFileSync(path.join(NA.nodeatlasPath, "src", "socket.io.js"), "utf-8")
.replace(/%urlRelativeSubPath%/g, NA.webconfig.urlRelativeSubPath.slice(1))
.replace(/%urlRoot%/g, NA.webconfig.urlRoot);

code = uglifyJs.minify(file, {fromString: true}).code;
/* And for others real files. */
} else {
code = uglifyJs.minify(path.join(NA.serverPath, NA.webconfig.assetsRelativePath, sourceFile)).code;
}
secondCallback(null, code);
}, function(error, results) {
for (var i = 0; i < results.length; i++) {
output += results[i];
}

fs.writeFileSync(path.join(NA.serverPath, NA.webconfig.assetsRelativePath, compressedFile), output);
data.pathName = path.join(NA.serverPath, NA.webconfig.assetsRelativePath, compressedFile);
NA.log(NA.appLabels.jsGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
NA.log(NA.cliLabels.jsGenerate.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return data[matches]; }));
output = "";

firstCallback();
Expand Down Expand Up @@ -684,7 +697,7 @@ exports.loadController = function (controller, callback) {
} catch (err) {
if (err && err.code === 'MODULE_NOT_FOUND') {
err.controller = commonControllerPath;
return NA.log(NA.appLabels.notFound.controller.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return err[matches]; }));
return NA.log(NA.cliLabels.notFound.controller.replace(/%([\-a-zA-Z0-9_]+)%/g, function (regex, matches) { return err[matches]; }));
} else if (err) {
return NA.log(err);
}
Expand Down
44 changes: 27 additions & 17 deletions lib/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ exports.lineCommandConfiguration = function () {
.version("2.0.0")

/* Automaticly run default browser with `--browse` options. If a param is setted, the param is added to the and of url. */
.option(NA.appLabels.commander.browse.command, NA.appLabels.commander.browse.description, String)
.option(NA.cliLabels.commander.browse.command, NA.cliLabels.commander.browse.description, String)

/* Target the directory in which website and NodeAtlas will be running. */
.option(NA.appLabels.commander.directory.command, NA.appLabels.commander.directory.description, String)
.option(NA.cliLabels.commander.directory.command, NA.cliLabels.commander.directory.description, String)

/* Change name of JSON file used as the webconfig file. */
.option(NA.appLabels.commander.webconfig.command, NA.appLabels.commander.webconfig.description, String)
.option(NA.cliLabels.commander.webconfig.command, NA.cliLabels.commander.webconfig.description, String)

/* Change the hostname that runs the NodeAtlas website. */
.option(NA.appLabels.commander.httpHostname.command, NA.appLabels.commander.httpHostname.description, String)
.option(NA.cliLabels.commander.httpHostname.command, NA.cliLabels.commander.httpHostname.description, String)

/* Change the port that runs the NodeAtlas website. */
.option(NA.appLabels.commander.httpPort.command, NA.appLabels.commander.httpPort.description, String)
.option(NA.cliLabels.commander.httpPort.command, NA.cliLabels.commander.httpPort.description, String)

/* Minify all files and re-create all HTML assets into generates folder. */
.option(NA.appLabels.commander.generate.command, NA.appLabels.commander.generate.description)
.option(NA.cliLabels.commander.generate.command, NA.cliLabels.commander.generate.description)

/* Avoid cache at all levels (Server, Template Engine...). */
.option(NA.appLabels.commander.cache.command, NA.appLabels.commander.cache.description)
.option(NA.cliLabels.commander.cache.command, NA.cliLabels.commander.cache.description)

/* Copy all data from `test/<project-name>` from NodeAtlas package to current directory. */
.option(NA.appLabels.commander.create.command, NA.appLabels.commander.create.description)
.option(NA.cliLabels.commander.create.command, NA.cliLabels.commander.create.description)

/* Start the server with HTTPs Protocol. */
.option(NA.appLabels.commander.httpSecure.command, NA.appLabels.commander.httpSecure.description)
.option(NA.cliLabels.commander.httpSecure.command, NA.cliLabels.commander.httpSecure.description)

/* Change language used by NodeAtlas. */
.option(NA.appLabels.commander.lang.command, NA.appLabels.commander.lang.description)
.option(NA.cliLabels.commander.lang.command, NA.cliLabels.commander.lang.description)
.parse(process.argv);

/* `generate` manually setted value with `--generate`. */
Expand Down Expand Up @@ -93,12 +93,12 @@ exports.initGlobalVar = function () {
/**
* Name of file which contains language error messages. The name of file is without extension.
* @public
* @alias appLanguage
* @alias cliLanguage
* @type {String}
* @memberOf NA#
* @default "default"
*/
NA.appLanguage = 'default';
NA.cliLanguage = 'default';

/**
* OS absolute path which contains NodeAtlas folders and files.
Expand All @@ -111,13 +111,13 @@ exports.initGlobalVar = function () {
NA.nodeatlasPath = path.join(__dirname, "..");

/**
* All internationalize labels from `NA#appLanguage` file.
* All internationalize labels from `NA#cliLanguage` file.
* @public
* @alias appLabels
* @alias cliLabels
* @type {Object}
* @memberOf NA#
*/
NA.appLabels = require('../languages/' + NA.appLanguage + '.json');
NA.cliLabels = require('../languages/' + NA.cliLanguage + '.json');

/**
* Contain all functions of controllers both common and specific.
Expand All @@ -132,12 +132,12 @@ exports.initGlobalVar = function () {
* NA.controllers["common.json"].setSockets(...);
* NA.controllers["common.json"].setConfigurations(...);
* NA.controllers["common.json"].setRoutes(...);
* NA.controllers["common.json"].changeVariation(...);
* NA.controllers["common.json"].changeVariations(...);
* NA.controllers["common.json"].changeDom(...);
*
* // Functions for specific controller if a route `controller` value is "index.json".
* NA.controllers["index.json"].setSockets(...);
* NA.controllers["index.json"].changeVariation(...);
* NA.controllers["index.json"].changeVariations(...);
* NA.controllers["index.json"].changeDom(...);
*/
NA.controllers = [];
Expand Down Expand Up @@ -649,6 +649,16 @@ exports.improveWebconfigBase = function () {
*/
ejs.delimiter = NA.webconfig.templateEngineDelimiter || "?";

/**
* Deliver the client-side window.NA.socket and window.NA.io object.
* @public
* @alias urlSocketsFile
* @type {string}
* @memberOf NA#webconfig
* @default "/node-atlas/socket.io.js"
*/
NA.webconfig.urlSocketsFile = (NA.webconfig.urlSocketsFile === false) ? false : (NA.webconfig.urlSocketsFile || "/node-atlas/socket.io.js");

/**
* Default Content Type used for all pages.
* @public
Expand Down
Loading

0 comments on commit 8c66044

Please sign in to comment.