diff --git a/build.js b/build.js index 26ef98a..3b782a4 100644 --- a/build.js +++ b/build.js @@ -11,36 +11,57 @@ const argument0 = process.argv[2]; async function main(runMode) { const angularSourceBuffer = fs.readFileSync("buildconfig.json"); const angularSource = JSON.parse(angularSourceBuffer); + const generalConfiguration = angularSource.angular.projects[angularSource.projectName].architect.build.options; + angularSource.angular.projects[angularSource.projectName].architect.build.options = {}; const productionConfiguration = angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production"]; delete angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production"]; + angularSource.languages.forEach((language, languageIndex) => { - const defaultIndex = angularSource.angular.projects[angularSource.projectName].architect.build.options.index; + const defaultIndex = generalConfiguration.index; const defaultIndexName = defaultIndex.split(".").slice(0, -1).join("."); const defaultIndexExtension = defaultIndex.split(".").pop(); const languageSpecificIndex = defaultIndexName + "." + language + ".generated." + defaultIndexExtension; const languageConfiguration = { - "index": languageSpecificIndex, ...angularSource.angular.projects[angularSource.projectName].architect.build.configurations[language] }; delete angularSource.angular.projects[angularSource.projectName].architect.build.configurations[language]; angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production_" + language] = { + ...generalConfiguration, ...productionConfiguration, ...languageConfiguration }; + angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production_" + language].fileReplacements = [ + { + "replace": defaultIndex, + "with": languageSpecificIndex + }, + ...angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production_" + language].fileReplacements + ]; + resolvePaths(angularSource.angular.projects[angularSource.projectName].architect.build.configurations["production_" + language], "assets", language); + angularSource.angular.projects[angularSource.projectName].architect.build.configurations["serve_" + language] = { - "aot": true, + ...generalConfiguration, ...languageConfiguration, + "aot": true, }; + if (angularSource.angular.projects[angularSource.projectName].architect.build.configurations["serve_" + language].fileReplacements === undefined) { + angularSource.angular.projects[angularSource.projectName].architect.build.configurations["serve_" + language].fileReplacements = []; + } + angularSource.angular.projects[angularSource.projectName].architect.build.configurations["serve_" + language].fileReplacements.push({ + "replace": defaultIndex, + "with": languageSpecificIndex + }); angularSource.angular.projects[angularSource.projectName].architect.serve.configurations[language] = { "browserTarget": "cavallium-website:build:serve_"+language, "port": 4200 + languageIndex }; + resolvePaths(angularSource.angular.projects[angularSource.projectName].architect.build.configurations["serve_" + language], "assets", language); // Create index.language.html let indexText = fs.readFileSync(defaultIndex).toString("utf8"); - indexText = indexText.replace("", ""); + indexText = indexText.replace("generate=\"language_attribute\"", "lang=\"" + language + "\""); fs.writeFileSync(languageSpecificIndex, indexText); }); @@ -60,7 +81,14 @@ async function main(runMode) { case "serve": await Promise.all(angularSource.languages.map((language, index) => { console.log("Building for language " + JSON.stringify(language) + (index > 0 ? " (hidden)" : "")); - const childProcess = spawn("ng", ["serve", "--configuration=" + language, "--host=0.0.0.0"], + const arguments = ["serve", "--configuration=" + language]; + if (angularSource.localIpAddress) { + arguments.push("--host=" + angularSource.localIpAddress); + } + if (angularSource.disableHostCheck) { + arguments.push("--disable-host-check"); + } + const childProcess = spawn("ng", arguments, { stdio: [process.stdin, index == 0 ? process.stdout : null, process.stderr] }); return onExit(childProcess); })); @@ -85,4 +113,14 @@ function onExit(childProcess) { reject(err); }); }); +} + +function resolvePaths(obj, elem, language) { + if (obj !== undefined && obj[elem] !== undefined && Array.isArray(obj[elem])) { + obj[elem] = obj[elem].map((asset) => typeof asset === "string" ? asset.replace("_GENERATED_LANGUAGE_", language) : { + "glob": asset.glob.replace("_GENERATED_LANGUAGE_", language), + "input": asset.input.replace("_GENERATED_LANGUAGE_", language), + "output": asset.output.replace("_GENERATED_LANGUAGE_", language) + }); + } } \ No newline at end of file diff --git a/buildconfig.json b/buildconfig.json index a0c3d7c..64918ea 100644 --- a/buildconfig.json +++ b/buildconfig.json @@ -2,6 +2,8 @@ "version": 1, "projectName": "cavallium-website", "languages": ["it", "en"], + "localIpAddress": "0.0.0.0", + "disableHostCheck": true, "angular": { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, @@ -28,7 +30,8 @@ "tsConfig": "src/tsconfig.app.json", "assets": [ "src/favicon.ico", - "src/assets" + "src/assets", + "src/documents" ], "styles": [ "src/styles.scss", @@ -86,7 +89,7 @@ "browserTarget": "cavallium-website:build:production" }, "en": { - "browserTarget": "my-project:build:it" + "browserTarget": "my-project:build:en" }, "it": { "browserTarget": "my-project:build:it" @@ -113,7 +116,8 @@ "scripts": [], "assets": [ "src/favicon.ico", - "src/assets" + "src/assets", + "src/documents" ] } }, diff --git a/package-lock.json b/package-lock.json index 8cb5072..a3a2c24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -673,6 +673,11 @@ "@types/jasmine": "*" } }, + "@types/marked": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@types/marked/-/marked-0.6.5.tgz", + "integrity": "sha512-6kBKf64aVfx93UJrcyEZ+OBM5nGv4RLsI6sR1Ar34bpgvGVRoyTgpxn4ZmtxOM5aDTAaaznYuYUH8bUX3Nk3YA==" + }, "@types/node": { "version": "8.9.5", "resolved": "https://registry.npmjs.org/@types/node/-/node-8.9.5.tgz", @@ -2028,6 +2033,17 @@ "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, + "clipboard": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.4.tgz", + "integrity": "sha512-Vw26VSLRpJfBofiVaFb/I8PVfdI1OxKcYShe6fm0sP/DtmiWQNCjhM/okTvdCo0G+lMMm1rMYbk4IK4x1X+kgQ==", + "optional": true, + "requires": { + "good-listener": "^1.2.2", + "select": "^1.1.2", + "tiny-emitter": "^2.0.0" + } + }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", @@ -2661,6 +2677,12 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, + "delegate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz", + "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==", + "optional": true + }, "delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -3624,14 +3646,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3646,20 +3666,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3776,8 +3793,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3789,7 +3805,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3804,7 +3819,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3812,14 +3826,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3838,7 +3850,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3919,8 +3930,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3932,7 +3942,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -4054,7 +4063,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -4270,6 +4278,15 @@ "minimatch": "~3.0.2" } }, + "good-listener": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz", + "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=", + "optional": true, + "requires": { + "delegate": "^3.1.2" + } + }, "graceful-fs": { "version": "4.1.15", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", @@ -5944,6 +5961,11 @@ "object-visit": "^1.0.0" } }, + "marked": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.6.2.tgz", + "integrity": "sha512-LqxwVH3P/rqKX4EKGz7+c2G9r98WeM/SW34ybhgNGhUQNKtf1GmmSkJ6cDGJ/t6tiyae49qRkpyTw2B9HOrgUA==" + }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -6291,6 +6313,17 @@ "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", "dev": true }, + "ngx-markdown": { + "version": "7.1.5", + "resolved": "https://registry.npmjs.org/ngx-markdown/-/ngx-markdown-7.1.5.tgz", + "integrity": "sha512-boL1eQkdHHwVQuLsRF4eaIxuBx2PoJidO/YStLU2a0u6Q7VCjaZI09oSPgsAmsDjJ/Hu7ZWGPv475H7BGJ8iCw==", + "requires": { + "@types/marked": "^0.6.0", + "marked": "^0.6.0", + "prismjs": "^1.16.0", + "tslib": "^1.9.0" + } + }, "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -7225,6 +7258,14 @@ "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", "dev": true }, + "prismjs": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.16.0.tgz", + "integrity": "sha512-OA4MKxjFZHSvZcisLGe14THYsug/nF6O1f0pAJc0KN0wTyAcLqmsbE+lTGKSpyh+9pEW57+k6pg2AfYR+coyHA==", + "requires": { + "clipboard": "^2.0.0" + } + }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -8008,6 +8049,12 @@ } } }, + "select": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz", + "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=", + "optional": true + }, "select-hose": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", @@ -9235,6 +9282,12 @@ "setimmediate": "^1.0.4" } }, + "tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==", + "optional": true + }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", diff --git a/package.json b/package.json index 13a2230..52b234c 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@angular/platform-browser-dynamic": "~7.2.0", "@angular/router": "~7.2.0", "core-js": "^2.5.4", + "ngx-markdown": "^7.1.5", "rxjs": "~6.3.3", "tslib": "^1.9.0", "zone.js": "~0.8.26" diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 5362b85..57811cf 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -4,6 +4,10 @@ import { ArticleComponent } from "./article/article.component"; import { RouterEmptyComponent } from "./gui/router-empty/router-empty.component"; const routes: Routes = [ + { + path: "", + component: ArticleComponent + }, { path: "article", component: RouterEmptyComponent, diff --git a/src/app/app.component.html b/src/app/app.component.html index 9fde759..dc181b6 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,8 +1,3 @@ - -
Welcome to
+"; + }; + /*renderer.warning = (text: string) => { + return ""; + };*/ + + return { + renderer, + gfm: true, + tables: true, + breaks: false, + pedantic: false, + sanitize: false, + smartLists: true, + smartypants: false, + }; +} diff --git a/src/app/article/article.component.html b/src/app/article/article.component.html index 684915b..b6de578 100644 --- a/src/app/article/article.component.html +++ b/src/app/article/article.component.html @@ -1,3 +1,6 @@ -" + text + "
- article works! -
+ +