@abtnode/router-templates 1.6.16 → 1.6.17

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.
package/lib/404.js CHANGED
@@ -3,7 +3,6 @@ const common = require('./common');
3
3
  module.exports = (nodeInfo) =>
4
4
  common({
5
5
  title: '404',
6
- pageTitle: '404',
7
6
  content: "We can't find the page that you're looking for.",
8
7
  nodeInfo,
9
8
  refreshButton: false,
package/lib/502.js CHANGED
@@ -3,7 +3,6 @@ const common = require('./common');
3
3
  module.exports = (nodeInfo) =>
4
4
  common({
5
5
  title: '502',
6
- pageTitle: 'Error 502',
7
6
  content: 'Bad gateway: Upstream Blocklet or Daemon service is not available!',
8
7
  nodeInfo,
9
8
  });
package/lib/5xx.js CHANGED
@@ -1,4 +1,3 @@
1
1
  const common = require('./common');
2
2
 
3
- module.exports = (nodeInfo) =>
4
- common({ title: 'Error', pageTitle: 'Oops!', content: 'Something went wrong', nodeInfo });
3
+ module.exports = (nodeInfo) => common({ title: 'Error', content: 'Something went wrong', nodeInfo });
@@ -2,8 +2,8 @@ const getCommonTemplate = require('./common');
2
2
 
3
3
  module.exports = (blocklet, nodeInfo) => {
4
4
  return getCommonTemplate({
5
- title: 'Error',
6
- pageTitle: 'Please come back later',
5
+ title: 'Please come back later',
6
+ pageTitle: 'Error - Blocklet Server',
7
7
  content: 'Blocklet is not running.',
8
8
  nodeInfo,
9
9
  });
package/lib/common.js CHANGED
@@ -1,64 +1,58 @@
1
- module.exports = ({ title = '', pageTitle = '', content = '', nodeInfo = {}, refreshButton = true }) => {
2
- const button = refreshButton
3
- ? '<div>Please click me to <button onclick="javascript:window.location.reload(true)">Refresh</button><div>'
4
- : '';
5
-
6
- return `<!DOCTYPE html>
7
- <html lang="en">
8
-
9
- <head>
10
- <meta charset="UTF-8">
11
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
12
- <title>${title} - Blocklet Server</title>
13
- <style>
14
- html {
15
- font-size: 16px;
16
- }
17
-
18
- h1 {
19
- color: #00c2c4;
20
- font-size: 3.8rem;
21
- }
1
+ const { render } = require('@arcblock/result-html-pages');
22
2
 
23
- button {
24
- font-size: 0.9375rem;
25
- border-radius: 20px;
26
- color: #FFFFFF;
27
- background-color: #4E6AF6;
28
- padding: 8px 22px;
29
- box-shadow: none;
30
- text-transform: capitalize;
31
- border: 0;
32
- outline: 0;
33
- cursor: pointer;
3
+ const filterNullOrUndefined = (obj) =>
4
+ Object.keys(obj).reduce((res, key) => {
5
+ if (obj[key] !== undefined && obj[key] !== null) {
6
+ res[key] = obj[key];
34
7
  }
35
-
36
- button:hover {
37
- background-color: rgb(54, 74, 172);
38
- }
39
-
40
- .documentation {
41
- margin-top: 10px;
42
- }
43
- </style>
44
- </head>
45
-
46
- <body>
47
- <center>
48
- <h1>${pageTitle}</h1>
49
- <h2>
50
- ${content}
51
- </h2>
52
- ${button}
53
- <div class="documentation">
54
- Checkout Blocklet Server Documentation: <a
55
- href="https://docs.arcblock.io/en/abtnode/">https://docs.arcblock.io/en/abtnode/</a>
56
- </div>
57
- <div style="margin-top: 100px;font-size: 12px;color: #fff;line-height: 1.4;">
58
- <div>Blocklet Server version: ${nodeInfo.version}, mode: ${nodeInfo.mode}</div>
59
- </div>
60
- </center>
61
- </body>
62
-
63
- </html>`;
8
+ return res;
9
+ }, {});
10
+
11
+ module.exports = ({
12
+ status: inputStatus,
13
+ icon,
14
+ title = '',
15
+ pageTitle = '',
16
+ content = '',
17
+ nodeInfo = {},
18
+ refreshButton = false,
19
+ extra,
20
+ }) => {
21
+ const button = refreshButton
22
+ ? `
23
+ <style>
24
+ button {
25
+ font-size: 0.9375rem;
26
+ border-radius: 20px;
27
+ color: #FFFFFF;
28
+ background-color: #4E6AF6;
29
+ padding: 8px 22px;
30
+ box-shadow: none;
31
+ text-transform: capitalize;
32
+ border: 0;
33
+ outline: 0;
34
+ cursor: pointer;
35
+ }
36
+ button:hover {
37
+ background-color: rgb(54, 74, 172);
38
+ }
39
+ </style>
40
+ <div>Please click me to <button onclick="javascript:window.location.reload(true)">Refresh</button><div>
41
+ `
42
+ : '';
43
+ const hiddenText = `Blocklet Server version: ${nodeInfo.version}, mode: ${nodeInfo.mode}`;
44
+
45
+ const status = inputStatus === undefined ? 'error' : inputStatus;
46
+
47
+ return render(
48
+ filterNullOrUndefined({
49
+ status,
50
+ icon,
51
+ pageTitle,
52
+ title,
53
+ description: content,
54
+ hiddenText,
55
+ extra: extra || button,
56
+ })
57
+ );
64
58
  };
package/lib/welcome.js CHANGED
@@ -1,42 +1,27 @@
1
- module.exports = (nodeInfo = {}) => `<!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Welcome - Blocklet Server</title>
7
- <style>
8
- html {
9
- font-size: 16px;
10
- font-family: 'Roboto';
11
- width: 100%;
12
- height: 100%;
13
- }
14
- h1 {
15
- color: #00c2c4;
16
- font-size: 3rem;
17
- }
18
- h2 {
19
- font-size: 2rem;
20
- }
21
- a {
22
- font-size: 2rem;
23
- }
24
- a:first-of-type {
25
- margin-right: 2rem;
26
- }
27
- </style>
28
- </head>
29
- <body>
30
- <center>
31
- <h1>Congratulations!</h1>
32
- <h2>Your Blocklet Server is up and running!</h2>
33
- <div>
34
- <a href="/${(nodeInfo.routing.adminPath || '').replace(/^\//, '')}">Node Dashboard</a>
35
- <a href="https://docs.arcblock.io/en/abtnode/">Documentation</a>
36
- </div>
37
- <div style="margin-top: 100px;font-size: 12px;color: #fff;line-height: 1.4;">
38
- <div>Blocklet Server version: ${nodeInfo.version}, mode: ${nodeInfo.mode}</div>
39
- </div>
40
- </center>
41
- </body>
42
- </html>`;
1
+ const common = require('./common');
2
+
3
+ module.exports = (nodeInfo = {}) => {
4
+ const extra = `
5
+ <div style="margin-top: 3rem;">
6
+ <a href="/${(nodeInfo.routing.adminPath || '').replace(
7
+ /^\//,
8
+ ''
9
+ )}" style="color: #47494E; margin-right: 2rem;">Dashboard</a>
10
+ <a href="https://docs.arcblock.io/en/abtnode/" style="color: #47494E;">Document</a>
11
+ </div>
12
+ `;
13
+ return common({
14
+ icon: `<svg xmlns="http://www.w3.org/2000/svg" style="width: 45px; height: 52px;" viewBox="0 0 45 52">
15
+ <g fill="none" fill-rule="evenodd" stroke="#000">
16
+ <path d="M.5 13.077L22.15.577l21.651 12.5v25l-21.65 12.5L.5 38.077zM22.15.577v50M.5 13.077l43.301 25M.5 38.077l43.301-25"/>
17
+ <path d="M22.15 38.077l10.826-6.25-10.825-18.75-10.825 18.75z"/>
18
+ </g>
19
+ </svg>`,
20
+ pageTitle: 'Welcome - Blocklet Server',
21
+ title: 'Congratulations!',
22
+ content: 'Your Blocklet Server is up and running!',
23
+ status: null,
24
+ nodeInfo,
25
+ extra,
26
+ });
27
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.16",
6
+ "version": "1.6.17",
7
7
  "description": "Provide page templates for ABT Node router",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,10 +19,11 @@
19
19
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@blocklet/meta": "1.6.16"
22
+ "@arcblock/result-html-pages": "^1.6.20",
23
+ "@blocklet/meta": "1.6.17"
23
24
  },
24
25
  "devDependencies": {
25
26
  "jest": "^27.4.5"
26
27
  },
27
- "gitHead": "69b08db16aeb75ce23b0e6bb5b9fa396adba2d4b"
28
+ "gitHead": "d567a622a779eba43c95eaeb4633cb2b276bb7b9"
28
29
  }