diff --git a/js/index.d.ts b/js/index.d.ts index ad9b4f4..f5e9e19 100644 --- a/js/index.d.ts +++ b/js/index.d.ts @@ -1,17 +1,39 @@ -export interface INavigationNode { +export interface IBreadcrumbNode { referencedFile: string; title: string; } +interface INavigationNode { + title: string; + /** + * Values can be any string. Special treatment for: + * - "none" : excluded from all navigations except "allplain" + * - "top" : default top navigation + */ + navigation?: NavigationType | "none"; +} +export interface IBranch extends INavigationNode { + children: ConfigNode[]; +} +export interface IStructureNode extends INavigationNode { + children?: ConfigNode[]; + referencedFile: string; +} +declare type ConfigNode = IStructureNode | IBranch; +/** + * Array of (child) elements in the site structure tree. + */ +export declare type StructureConfig = ConfigNode[]; export declare type NavigationType = string | "allplain" | "top"; export declare class Navigation { private fileExtension; private breadcrumbStartNode; private structure; private breadcrumbs; - constructor(s: any, fileExtension?: string, breadcrumbStartNode?: INavigationNode); + constructor(s: any, fileExtension?: string, breadcrumbStartNode?: IBreadcrumbNode); private writeNavigationEntry; private renderBreadcrumb; private initBreadcrumbs; writeNavigation(type: NavigationType, writeHtml?: boolean, excludedFromAllPlain?: string[]): string; getBreadcrumb(referencedFile: string, writeHtml?: boolean): string; } +export {}; diff --git a/js/index.js b/js/index.js index 02e4588..db66ed5 100644 --- a/js/index.js +++ b/js/index.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); const jsonschema_1 = require("jsonschema"); const pug_1 = require("pug"); -const site_structure_schema_1 = require("./site-structure-schema"); const util_1 = require("./util"); +const SiteStructureSchema = require("./site-structure-schema"); const NAV_CONST = { // dont show in navigation at all none: "none", @@ -23,7 +23,7 @@ class Navigation { if (!util_1.isNullOrEmpty(fileExtension)) { this.fileExtension = `.${fileExtension}`; } - let validationResult = new jsonschema_1.Validator().validate(s, site_structure_schema_1.SiteStructureSchema); + let validationResult = new jsonschema_1.Validator().validate(s, SiteStructureSchema); if (!validationResult.valid) { console.error(validationResult); throw { @@ -41,7 +41,7 @@ class Navigation { let pug = ""; if (!util_1.isNullOrUndefined(entry) && entry.children - && (entry.children.filter((e) => { return e.navigation !== NAV_CONST.none; }).length > 0 + && (entry.children.filter((e) => e.navigation !== NAV_CONST.none).length > 0 || type === NAV_CONST.allplain)) { pug = util_1.indent(n, true) + "li" @@ -87,15 +87,16 @@ class Navigation { } return pug; } - initBreadcrumbs(branch, path) { + initBreadcrumbs(node, path) { let fork = [...path]; - if (branch.referencedFile != this.breadcrumbStartNode.referencedFile) { + if (node.referencedFile != this.breadcrumbStartNode.referencedFile) { fork.push({ - title: branch.title, - referencedFile: branch.referencedFile + title: node.title, + referencedFile: node.referencedFile }); } - this.breadcrumbs[branch.referencedFile] = fork; + this.breadcrumbs[node.referencedFile] = fork; + let branch = node; if (branch.children) { for (let child of branch.children) { this.initBreadcrumbs(child, fork); diff --git a/js/index.js.map b/js/index.js.map index 8ba3cae..68799d0 100644 --- a/js/index.js.map +++ b/js/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;AAAA,2CAAwD;AACxD,6BAA6B;AAC7B,mEAA8D;AAC9D,iCAAkE;AAElE,MAAM,SAAS,GAAkD;IAC/D,iCAAiC;IACjC,IAAI,EAAE,MAAM;IACZ,yBAAyB;IACzB,GAAG,EAAE,KAAK;IACV,oBAAoB;IACpB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAkBF,MAAa,UAAU;IAIrB,YAAmB,CAAM,EACE,gBAAwB,MAAM,EAC9B,sBAAuC,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE;QADlF,kBAAa,GAAb,aAAa,CAAiB;QAC9B,wBAAmB,GAAnB,mBAAmB,CAA+D;QAC3G,IAAI,oBAAa,CAAC,CAAC,CAAC,EAAE;YACpB,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAC1C,CAAC,GAAG,EAAE,CAAC;SACR;QAED,IAAI,CAAC,oBAAa,CAAC,aAAa,CAAC,EAAE;Y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AAS,EAAE;gBAC/B,IAAI,CAAE,IAAuB,CAAC,UAAU,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI;uBAC9D,CAAC,IAAI,KAAK,SAAS,CAAC,QAAQ;2BACzB,oBAAoB,CAAC,OAAO,CAAE,IAAuB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE;oBAClF,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;iBACjD;aACF;SACF;QAED,OAAO,SAAS,CAAC,CAAC,CAAC,YAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACvC,CAAC;IAEM,aAAa,CAAC,cAAsB,EAAE,YAAqB,KAAK;QACrE,IAAI,EAAE,GAAsB,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAC7D,IAAI,CAAC,EAAE,EAAE;YACP,MAAM;gBACJ,IAAI,EAAE,iBAAiB;gBACvB,OAAO,EAAE,6BAA6B,GAAG,cAAc;aACxD,CAAC;SACH;QAED,IAAI,GAAG,GAAW,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC5C,OAAO,SAAS,CAAC,CAAC,CAAC,YAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACvC,CAAC;CACF;AApID,gCAoIC"} \ No newline at end of file diff --git a/js/site-structure-schema.d.ts b/js/site-structure-schema.d.ts deleted file mode 100644 index 38e03e1..0000000 --- a/js/site-structure-schema.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare const SiteStructureSchema: any; diff --git a/js/site-structure-schema.js b/js/site-structure-schema.js deleted file mode 100644 index d51ef30..0000000 --- a/js/site-structure-schema.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SiteStructureSchema = { - "$schema": "http://json-schema.org/draft-04/schema", - "title": "JSON Schema for the site structure file", - "description": "Array of (child) elements in the site structure tree.", - "type": "array", - "items": { - "oneOf": [ - { - "$ref": "#/definitions/group" - }, - { - "$ref": "#/definitions/entry" - } - ] - }, - "definitions": { - "group": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "type": "string", - "description": "The title of the menu entry and url path." - }, - "navigation": { - "$ref": "#/definitions/navigationType" - }, - "children": { - "$ref": "#" - } - }, - "required": [ - "title", - "children" - ] - }, - "entry": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "type": "string", - "description": "The title of the menu entry and url path." - }, - "navigation": { - "$ref": "#/definitions/navigationType" - }, - "referencedFile": { - "type": "string", - "description": "Name of the partial file." - }, - "children": { - "$ref": "#" - } - }, - "required": [ - "title", - "referencedFile" - ] - }, - "navigationType": { - "enum": [ - "top", - "footer", - "none" - ], - "description": "Whether the entry is visible in the navigation." - } - } -}; -//# sourceMappingURL=site-structure-schema.js.map \ No newline at end of file diff --git a/js/site-structure-schema.js.map b/js/site-structure-schema.js.map deleted file mode 100644 index f1c51f6..0000000 --- a/js/site-structure-schema.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"site-structure-schema.js","sourceRoot":"","sources":["../ts/site-structure-schema.ts"],"names":[],"mappings":";;AAAa,QAAA,mBAAmB,GAAQ;IACtC,SAAS,EAAE,wCAAwC;IACnD,OAAO,EAAE,yCAAyC;IAClD,aAAa,EAAE,uDAAuD;IAEtE,MAAM,EAAE,OAAO;IACf,OAAO,EAAE;QACP,OAAO,EAAE;YACP;gBACE,MAAM,EAAE,qBAAqB;aAC9B;YACD;gBACE,MAAM,EAAE,qBAAqB;aAC9B;SACF;KACF;IACD,aAAa,EAAE;QACb,OAAO,EAAE;YACP,MAAM,EAAE,QAAQ;YAChB,sBAAsB,EAAE,KAAK;YAC7B,YAAY,EAAE;gBACZ,OAAO,EAAE;oBACP,MAAM,EAAE,QAAQ;oBAChB,aAAa,EAAE,2CAA2C;iBAC3D;gBACD,YAAY,EAAE;oBACZ,MAAM,EAAE,8BAA8B;iBACvC;gBACD,UAAU,EAAE;oBACV,MAAM,EAAE,GAAG;iBACZ;aACF;YACD,UAAU,EAAE;gBACV,OAAO;gBACP,UAAU;aACX;SACF;QACD,OAAO,EAAE;YACP,MAAM,EAAE,QAAQ;YAChB,sBAAsB,EAAE,KAAK;YAC7B,YAAY,EAAE;gBACZ,OAAO,EAAE;oBACP,MAAM,EAAE,QAAQ;oBAChB,aAAa,EAAE,2CAA2C;iBAC3D;gBACD,YAAY,EAAE;oBACZ,MAAM,EAAE,8BAA8B;iBACvC;gBACD,gBAAgB,EAAE;oBAChB,MAAM,EAAE,QAAQ;oBAChB,aAAa,EAAE,2BAA2B;iBAC3C;gBACD,UAAU,EAAE;oBACV,MAAM,EAAE,GAAG;iBACZ;aACF;YACD,UAAU,EAAE;gBACV,OAAO;gBACP,gBAAgB;aACjB;SACF;QACD,gBAAgB,EAAE;YAChB,MAAM,EAAE;gBACN,KAAK;gBACL,QAAQ;gBACR,MAAM;aACP;YACD,aAAa,EAAE,iDAAiD;SACjE;KACF;CACF,CAAC"} \ No newline at end of file diff --git a/js/site-structure-schema.json b/js/site-structure-schema.json new file mode 100644 index 0000000..27fbd6a --- /dev/null +++ b/js/site-structure-schema.json @@ -0,0 +1,90 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "IBranch": { + "additionalProperties": false, + "properties": { + "children": { + "items": { + "anyOf": [ + { + "$ref": "#/definitions/IBranch" + }, + { + "$ref": "#/definitions/IStructureNode" + } + ] + }, + "title": "children", + "type": "array" + }, + "navigation": { + "description": "Values can be any string. Special treatment for:\n- \"none\" : excluded from all navigations except \"allplain\"\n- \"top\" : default top navigation", + "title": "navigation", + "type": "string" + }, + "title": { + "title": "title", + "type": "string" + } + }, + "required": [ + "children", + "title" + ], + "title": "IBranch", + "type": "object" + }, + "IStructureNode": { + "additionalProperties": false, + "properties": { + "children": { + "items": { + "anyOf": [ + { + "$ref": "#/definitions/IBranch" + }, + { + "$ref": "#/definitions/IStructureNode" + } + ] + }, + "title": "children", + "type": "array" + }, + "navigation": { + "description": "Values can be any string. Special treatment for:\n- \"none\" : excluded from all navigations except \"allplain\"\n- \"top\" : default top navigation", + "title": "navigation", + "type": "string" + }, + "referencedFile": { + "title": "referencedFile", + "type": "string" + }, + "title": { + "title": "title", + "type": "string" + } + }, + "required": [ + "referencedFile", + "title" + ], + "title": "IStructureNode", + "type": "object" + } + }, + "description": "Array of (child) elements in the site structure tree.", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/IBranch" + }, + { + "$ref": "#/definitions/IStructureNode" + } + ] + }, + "type": "array" +} + diff --git a/package-lock.json b/package-lock.json index d5fa580..8b0213e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mvw-navigation", - "version": "2.0.12", + "version": "2.0.14", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -244,6 +244,12 @@ "wordwrap": "0.0.2" } }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, "color-convert": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", @@ -287,6 +293,17 @@ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.6.tgz", "integrity": "sha512-lQUVfQi0aLix2xpyjrrJEvfuYCqPc/HwmTKsC/VNf8q0zsjX7SQZtp4+oRONN5Tsur9GDETPjj+Ub2iDiGZfSQ==" }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "^4.0.1", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", @@ -320,6 +337,30 @@ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "dev": true, + "requires": { + "cross-spawn": "^5.0.1", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -331,10 +372,22 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, + "get-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", + "dev": true + }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -384,6 +437,12 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "dev": true + }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", @@ -405,6 +464,12 @@ } } }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, "is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", @@ -418,6 +483,18 @@ "has": "^1.0.1" } }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, "jasmine": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.2.0.tgz", @@ -455,6 +532,21 @@ "esprima": "^4.0.0" } }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "~0.0.0" + } + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, "jsonschema": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.4.tgz", @@ -482,6 +574,25 @@ "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=" }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, "lodash": { "version": "4.17.10", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", @@ -492,15 +603,55 @@ "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=" }, + "lru-cache": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", + "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, + "mem": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", + "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", "dev": true, "requires": { "brace-expansion": "^1.1.7" } }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, + "requires": { + "path-key": "^2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -515,12 +666,65 @@ "wrappy": "1" } }, + "os-locale": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "dev": true, + "requires": { + "execa": "^0.7.0", + "lcid": "^1.0.0", + "mem": "^1.1.0" + } + }, + "p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true + }, + "p-limit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", + "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", + "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", + "dev": true + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", @@ -534,6 +738,12 @@ "asap": "~2.0.3" } }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, "pug": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pug/-/pug-2.0.3.tgz", @@ -658,6 +868,18 @@ "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, "resolve": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", @@ -680,6 +902,33 @@ "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -691,6 +940,33 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", @@ -700,6 +976,12 @@ "ansi-regex": "^2.0.0" } }, + "strip-eof": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true + }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", @@ -757,6 +1039,75 @@ "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==", "dev": true }, + "typescript-json-schema": { + "version": "0.31.0", + "resolved": "https://registry.npmjs.org/typescript-json-schema/-/typescript-json-schema-0.31.0.tgz", + "integrity": "sha512-YgG+lWiToGzlKPdO2ZjGx4Y5TdJh8N0eEA2p8IQDSGdUIv+fqQlO4YLbZNxMpFiomvparcxTOgRpPsIrk0sNWg==", + "dev": true, + "requires": { + "glob": "~7.1.2", + "json-stable-stringify": "^1.0.1", + "typescript": "^3.0.1", + "yargs": "^12.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0", + "wrap-ansi": "^2.0.0" + } + }, + "decamelize": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-2.0.0.tgz", + "integrity": "sha512-Ikpp5scV3MSYxY39ymh45ZLEecsTdv/Xj2CaQfI8RLMuwi7XvjX9H/fhraiSuU+C5w5NTDu4ZU72xNiZnurBPg==", + "dev": true, + "requires": { + "xregexp": "4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + }, + "yargs": { + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.1.tgz", + "integrity": "sha512-B0vRAp1hRX4jgIOWFtjfNjd9OA9RWYZ6tqGA9/I/IrTMsxmKvtWy+ersM+jzpQqbC3YfLzeABPdeTgcJ9eu1qQ==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^2.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^2.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^10.1.0" + } + } + } + }, "uglify-js": { "version": "2.8.29", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", @@ -778,6 +1129,21 @@ "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=" }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "dev": true + }, "window-size": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", @@ -797,12 +1163,62 @@ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=" }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + } + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "xregexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.0.0.tgz", + "integrity": "sha512-PHyM+sQouu7xspQQwELlGwwd05mXUFqwFYfqPO0cC7x4fxyHnnuetmQr6CjJiafIDoH4MogHb9dOoJzR/Y4rFg==", + "dev": true + }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true + }, "yargs": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", @@ -813,6 +1229,23 @@ "decamelize": "^1.0.0", "window-size": "0.1.0" } + }, + "yargs-parser": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", + "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", + "dev": true, + "requires": { + "camelcase": "^4.1.0" + }, + "dependencies": { + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + } + } } } } diff --git a/package.json b/package.json index 8ae77b3..8fd2a38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mvw-navigation", - "version": "2.0.13", + "version": "2.1.0", "description": "Module to generate a site navigation from a given structure file.", "keywords": [ "website", @@ -21,7 +21,8 @@ "@types/pug": "2.0.4", "jasmine": "3.2.0", "typescript": "3.0.1", - "tslint": "5.11.0" + "tslint": "5.11.0", + "typescript-json-schema": "0.31.0" }, "dependencies": { "jsonschema": "~1.2.4", @@ -29,7 +30,8 @@ }, "scripts": { "build": "tsc -p ./ts", - "test": "tslint --project ./ts && tsc -p ./ts && tsc -p ./spec && jasmine" + "postbuild": "typescript-json-schema ./ts/tsconfig.json StructureConfig --titles --required --excludePrivate --noExtraProps > ./js/site-structure-schema.json", + "test": "tslint --project ./ts && npm run build && tsc -p ./spec && jasmine" }, "repository": { "type": "git", diff --git a/ts/index.ts b/ts/index.ts index e4f30be..42151b9 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,8 +1,9 @@ import { Validator, ValidatorResult } from "jsonschema"; import { render } from "pug"; -import { SiteStructureSchema } from "./site-structure-schema"; import { isNullOrUndefined, isNullOrEmpty, indent } from "./util"; +const SiteStructureSchema: any = require("./site-structure-schema"); + const NAV_CONST: {none: string, top: string, allplain: string} = { // dont show in navigation at all none: "none", @@ -12,29 +13,46 @@ const NAV_CONST: {none: string, top: string, allplain: string} = { allplain: "allplain" }; -export interface INavigationNode { +export interface IBreadcrumbNode { referencedFile: string; title: string; } -interface IBranch extends INavigationNode { - children: IBranch[]; +interface INavigationNode { + title: string; + /** + * Values can be any string. Special treatment for: + * - "none" : excluded from all navigations except "allplain" + * - "top" : default top navigation + */ + navigation?: NavigationType | "none"; } -interface IStructureNode extends INavigationNode { - navigation: NavigationType | "none"; - children: IStructureNode[]; +export interface IBranch extends INavigationNode { + children: ConfigNode[]; } +export interface IStructureNode extends INavigationNode { + children?: ConfigNode[]; + referencedFile: string; +} + +type ConfigNode = IStructureNode | IBranch; + +/** + * Array of (child) elements in the site structure tree. + */ +export type StructureConfig = ConfigNode[]; + export type NavigationType = string | "allplain" | "top"; export class Navigation { - private structure: IStructureNode[]; - private breadcrumbs: { [referencedFile: string]: INavigationNode[] }; + private structure: StructureConfig; + private breadcrumbs: { [referencedFile: string]: IBreadcrumbNode[] }; public constructor(s: any, private fileExtension: string = "html", - private breadcrumbStartNode: INavigationNode = { title: "Start", referencedFile: "index" }) { + private breadcrumbStartNode: IBreadcrumbNode = { title: "Start", referencedFile: "index" }) { if (isNullOrEmpty(s)) { console.warn("Empty structure provided!"); s = []; @@ -60,11 +78,11 @@ export class Navigation { } } - private writeNavigationEntry(entry: IStructureNode, n: number, type: NavigationType): string { + private writeNavigationEntry(entry: ConfigNode, n: number, type: NavigationType): string { let pug: string = ""; if (!isNullOrUndefined(entry) && entry.children - && (entry.children.filter((e): boolean => { return e.navigation !== NAV_CONST.none; }).length > 0 + && (entry.children.filter((e): boolean => e.navigation !== NAV_CONST.none).length > 0 || type === NAV_CONST.allplain)) { pug = indent(n, true) + "li" @@ -73,8 +91,8 @@ export class Navigation { : "") + indent(n + 2, true) + (type !== NAV_CONST.allplain ? "a(href=\"#\") " - : (entry.referencedFile - ? `a(href="${entry.referencedFile}${this.fileExtension}") ` + : ((entry as IStructureNode).referencedFile + ? `a(href="${(entry as IStructureNode).referencedFile}${this.fileExtension}") ` : "div ")) + entry.title + indent(n + 2, true) @@ -84,18 +102,18 @@ export class Navigation { } } else { if (type === NAV_CONST.allplain || entry.navigation !== NAV_CONST.none) { - pug = indent(n, true) + `li(class=(referencedFile === "${entry.referencedFile}" ? "active" : undefined))` - + indent(n + 2, true) + `a(href="${entry.referencedFile}${this.fileExtension}") ` + pug = indent(n, true) + `li(class=(referencedFile === "${(entry as IStructureNode).referencedFile}" ? "active" : undefined))` + + indent(n + 2, true) + `a(href="${(entry as IStructureNode).referencedFile}${this.fileExtension}") ` + entry.title; } } return pug; } - private renderBreadcrumb(breadcrumb: INavigationNode[]): string { + private renderBreadcrumb(breadcrumb: IBreadcrumbNode[]): string { let pug: string = `ol.breadcrumb(itemprop="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList")`; for (let i: number = 0; i < breadcrumb.length; i++) { - let bc: INavigationNode = breadcrumb[i]; + let bc: IBreadcrumbNode = breadcrumb[i]; if (isNullOrEmpty(bc.referencedFile) || i === breadcrumb.length - 1) { pug += indent(2, true) + `li${((i === breadcrumb.length - 1) ? ".active" : "")}(itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem")` + indent(4, true) + `span(itemprop="name") ${bc.title}` @@ -110,18 +128,19 @@ export class Navigation { return pug; } - private initBreadcrumbs(branch: IBranch, path: INavigationNode[]): void { - let fork: INavigationNode[] = [...path]; + private initBreadcrumbs(node: INavigationNode, path: IBreadcrumbNode[]): void { + let fork: IBreadcrumbNode[] = [...path]; - if(branch.referencedFile != this.breadcrumbStartNode.referencedFile) { + if((node as IStructureNode).referencedFile != this.breadcrumbStartNode.referencedFile) { fork.push({ - title: branch.title, - referencedFile: branch.referencedFile + title: node.title, + referencedFile: (node as IStructureNode).referencedFile }); } - this.breadcrumbs[branch.referencedFile] = fork; + this.breadcrumbs[(node as IStructureNode).referencedFile] = fork; + let branch: IBranch = node as IBranch; if (branch.children) { for (let child of branch.children) { this.initBreadcrumbs(child, fork); @@ -136,9 +155,9 @@ export class Navigation { if (!isNullOrUndefined(this.structure) && this.structure.length > 0) { for (let node of this.structure) { - if ((node.navigation || NAV_CONST.top) === type + if (((node as IStructureNode).navigation || NAV_CONST.top) === type || (type === NAV_CONST.allplain - && excludedFromAllPlain.indexOf(node.referencedFile) < 0)) { + && excludedFromAllPlain.indexOf((node as IStructureNode).referencedFile) < 0)) { pug += this.writeNavigationEntry(node, 2, type); } } @@ -148,7 +167,7 @@ export class Navigation { } public getBreadcrumb(referencedFile: string, writeHtml: boolean = false): string { - let bc: INavigationNode[] = this.breadcrumbs[referencedFile]; + let bc: IBreadcrumbNode[] = this.breadcrumbs[referencedFile]; if (!bc) { throw { name: "ElementNotFound", diff --git a/ts/site-structure-schema.ts b/ts/site-structure-schema.ts deleted file mode 100644 index 9ebb37d..0000000 --- a/ts/site-structure-schema.ts +++ /dev/null @@ -1,71 +0,0 @@ -export const SiteStructureSchema: any = { - "$schema": "http://json-schema.org/draft-04/schema", - "title": "JSON Schema for the site structure file", - "description": "Array of (child) elements in the site structure tree.", - - "type": "array", - "items": { - "oneOf": [ - { - "$ref": "#/definitions/group" - }, - { - "$ref": "#/definitions/entry" - } - ] - }, - "definitions": { - "group": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "type": "string", - "description": "The title of the menu entry and url path." - }, - "navigation": { - "$ref": "#/definitions/navigationType" - }, - "children": { - "$ref": "#" - } - }, - "required": [ - "title", - "children" - ] - }, - "entry": { - "type": "object", - "additionalProperties": false, - "properties": { - "title": { - "type": "string", - "description": "The title of the menu entry and url path." - }, - "navigation": { - "$ref": "#/definitions/navigationType" - }, - "referencedFile": { - "type": "string", - "description": "Name of the partial file." - }, - "children": { - "$ref": "#" - } - }, - "required": [ - "title", - "referencedFile" - ] - }, - "navigationType": { - "enum": [ - "top", - "footer", - "none" - ], - "description": "Whether the entry is visible in the navigation." - } - } -};