@nzz/q-cli 1.10.3 → 2.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +22 -313
  2. package/dist/createCustomCodeItem.js +74 -0
  3. package/dist/enums.js +7 -0
  4. package/dist/index.js +50 -0
  5. package/dist/interfaces.js +1 -0
  6. package/dist/newCustomCode.js +107 -0
  7. package/dist/updateItem.js +194 -0
  8. package/dist/utils.js +88 -0
  9. package/package.json +29 -36
  10. package/.nvmrc +0 -1
  11. package/.travis.yml +0 -17
  12. package/.vscode/launch.json +0 -36
  13. package/.vscode/settings.json +0 -5
  14. package/LICENSE +0 -21
  15. package/bin/commands/bootstrap.js +0 -68
  16. package/bin/commands/qItem/configStore.js +0 -144
  17. package/bin/commands/qItem/copyItem/copyItem.js +0 -103
  18. package/bin/commands/qItem/copyItem/copySchema.json +0 -37
  19. package/bin/commands/qItem/createCustomCodeItem/createCustomCodeItem.js +0 -81
  20. package/bin/commands/qItem/createCustomCodeItem/schema.json +0 -41
  21. package/bin/commands/qItem/helpers.js +0 -102
  22. package/bin/commands/qItem/itemService.js +0 -310
  23. package/bin/commands/qItem/resourcesService.js +0 -148
  24. package/bin/commands/qItem/schemaService.js +0 -65
  25. package/bin/commands/qItem/updateItem/updateItem.js +0 -64
  26. package/bin/commands/server.js +0 -80
  27. package/bin/q.js +0 -213
  28. package/dev-server/config/default.js +0 -51
  29. package/dev-server/public/favicon.ico +0 -0
  30. package/dev-server/public/style.css +0 -64
  31. package/dev-server/routes/dev-view.js +0 -52
  32. package/dev-server/routes/file.js +0 -10
  33. package/dev-server/routes/rendering-info.js +0 -130
  34. package/dev-server/routes/routes.js +0 -6
  35. package/dev-server/routes/tool-default.js +0 -108
  36. package/dev-server/server-plugins.js +0 -1
  37. package/dev-server/server.js +0 -18
  38. package/dev-server/views/index.html +0 -184
  39. package/skeletons/custom-code-skeleton/.nvmrc +0 -1
  40. package/skeletons/custom-code-skeleton/.vscode/settings.json +0 -5
  41. package/skeletons/custom-code-skeleton/README.md +0 -26
  42. package/skeletons/custom-code-skeleton/index.d.ts +0 -3
  43. package/skeletons/custom-code-skeleton/package-lock.json +0 -7355
  44. package/skeletons/custom-code-skeleton/package.json +0 -46
  45. package/skeletons/custom-code-skeleton/q.config.json +0 -60
  46. package/skeletons/custom-code-skeleton/rollup.config.js +0 -185
  47. package/skeletons/custom-code-skeleton/src/App.scss +0 -5
  48. package/skeletons/custom-code-skeleton/src/App.svelte +0 -7
  49. package/skeletons/custom-code-skeleton/src/enums.ts +0 -0
  50. package/skeletons/custom-code-skeleton/src/interfaces.ts +0 -0
  51. package/skeletons/custom-code-skeleton/src/main-prod.ts +0 -4
  52. package/skeletons/custom-code-skeleton/src/main.scss +0 -1
  53. package/skeletons/custom-code-skeleton/src/main.ts +0 -18
  54. package/skeletons/custom-code-skeleton/tsconfig.json +0 -16
  55. package/skeletons/et-utils-package-skeleton/.nvmrc +0 -1
  56. package/skeletons/et-utils-package-skeleton/README.md +0 -12
  57. package/skeletons/et-utils-package-skeleton/jest.config.ts +0 -17
  58. package/skeletons/et-utils-package-skeleton/package-lock.json +0 -3969
  59. package/skeletons/et-utils-package-skeleton/package.json +0 -40
  60. package/skeletons/et-utils-package-skeleton/scripts/package-fixup.sh +0 -13
  61. package/skeletons/et-utils-package-skeleton/src/Service.ts +0 -8
  62. package/skeletons/et-utils-package-skeleton/src/index.ts +0 -4
  63. package/skeletons/et-utils-package-skeleton/test/Service.spec.ts +0 -10
  64. package/skeletons/et-utils-package-skeleton/test/tsconfig.json +0 -8
  65. package/skeletons/et-utils-package-skeleton/tsconfig-base.json +0 -10
  66. package/skeletons/et-utils-package-skeleton/tsconfig-cjs.json +0 -8
  67. package/skeletons/et-utils-package-skeleton/tsconfig.json +0 -8
  68. package/skeletons/server-skeleton/.nvmrc +0 -1
  69. package/skeletons/server-skeleton/Dockerfile +0 -19
  70. package/skeletons/server-skeleton/auth/routes.js +0 -85
  71. package/skeletons/server-skeleton/auth/strategyOptions.js +0 -28
  72. package/skeletons/server-skeleton/config/base.js +0 -45
  73. package/skeletons/server-skeleton/config/db.js +0 -6
  74. package/skeletons/server-skeleton/config/editor.js +0 -105
  75. package/skeletons/server-skeleton/config/rendering-info.js +0 -70
  76. package/skeletons/server-skeleton/config/screenshot.js +0 -80
  77. package/skeletons/server-skeleton/config/targets.js +0 -31
  78. package/skeletons/server-skeleton/config/tools.js +0 -65
  79. package/skeletons/server-skeleton/files/favicon.png +0 -0
  80. package/skeletons/server-skeleton/files/system.js +0 -3612
  81. package/skeletons/server-skeleton/index.js +0 -106
  82. package/skeletons/server-skeleton/package-lock.json +0 -1825
  83. package/skeletons/server-skeleton/package.json +0 -29
  84. package/skeletons/tool-skeleton/.dockerignore +0 -1
  85. package/skeletons/tool-skeleton/.nvmrc +0 -1
  86. package/skeletons/tool-skeleton/.travis.yml +0 -26
  87. package/skeletons/tool-skeleton/.vscode/settings.json +0 -5
  88. package/skeletons/tool-skeleton/Dockerfile +0 -19
  89. package/skeletons/tool-skeleton/LICENSE +0 -20
  90. package/skeletons/tool-skeleton/README.md +0 -104
  91. package/skeletons/tool-skeleton/index.js +0 -32
  92. package/skeletons/tool-skeleton/package-lock.json +0 -10108
  93. package/skeletons/tool-skeleton/package.json +0 -45
  94. package/skeletons/tool-skeleton/resources/display-options-schema.json +0 -11
  95. package/skeletons/tool-skeleton/resources/fixtures/data/basic.json +0 -4
  96. package/skeletons/tool-skeleton/resources/locales/de/translation.json +0 -1
  97. package/skeletons/tool-skeleton/resources/locales/en/translation.json +0 -1
  98. package/skeletons/tool-skeleton/resources/locales/fr/translation.json +0 -1
  99. package/skeletons/tool-skeleton/resources/schema.json +0 -16
  100. package/skeletons/tool-skeleton/rollup.config.js +0 -75
  101. package/skeletons/tool-skeleton/routes/fixtures/data.js +0 -15
  102. package/skeletons/tool-skeleton/routes/health.js +0 -10
  103. package/skeletons/tool-skeleton/routes/locales.js +0 -21
  104. package/skeletons/tool-skeleton/routes/rendering-info/web.js +0 -97
  105. package/skeletons/tool-skeleton/routes/routes.js +0 -8
  106. package/skeletons/tool-skeleton/routes/schema.js +0 -19
  107. package/skeletons/tool-skeleton/routes/script.js +0 -17
  108. package/skeletons/tool-skeleton/routes/stylesheet.js +0 -17
  109. package/skeletons/tool-skeleton/sass.config.js +0 -66
  110. package/skeletons/tool-skeleton/scripts_src/default.js +0 -3
  111. package/skeletons/tool-skeleton/styles_src/_variables.scss +0 -1
  112. package/skeletons/tool-skeleton/styles_src/main.scss +0 -2
  113. package/skeletons/tool-skeleton/test/e2e-tests.js +0 -162
  114. package/skeletons/tool-skeleton/views/dynamic/YourTool.scss +0 -5
  115. package/skeletons/tool-skeleton/views/dynamic/YourTool.svelte +0 -19
  116. package/skeletons/tool-skeleton/views/static/App.scss +0 -5
  117. package/skeletons/tool-skeleton/views/static/App.svelte +0 -21
  118. package/skeletons/tool-skeleton/views/static/components/Footer.svelte +0 -31
  119. package/skeletons/tool-skeleton/views/static/components/Header.svelte +0 -7
  120. package/skeletons/toolv2-skeleton/.husky/pre-commit +0 -6
  121. package/skeletons/toolv2-skeleton/.nvmrc +0 -1
  122. package/skeletons/toolv2-skeleton/.prettierrc.cjs +0 -15
  123. package/skeletons/toolv2-skeleton/.travis.yml +0 -30
  124. package/skeletons/toolv2-skeleton/.vscode/settings.json +0 -6
  125. package/skeletons/toolv2-skeleton/Dockerfile +0 -19
  126. package/skeletons/toolv2-skeleton/LICENSE +0 -21
  127. package/skeletons/toolv2-skeleton/README.md +0 -99
  128. package/skeletons/toolv2-skeleton/dev.js +0 -7
  129. package/skeletons/toolv2-skeleton/index.js +0 -39
  130. package/skeletons/toolv2-skeleton/jest.config.ts +0 -39
  131. package/skeletons/toolv2-skeleton/nodemon.json +0 -4
  132. package/skeletons/toolv2-skeleton/package-lock.json +0 -21382
  133. package/skeletons/toolv2-skeleton/package.json +0 -80
  134. package/skeletons/toolv2-skeleton/resources/display-options-schema.json +0 -11
  135. package/skeletons/toolv2-skeleton/resources/locales/de/translation.json +0 -8
  136. package/skeletons/toolv2-skeleton/resources/locales/en/translation.json +0 -10
  137. package/skeletons/toolv2-skeleton/resources/locales/fr/translation.json +0 -10
  138. package/skeletons/toolv2-skeleton/resources/schema.json +0 -66
  139. package/skeletons/toolv2-skeleton/rollup.config.js +0 -48
  140. package/skeletons/toolv2-skeleton/scripts/postinstall.sh +0 -5
  141. package/skeletons/toolv2-skeleton/src/.eslintrc.cjs +0 -52
  142. package/skeletons/toolv2-skeleton/src/components/Main.spec.ts +0 -15
  143. package/skeletons/toolv2-skeleton/src/components/Main.svelte +0 -32
  144. package/skeletons/toolv2-skeleton/src/enums.ts +0 -11
  145. package/skeletons/toolv2-skeleton/src/helpers/fixture-generators.ts +0 -38
  146. package/skeletons/toolv2-skeleton/src/helpers/toolRuntimeConfig.ts +0 -15
  147. package/skeletons/toolv2-skeleton/src/interfaces.ts +0 -82
  148. package/skeletons/toolv2-skeleton/src/modules.d.ts +0 -8
  149. package/skeletons/toolv2-skeleton/src/routes/dynamic-schemas/exampleDynamicSchema.ts +0 -49
  150. package/skeletons/toolv2-skeleton/src/routes/dynamic-schemas/index.ts +0 -5
  151. package/skeletons/toolv2-skeleton/src/routes/health.ts +0 -14
  152. package/skeletons/toolv2-skeleton/src/routes/locales.ts +0 -31
  153. package/skeletons/toolv2-skeleton/src/routes/notifications/exampleNotification.ts +0 -46
  154. package/skeletons/toolv2-skeleton/src/routes/option-availability.ts +0 -27
  155. package/skeletons/toolv2-skeleton/src/routes/rendering-info/web.ts +0 -150
  156. package/skeletons/toolv2-skeleton/src/routes/routes.ts +0 -21
  157. package/skeletons/toolv2-skeleton/src/routes/schema.ts +0 -21
  158. package/skeletons/toolv2-skeleton/src/routes/stylesheet.ts +0 -31
  159. package/skeletons/toolv2-skeleton/src/styles/main.scss +0 -6
  160. package/skeletons/toolv2-skeleton/svelte.config.cjs +0 -6
  161. package/skeletons/toolv2-skeleton/tasks/compileStyleFiles.cjs +0 -101
  162. package/skeletons/toolv2-skeleton/tests/e2e-tests.spec.ts +0 -158
  163. package/skeletons/toolv2-skeleton/tests/helpers.ts +0 -21
  164. package/skeletons/toolv2-skeleton/tsconfig.json +0 -48
  165. /package/{bin/commands/qItem/updateItem → dist/assets}/updateSchema.json +0 -0
