1 | var generateIndexHtmlContent = ({
|
2 | bootScriptPath = "",
|
3 | bootScript = "",
|
4 | resourceRoot = "https://openui5.hana.ondemand.com/resources/",
|
5 | theme = "sap_belize",
|
6 | projectNameSpace = "",
|
7 | preload = false,
|
8 | title = "UI5 Application",
|
9 | inlineCssLink = [],
|
10 | inlineJsSrc = [],
|
11 | offline = false,
|
12 | resourceRoots = { projectNameSpace: "." }
|
13 | }) => {
|
14 |
|
15 | var sapUiCodeLink = `${resourceRoot}sap-ui-core.js`;
|
16 |
|
17 | if (!resourceRoot.endsWith("/")) {
|
18 | resourceRoot = `${resourceRoot}/`;
|
19 | }
|
20 |
|
21 | if (offline) {
|
22 | sapUiCodeLink = "./resources/sap-ui-core.js";
|
23 | }
|
24 |
|
25 | if (preload) {
|
26 | inlineJsSrc.push("./preload.js");
|
27 | inlineJsSrc.push("./Component-preload.js");
|
28 | }
|
29 |
|
30 | var jsSrcs = inlineJsSrc.map(l => `<script src="${l}"></script>`).join("\n");
|
31 |
|
32 | var cssLinks = inlineCssLink
|
33 | .map(l => `<link rel="stylesheet" href="${l}">`)
|
34 | .join("\n");
|
35 |
|
36 | var sBootScript = "";
|
37 |
|
38 | if (bootScriptPath) {
|
39 | sBootScript = `<script src="${bootScriptPath}"></script>`;
|
40 | } else if (bootScript) {
|
41 | sBootScript = `<script>${bootScript}</script>`;
|
42 | }
|
43 |
|
44 | return `<!DOCTYPE html>
|
45 | <html>
|
46 |
|
47 | <head>
|
48 | <meta http-equiv="X-UA-Compatible" content="IE=edge">
|
49 | <meta charset="utf-8">
|
50 | <title>
|
51 | ${title}
|
52 | </title>
|
53 | <script
|
54 | id="sap-ui-bootstrap"
|
55 | src="${sapUiCodeLink}"
|
56 | data-sap-ui-theme="${theme}"
|
57 | data-sap-ui-compatVersion="edge"
|
58 | data-sap-ui-resourceroots='${JSON.stringify(resourceRoots)}'
|
59 | >
|
60 | </script>
|
61 | ${jsSrcs}
|
62 | </head>
|
63 |
|
64 | ${cssLinks}
|
65 |
|
66 | <body class="sapUiBody" id="content">
|
67 | ${sBootScript}
|
68 | </body>
|
69 |
|
70 | </html>`;
|
71 | };
|
72 |
|
73 | module.exports = { generateIndexHtmlContent };
|