diff --git a/components/component-import-url/actions/build.js b/components/component-import-url/actions/build.js
new file mode 100644
index 0000000..57e56f3
--- /dev/null
+++ b/components/component-import-url/actions/build.js
@@ -0,0 +1,34 @@
+function(builderTemplate, data) {
+ var build = builderTemplate;
+ let replacements = {
+ "shortcuts" : editor.transformers.simplyPreviewShortcuts.render(data.shortcuts ?? []),
+ "actions" : editor.transformers.simplyPreviewActions.render(data.actions ?? []),
+ "commands" : editor.transformers.simplyPreviewCommands.render(data.commands ?? []),
+ "dataApi" : editor.transformers.simplyPreviewDataApi.render(data.dataApi ?? []),
+ "rawApi" : editor.transformers.simplyPreviewRawApi.render(data.rawApi ?? []),
+ "routes" : editor.transformers.simplyPreviewRoutes.render(data.routes ?? []),
+ "dataSources" : editor.transformers.simplyPreviewDataSources.render(data.dataSources ?? []),
+ "transformers" : editor.transformers.simplyPreviewTransformers.render(data.transformers ?? []),
+ "sorters" : editor.transformers.simplyPreviewSorters.render(data.sorters ?? []),
+ "pageTemplates" :editor.transformers.simplyPreviewPageTemplates.render(data.pageTemplates ?? []),
+ "pageCss" : editor.transformers.simplyPreviewPageCss.render(data.pageCss ?? []),
+ "componentCss" : editor.transformers.simplyPreviewComponentCss.render(data.componentCss ?? []),
+ "componentTemplates" : editor.transformers.simplyPreviewComponentTemplates.render(data.componentTemplates ?? []),
+ "headHtml": editor.transformers.simplyPreviewHeadHtml.render(data.headHtml ?? []),
+ "footHtml": editor.transformers.simplyPreviewFootHtml.render(data.footHtml ?? []),
+ "bodyHtml" : editor.transformers.simplyPreviewBodyHtml.render(data.bodyHtml ?? [])
+ };
+
+ Object.keys(replacements).forEach(function(replacement) {
+ matches = build.match("(\\s*){{" + replacement + "}}");
+ if (matches) {
+ let indentedNewline = matches[1];
+ if (indentedNewline == '') {
+ indentedNewline = "\n";
+ }
+ build = build.replace("{{" + replacement + "}}", replacements[replacement].replace(/\n/g, indentedNewline));
+ }
+ });
+
+ return build;
+}
\ No newline at end of file
diff --git a/components/component-import-url/commands/addImportUrl.js b/components/component-import-url/commands/addImportUrl.js
new file mode 100644
index 0000000..8b0960d
--- /dev/null
+++ b/components/component-import-url/commands/addImportUrl.js
@@ -0,0 +1,3 @@
+function(el) {
+ editor.pageData.component.parts.importUrls.push({});
+}
\ No newline at end of file
diff --git a/components/component-import-url/componentCss/simplycode-import-url.css b/components/component-import-url/componentCss/simplycode-import-url.css
new file mode 100644
index 0000000..e8b4b6a
--- /dev/null
+++ b/components/component-import-url/componentCss/simplycode-import-url.css
@@ -0,0 +1,5 @@
+.simplycode-editor-url input {
+ width: 100%;
+ padding: 10px;
+ font-size: 1.2em;
+}
\ No newline at end of file
diff --git a/components/component-import-url/componentTemplates/componentImportUrl.html b/components/component-import-url/componentTemplates/componentImportUrl.html
new file mode 100644
index 0000000..9b26cfc
--- /dev/null
+++ b/components/component-import-url/componentTemplates/componentImportUrl.html
@@ -0,0 +1,36 @@
+
+
+
+ Import URL
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/component-import-url/meta.json b/components/component-import-url/meta.json
new file mode 100644
index 0000000..a7653c3
--- /dev/null
+++ b/components/component-import-url/meta.json
@@ -0,0 +1 @@
+{"id":"component-import-url","description":"Edit form for component import URL"}
\ No newline at end of file
diff --git a/components/data-format/dataApi/mergeComponent.js b/components/data-format/dataApi/mergeComponent.js
index 42d929f..1274d24 100644
--- a/components/data-format/dataApi/mergeComponent.js
+++ b/components/data-format/dataApi/mergeComponent.js
@@ -118,6 +118,23 @@ function(component) {
componentPart.contents = JSON.stringify(Object.values(contents));
}
break;
+ case "importUrls":
+ if (typeof componentPart.contents === "object") {
+ var contents = {};
+ componentPart.contents.forEach(function(partFile) {
+ if (partFile.id.match(/\.url$/)) {
+ partId = partFile.id.replace(/\.url$/, '');
+ if (typeof contents[partId] === "undefined") {
+ contents[partId] = {
+ import : partId
+ }
+ }
+ contents[partId]['url'] = partFile.contents;
+ }
+ });
+ componentPart.contents = JSON.stringify(Object.values(contents));
+ }
+ break;
case "rawApi":
case "dataApi":
if (typeof componentPart.contents === "object") {
diff --git a/components/data-format/dataApi/savePart.js b/components/data-format/dataApi/savePart.js
index 07053da..8329632 100644
--- a/components/data-format/dataApi/savePart.js
+++ b/components/data-format/dataApi/savePart.js
@@ -109,6 +109,22 @@ function(basePath, part, contents) {
}
});
break;
+ case "importUrls":
+ contents.forEach(function(componentPart, componentIndex) {
+ if (!componentPart.url) {
+ throw new Error("Required part name is empty");
+ }
+ if (componentPart.deleted == "true") {
+ results.push(simplyRawApi.delete(basePath + "/" + part + "/" + componentPart.import + ".url"));
+ contents.splice(componentIndex, 1);
+ } else {
+ results.push(simplyRawApi.putRaw(
+ basePath + "/" + part + "/" + componentPart.import + ".url", {},
+ componentPart.url
+ ));
+ }
+ });
+ break;
case "rawApi":
case "dataApi":
contents.forEach(function(componentPart, componentIndex) {
diff --git a/components/navigation/actions/getMainMenu.js b/components/navigation/actions/getMainMenu.js
index 6c7a731..e2154b1 100644
--- a/components/navigation/actions/getMainMenu.js
+++ b/components/navigation/actions/getMainMenu.js
@@ -36,6 +36,13 @@ function() {
href : "#builders",
"data-path" : "builders"
}
+ },
+ {
+ item : {
+ innerHTML : "Imports",
+ href : "#imports",
+ "data-path" : "imports"
+ }
}
]
);
diff --git a/components/simply-toolbar/componentTemplates/simply-toolbar-import.html b/components/simply-toolbar/componentTemplates/simply-toolbar-import.html
new file mode 100644
index 0000000..86b59ef
--- /dev/null
+++ b/components/simply-toolbar/componentTemplates/simply-toolbar-import.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/simply-toolbar/componentTemplates/simply-toolbar.html b/components/simply-toolbar/componentTemplates/simply-toolbar.html
index 7113990..a504805 100644
--- a/components/simply-toolbar/componentTemplates/simply-toolbar.html
+++ b/components/simply-toolbar/componentTemplates/simply-toolbar.html
@@ -1,6 +1,7 @@