@@ -1,52 +0,0 @@
1
- module.exports = [
2
- {
3
- method: "GET",
4
- path: "/dev",
5
- handler: async (request, h) => {
6
- const target = process.env.TARGET || "nzz_ch";
7
-
8
- // add target and port
9
- const viewData = {
10
- port: process.env.PORT || 5000,
11
- target: target
12
- };
13
-
14
- // add context config if available
15
- if (process.env.CONFIG) {
16
- const getConfig = require(process.env.CONFIG);
17
- const config = await getConfig();
18
-
19
- if (config[target].context) {
20
- viewData.context = config[target].context;
21
- }
22
- }
23
-
24
- return h.view("index", viewData);
25
- }
26
- },
27
- {
28
- method: "GET",
29
- path: "/",
30
- handler: async (request, h) => {
31
- const target = process.env.TARGET || "nzz_ch";
32
-
33
- // add target and port
34
- const viewData = {
35
- port: process.env.PORT || 5000,
36
- target: target
37
- };
38
-
39
- // add context config if available
40
- if (process.env.CONFIG) {
41
- const getConfig = require(process.env.CONFIG);
42
- const config = await getConfig();
43
-
44
- if (config[target].context) {
45
- viewData.context = config[target].context;
46
- }
47
- }
48
-
49
- return h.view("index", viewData);
50
- }
51
- }
52
- ];
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- method: "GET",
3
- path: "/{param*}",
4
- handler: {
5
- directory: {
6
- path: ".",
7
- redirectToSlash: true
8
- }
9
- }
10
- };
@@ -1,130 +0,0 @@
1
- const Joi = require("joi");
2
- const Boom = require("@hapi/boom");
3
- const fetch = require("node-fetch");
4
- const querystring = require("querystring");
5
- const deepmerge = require("deepmerge");
6
-
7
- const toolBaseUrl = process.env.TOOL_BASE_URL || "http://localhost:3000";
8
-
9
- // try different endpoints to get the right one for the current tool
10
- function getRenderingInfo(item, queryString, config) {
11
- let promises = [];
12
- const pathEnds = ["html-static", "html-js", "web"];
13
-
14
- pathEnds.forEach((pathEnd) => {
15
- promises.push(
16
- fetch(`${toolBaseUrl}/rendering-info/${pathEnd}?${queryString}`, {
17
- method: "POST",
18
- body: JSON.stringify({
19
- item: item,
20
- toolRuntimeConfig: config.toolRuntimeConfig,
21
- }),
22
- headers: {
23
- "Content-Type": "application/json",
24
- },
25
- }).then((response) => {
26
- if (response.ok) {
27
- return response.json();
28
- } else {
29
- return undefined;
30
- }
31
- })
32
- );
33
- });
34
- return Promise.all(promises);
35
- }
36
-
37
- module.exports = {
38
- method: "GET",
39
- path: "/rendering-info/{id}/{target}",
40
- options: {
41
- validate: {
42
- params: {
43
- id: Joi.string().required(),
44
- target: Joi.string().required(),
45
- },
46
- options: {
47
- allowUnknown: true,
48
- },
49
- },
50
- },
51
- handler: async function (request, h) {
52
- try {
53
- // fetch item with id from array of fixture data
54
- const target = request.params.target;
55
- const fixtureDataResponse = await fetch(`${toolBaseUrl}/fixtures/data`);
56
- if (!fixtureDataResponse.ok) {
57
- throw new Error(fixtureDataResponse.status);
58
- }
59
- const fixtureData = await fixtureDataResponse.json();
60
- const item = fixtureData[request.params.id];
61
-
62
- // if these attributes are present in current item add them as query params to rendering-info request
63
- const queryParams = ["_id", "createdDate", "updatedDate"];
64
- let query = {};
65
- for (let queryParam of queryParams) {
66
- if (item.hasOwnProperty(queryParam) && item[queryParam]) {
67
- query[queryParam] = item[queryParam];
68
- } else if (queryParam === "_id") {
69
- query["_id"] = request.params.id;
70
- }
71
- }
72
- let queryString = querystring.stringify(query);
73
-
74
- let toolRuntimeConfig = {
75
- toolBaseUrl:
76
- request.server.info.protocol +
77
- "://" +
78
- request.server.info.address +
79
- ":" +
80
- request.server.info.port +
81
- "/tools",
82
- };
83
-
84
- let config;
85
- if (process.env.CONFIG) {
86
- const getConfig = require(process.env.CONFIG);
87
- config = await getConfig();
88
- // add tool specifc toolRuntimeConfig if it exists
89
- if (config[target].toolRuntimeConfig) {
90
- toolRuntimeConfig = Object.assign(
91
- toolRuntimeConfig,
92
- config[target].toolRuntimeConfig
93
- );
94
- }
95
- }
96
-
97
- let responses = await getRenderingInfo(item, queryString, {
98
- toolRuntimeConfig: toolRuntimeConfig,
99
- });
100
- let renderingInfo = responses.filter(
101
- (response) => response !== undefined
102
- )[0];
103
-
104
- // add target/tool specific additional rendering info to rendering info if it exists
105
- if (config && config[target].additionalRenderingInfo) {
106
- renderingInfo = deepmerge(
107
- renderingInfo,
108
- config[target].additionalRenderingInfo,
109
- {
110
- arrayMerge: (destArr, srcArr) => {
111
- return srcArr.concat(destArr);
112
- },
113
- }
114
- );
115
- }
116
-
117
- return h.response(renderingInfo);
118
- } catch (err) {
119
- console.log(err);
120
- if (err.stack) {
121
- request.server.log(["error"], err.stack);
122
- }
123
- if (err.isBoom) {
124
- return err;
125
- } else {
126
- return Boom.serverUnavailable(err.message);
127
- }
128
- }
129
- },
130
- };
@@ -1,6 +0,0 @@
1
- module.exports = [
2
- require("./file.js"),
3
- require("./tool-default.js").get,
4
- require("./tool-default.js").post,
5
- require("./rendering-info.js")
6
- ].concat(require("./dev-view.js"));
@@ -1,108 +0,0 @@
1
- const Joi = require("joi");
2
- const Wreck = require("@hapi/wreck");
3
- const querystring = require("querystring");
4
- const fetch = require("node-fetch");
5
-
6
- const toolBaseUrl = process.env.TOOL_BASE_URL || "http://localhost:3000";
7
-
8
- async function handler(request, h, payload = null) {
9
- let queryString = "";
10
- if (request.query && Object.keys(request.query).length > 0) {
11
- queryString = querystring.stringify(request.query);
12
- }
13
-
14
- let toolResponse;
15
- if (payload) {
16
- toolResponse = await Wreck.post(
17
- `${toolBaseUrl}/${request.params.path}?${queryString}`,
18
- {
19
- payload: payload,
20
- }
21
- );
22
- } else {
23
- toolResponse = await Wreck.get(
24
- `${toolBaseUrl}/${request.params.path}?${queryString}`
25
- );
26
- }
27
-
28
- // prepare the response to add more headers
29
- const response = h.response(toolResponse.payload);
30
-
31
- // set all the headers from the tool response
32
- for (let header in toolResponse.res.headers) {
33
- response.header(header, toolResponse.res.headers[header]);
34
- }
35
-
36
- return response;
37
- }
38
-
39
- module.exports = {
40
- get: {
41
- path: "/tools/{path*}",
42
- method: "GET",
43
- options: {
44
- validate: {
45
- params: {
46
- path: Joi.string().required(),
47
- },
48
- query: {
49
- appendItemToPayload: Joi.string().optional(),
50
- },
51
- options: {
52
- allowUnknown: true,
53
- },
54
- },
55
- },
56
- handler: async (request, h) => {
57
- let payload = null;
58
- if (request.query.appendItemToPayload) {
59
- // we use fixture data here instead of items in db
60
- const fixtureDataResponse = await fetch(`${toolBaseUrl}/fixtures/data`);
61
- if (!fixtureDataResponse.ok) {
62
- throw new Error(fixtureDataResponse.status);
63
- }
64
-
65
- const fixtureData = await fixtureDataResponse.json();
66
- // appendItemToPayload = item id = index in fixtures data array
67
- const item = fixtureData[request.query.appendItemToPayload];
68
- payload = {
69
- item: item,
70
- };
71
- }
72
- return Reflect.apply(handler, this, [request, h, payload]);
73
- },
74
- },
75
- post: {
76
- path: "/tools/{path*}",
77
- method: "POST",
78
- options: {
79
- validate: {
80
- params: {
81
- path: Joi.string().required(),
82
- },
83
- query: {
84
- appendItemToPayload: Joi.string().optional(),
85
- },
86
- payload: Joi.string(),
87
- options: {
88
- allowUnknown: true,
89
- },
90
- },
91
- },
92
- handler: async (request, h) => {
93
- if (request.query.appendItemToPayload) {
94
- // we use fixture data here instead of items in db
95
- const fixtureDataResponse = await fetch(`${toolBaseUrl}/fixtures/data`);
96
- if (!fixtureDataResponse.ok) {
97
- throw new Error(fixtureDataResponse.status);
98
- }
99
-
100
- const fixtureData = await fixtureDataResponse.json();
101
- // appendItemToPayload = item id = index in fixtures data array
102
- const item = fixtureData[request.query.appendItemToPayload];
103
- request.payload.item = item;
104
- }
105
- return Reflect.apply(handler, this, [request, h, request.payload]);
106
- },
107
- },
108
- };
@@ -1 +0,0 @@
1
- module.exports = [require("@hapi/inert"), require("@hapi/vision")];
@@ -1,18 +0,0 @@
1
- const Hapi = require("@hapi/hapi");
2
- const Joi = require("joi");
3
- const Path = require("path");
4
-
5
- const server = new Hapi.Server({
6
- port: process.env.PORT || 5000,
7
- routes: {
8
- cors: {
9
- origin: ["*"],
10
- },
11
- files: {
12
- relativeTo: Path.join(__dirname, "public"),
13
- },
14
- },
15
- });
16
- server.validator(Joi);
17
-
18
- module.exports = server;
@@ -1,184 +0,0 @@
1
- <!-- index.html to test what markup would look like locally (independent of target) -->
2
- <!DOCTYPE html>
3
- <html>
4
- <head>
5
- <meta charset="utf-8" />
6
- <title>Q Tool</title>
7
- <meta name="viewport" content="width=device-width" />
8
- <script src="https://cdn.jsdelivr.net/gh/muicss/loadjs@3.6.1/dist/loadjs.min.js"></script>
9
- <script src="https://q-server.st.nzz.ch/files/system.js"></script>
10
- <!-- if context is given load stylesheets and scripts if available -->
11
- {%- if context.stylesheets %} {%- for stylesheet in context.stylesheets %}
12
- {%- if stylesheet.url %}
13
- <link rel="stylesheet" href="{{ stylesheet.url }}" />
14
- {%- endif %} {%- if stylesheet.content %}
15
- <style>
16
- {{ stylesheet.content }}
17
- </style>
18
- {%- endif %} {%- endfor %} {%- endif %} {%- if context.scripts %} {%- for
19
- script in context.scripts %} {%- if script.url %}
20
- <script src="{{ script.url }}"></script>
21
- {%- endif %} {%- if script.content %}
22
- <script>
23
- {
24
- {
25
- script.content;
26
- }
27
- }
28
- </script>
29
- {%- endif %} {%- endfor %} {%- endif %} {%- if context.background %}
30
- <style>
31
- body {
32
- background-color: {{ context.background.color }};
33
- color: {{ context.background.color }}
34
- }
35
- #container {
36
- background-color: {{ context.background.color }};
37
- color: {{ context.background.color }}
38
- }
39
- </style>
40
- {%- endif %}
41
- <link rel="stylesheet" href="http://localhost:5000/style.css" />
42
- </head>
43
- <!-- we have four different article templates, since the article itself has the same structure in each template
44
- we can use either of these classes: regular, longformstandard, regular, opinion
45
- if one changes the class attached to body tag one should change the class in section tag accordingly (maybe further adjustments needed too) -->
46
- <body class="regular">
47
- <div class="fixtures__container">
48
- <select class="fixtures__select"></select>
49
- <button class="fixtures__reload-button" type="button">Reload</button>
50
- </div>
51
- <div id="__nzz">
52
- <div id="__layout">
53
- <div class="page--article-id">
54
- <div class="pageholder">
55
- <div class="nzz-container">
56
- <div class="nzz-page-transition">
57
- <div class="article">
58
- <!-- also here change layout--{template} accordingly -->
59
- <section class="container container--article layout--regular">
60
- <!-- default = content width, for fullwidth, small left/right one has to add one of
61
- the following classes accordingly: widget--fullwidth, widget--left, widget--right-->
62
- <div
63
- class="articlecomponent q-embed widget--qembed regwalled"
64
- >
65
- <div>
66
- <div class="s-q-item" id="container"></div>
67
- </div>
68
- </div>
69
- </section>
70
- </div>
71
- </div>
72
- </div>
73
- </div>
74
- </div>
75
- </div>
76
- </div>
77
-
78
- <script>
79
- const port = {{ port }};
80
- const target = '{{ target }}';
81
- // load fixture data and populate select element with titles
82
- fetch(`http://localhost:${port}/tools/fixtures/data`)
83
- .then(response => {
84
- if (response.ok) {
85
- return response.json();
86
- }
87
- throw new Error(response);
88
- })
89
- .then(fixtureData => {
90
- let selectElement = document.querySelector(".fixtures__select");
91
- fixtureData.forEach((data, index) => {
92
- let option = document.createElement('option');
93
- // removes mandatory 'FIXTURE: ' from title
94
- option.text = data.title.substr(9);
95
- option.value = index;
96
- selectElement.appendChild(option);
97
- });
98
- // init with rendering info for first item in select
99
- updateRenderingInfoForItem(fixtureData, 0);
100
-
101
- // as soon as another fixture data item is selected, update with its rendering info
102
- selectElement.addEventListener('change', (event) => {
103
- updateRenderingInfoForItem(fixtureData, selectElement.selectedIndex);
104
- });
105
-
106
- document.querySelector(".fixtures__reload-button").addEventListener('click', () => {
107
- updateRenderingInfoForItem(fixtureData, selectElement.selectedIndex);
108
- })
109
- });
110
-
111
- function loadRenderingInfo(fixtureData, index) {
112
- return fetch(`http://localhost:${port}/rendering-info/${index}/${target}`)
113
- .then(response => {
114
- if (response.ok) {
115
- return response.json();
116
- }
117
- throw new Error(response);
118
- })
119
- .catch(e => {
120
- console.log(e);
121
- // do nothing
122
- });
123
- }
124
-
125
- function updateRenderingInfoForItem(fixtureData, index) {
126
- loadRenderingInfo(fixtureData, index)
127
- .then(data => {
128
- if(data) {
129
- // add markup
130
- document.querySelector("#container").innerHTML = data.markup;
131
- // load resources
132
- let scriptUrls = [];
133
- if(data.scripts) {
134
- data.scripts.map(script => {
135
- if(script.name) {
136
- script.url = `http://localhost:${port}/tools/script/${script.name}`;
137
- }
138
- });
139
- scriptUrls = data.scripts.filter(script => script.url).map(script => script.url);
140
- }
141
-
142
- let stylesheetUrls = [];
143
- if(data.stylesheets) {
144
- data.stylesheets.map(stylesheet => {
145
- if (stylesheet.name) {
146
- stylesheet.url = `http://localhost:${port}/tools/stylesheet/${stylesheet.name}`
147
- }
148
- });
149
- stylesheetUrls = data.stylesheets.filter(stylesheet => stylesheet.url).map(stylesheet => stylesheet.url);
150
- }
151
-
152
- const urlResources = [...scriptUrls, ...stylesheetUrls];
153
- loadjs(urlResources, {
154
- success: () => {
155
- if(data.scripts) {
156
- for(const script of data.scripts.filter(script => script.content)) {
157
- const scriptElement = document.createElement('script');
158
- scriptElement.innerHTML = script.content;
159
- document.querySelector("#container").appendChild(scriptElement);
160
- }
161
- }
162
- if(data.stylesheets) {
163
- for(const stylesheet of data.stylesheets.filter(stylesheet => stylesheet.content)) {
164
- const styleElement = document.createElement('style');
165
- styleElement.type = "text/css";
166
- styleElement.appendChild(document.createTextNode(stylesheet.content));
167
- document.querySelector("#container").appendChild(styleElement);
168
- }
169
- }
170
- },
171
- before: (path, scriptElement) => {
172
- document.querySelector("#container").appendChild(scriptElement);
173
- /* return `false` to bypass default DOM insertion mechanism */
174
- return false;
175
- }
176
- });
177
- } else {
178
- throw new Error("Something went wrong while loading the renderingInfo. There might be a problem in your tool");
179
- }
180
- })
181
- }
182
- </script>
183
- </body>
184
- </html>
@@ -1 +0,0 @@
1
- 16
@@ -1,5 +0,0 @@
1
- {
2
- "[svelte]": {
3
- "editor.defaultFormatter": "svelte.svelte-vscode"
4
- }
5
- }
@@ -1,26 +0,0 @@
1
- ## Custom code boilerplate
2
-
3
- Install the dependencies
4
-
5
- ```bash
6
- npm install
7
- ```
8
-
9
- #### Running it locally
10
-
11
- Regular layout
12
- ```
13
- npm start
14
- ```
15
-
16
- Longform standard
17
- ```
18
- npm run start-ls
19
- ```
20
-
21
- Longform Visual
22
- ```
23
- npm run start-lv
24
- ```
25
-
26
- Navigate to [http://0.0.0.0:5555](http://0.0.0.0:5555). You should see your app running. Edit a component file in `src`, save it and see the changes in the browser.
@@ -1,3 +0,0 @@
1
- declare module '*.jpg';
2
- declare module '*.png';
3
- declare module '*.svg';