From 988d99ae472ebb57f7562814d2909bd4a2c8fb6c Mon Sep 17 00:00:00 2001
From: Peter Crackenberg CascadeAsset
](#CascadeAsset)
* [.createBlankFile()](#Cascade+createBlankFile) ⇒ [CascadeAsset
](#CascadeAsset)
+ * [.createBlankFolder()](#Cascade+createBlankFolder) ⇒ [CascadeAsset
](#CascadeAsset)
* [.APICall(operation, [type], [assetIDPath], [assetObject])](#Cascade+APICall) ⇒ Object
* [.readPage(path)](#Cascade+readPage) ⇒ Object
* [.readFile(path)](#Cascade+readFile) ⇒ Object
+ * [.readFolder(path)](#Cascade+readFolder) ⇒ Object
* [.deletePage(path)](#Cascade+deletePage) ⇒ Object
* [.deleteFile(path)](#Cascade+deleteFile) ⇒ Object
+ * [.deleteFolder(path)](#Cascade+deleteFolder) ⇒ Object
* [.editPage(assetObject)](#Cascade+editPage) ⇒ Object
* [.editFile(assetObject)](#Cascade+editFile) ⇒ Object
+ * [.editFolder(assetObject)](#Cascade+editFolder) ⇒ Object
* [.publishPage(path)](#Cascade+publishPage) ⇒ Object
* [.publishFile(path)](#Cascade+publishFile) ⇒ Object
+ * [.publishFolder(path)](#Cascade+publishFolder) ⇒ Object
* [.createPage(assetObject)](#Cascade+createPage) ⇒ Object
* [.createFile(assetObject)](#Cascade+createFile) ⇒ Object
+ * [.createFolder(assetObject)](#Cascade+createFolder) ⇒ Object
@@ -96,6 +102,13 @@ Return a blank file, this is helpful when creating new assets.
**Kind**: instance method of [Cascade
](#Cascade)
**Returns**: [CascadeAsset
](#CascadeAsset) - Blank file
+
+
+### cascade.createBlankFolder() ⇒ [CascadeAsset
](#CascadeAsset)
+Return a blank folder, this is helpful when creating new assets.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: [CascadeAsset
](#CascadeAsset) - Blank folder
### cascade.APICall(operation, [type], [assetIDPath], [assetObject]) ⇒ Object
@@ -152,6 +165,22 @@ Read a file, given a path or ID (depending on the mode of the Cascade object) an
| --- | --- | --- |
| path | string
| Path or ID of file to read |
+
+
+### cascade.readFolder(path) ⇒ Object
+Read a folder, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response. Page that was found will be in the .asset.page attribute
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of folder to read |
+
### cascade.deletePage(path) ⇒ Object
@@ -184,6 +213,22 @@ Delete a file, given a path or ID (depending on the mode of the Cascade object)
| --- | --- | --- |
| path | string
| Path or ID of file to delete |
+
+
+### cascade.deleteFolder(path) ⇒ Object
+Delete a folder, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of folder to delete |
+
### cascade.editPage(assetObject) ⇒ Object
@@ -218,6 +263,23 @@ but it can be manually created as well.
| --- | --- | --- |
| assetObject | Object
| Cascade object representing the file. |
+
+
+### cascade.editFolder(assetObject) ⇒ Object
+Edit a folder, given a Cascade folder object. Typically the page to edit is read in via [readFolder](#Cascade+readFolder),
+but it can be manually created as well.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| assetObject | Object
| Cascade object representing the folder. |
+
### cascade.publishPage(path) ⇒ Object
@@ -250,6 +312,22 @@ Publish a file, given a path or ID (depending on the mode of the Cascade object)
| --- | --- | --- |
| path | string
| Path or ID of file to publish. |
+
+
+### cascade.publishFolder(path) ⇒ Object
+Publish a folder, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of folder to publish. |
+
### cascade.createPage(assetObject) ⇒ Object
@@ -270,7 +348,7 @@ but it can be created manually as well.
### cascade.createFile(assetObject) ⇒ Object
-Create a file, given a Cascade file object. Typically this is created using [createBlanFile](#Cascade+createBlankFile),
+Create a file, given a Cascade file object. Typically this is created using [createBlankFile](#Cascade+createBlankFile),
but it can be created manually as well.
**Kind**: instance method of [Cascade
](#Cascade)
@@ -284,6 +362,23 @@ but it can be created manually as well.
| --- | --- | --- |
| assetObject | Object
| Cascade object representing the file. |
+
+
+### cascade.createFolder(assetObject) ⇒ Object
+Create a folder, given a Cascade folder object. Typically this is created using [createBlankFolder](#Cascade+createBlankFolder),
+but it can be created manually as well.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| assetObject | Object
| Cascade object representing the folder. |
+
## CascadeAsset
diff --git a/documentation/folder-functions.md b/documentation/folder-functions.md
new file mode 100644
index 0000000..cf90bec
--- /dev/null
+++ b/documentation/folder-functions.md
@@ -0,0 +1,88 @@
+# Folder Functions
+
+## Read Folder
+
+```javascript
+cascadeAPI.readFolder("/test")
+.then(response=>{
+ console.log("Success reading folder:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Erroring reading folder:");
+ console.error(error);
+});
+```
+
+## Edit Folder
+
+```javascript
+cascadeAPI.readFolder("/test/test2")
+.then(response=>{
+ console.log("Success reading folder:");
+ const foundFolder = response.asset.folder;
+ foundFolder.metadata.displayName = "New Display Name";
+ cascadeAPI.editFolder(foundFolder)
+ .then(response=>{
+ console.log("Success editing folder:");
+ console.log(response);
+ })
+ .catch(error => {
+ console.errer("Error editing folder:");
+ console.errer(error);
+ });
+})
+.catch(error=>{
+ console.error("Error reading folder:");
+ console.error(error);
+});
+```
+
+## Create Folder
+The same as creating a new page, an asset must be sent when creating a new folder. There is a `createBlankFolder()` helper function for this as well. Unlike a page the only things that are required are `siteName`, `parentFolderPath` and `name`.
+
+The asset ID of the newly created folder will be returned on success.
+```javascript
+const newFolder = cascadeAPI.createBlankFolder();
+newFolder.siteName = cascadeAPI.site;
+newFolder.parentFolderPath = "/test";
+newFolder.name = "test2";
+console.log(newFolder);
+cascadeAPI.createFolder(newFolder)
+.then(response=>{
+ console.log("Success creating folder:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error creating folder:");
+ console.error(error);
+});
+```
+
+## Delete Folder
+
+```javascript
+cascadeAPI.deleteFolder("/test/test2")
+.then(response=>{
+ console.log("Success deleting folder:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error deleting folder:");
+ console.error(error);
+});
+```
+
+## Publish Folder
+
+```javascript
+cascadeAPI.publishFolder("/test/test2")
+.then(response=>{
+ console.log("Success publishing folder:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error publishing folder:");
+ console.error(error);
+});
+```
\ No newline at end of file
From e5110f36c06df35758edeb552b7dc6bd1d0c576a Mon Sep 17 00:00:00 2001
From: Peter Crackenberg
These are returned by the createBlankPage and -createBlankFile methods.
+Typically used to create new objects when using the createPage, +createFile, and createFolder functions.
+These are returned by the createBlankPage, +createBlankFile, and createBlankFolder methods.
@@ -386,11 +386,11 @@ Class to represent assets to submit into Cascade Server. These are generally use when creating a new asset, as it makes it easier than creating the required properties from scratch. -Typically used to create new objects when using the [createPage](#Cascade+createPage) and -[createFile](#Cascade+createFile) functions. +Typically used to create new objects when using the [createPage](#Cascade+createPage), +[createFile](#Cascade+createFile), and [createFolder](#Cascade+createFolder) functions. -These are returned by the [createBlankPage](#Cascade+createBlankPage) and -[createBlankFile](#Cascade+createBlankFile) methods. +These are returned by the [createBlankPage](#Cascade+createBlankPage), +[createBlankFile](#Cascade+createBlankFile), and [createBlankFolder](#Cascade+createBlankFolder) methods. **Kind**: global class @@ -401,5 +401,5 @@ Create a new CascadeAsset object. | Param | Type | Default | Description | | --- | --- | --- | --- | -| [type] |string
| "page"
| Either page or file, defaults to page. |
+| [type] | string
| "page"
| Either page, file, or folder. Defaults to page. |
From 44588408961c9f349ed6c3f0fde02a3be857e7d2 Mon Sep 17 00:00:00 2001
From: Peter Crackenberg CascadeAsset
](#CascadeAsset)
* [.createBlankFile()](#Cascade+createBlankFile) ⇒ [CascadeAsset
](#CascadeAsset)
* [.createBlankFolder()](#Cascade+createBlankFolder) ⇒ [CascadeAsset
](#CascadeAsset)
- * [.APICall(operation, [type], [assetIDPath], [assetObject])](#Cascade+APICall) ⇒ Object
+ * [.APICall(operation, [type], [assetIDPath], [assetObject], [ajaxParameters])](#Cascade+APICall) ⇒ Object
* [.readPage(path)](#Cascade+readPage) ⇒ Object
* [.readFile(path)](#Cascade+readFile) ⇒ Object
* [.readFolder(path)](#Cascade+readFolder) ⇒ Object
@@ -53,6 +53,17 @@ Otherwise it will use a Cascade asset ID. You can swap modes using the [useId](#
* [.createPage(assetObject)](#Cascade+createPage) ⇒ Object
* [.createFile(assetObject)](#Cascade+createFile) ⇒ Object
* [.createFolder(assetObject)](#Cascade+createFolder) ⇒ Object
+ * [.movePage(path, newName, folderPath)](#Cascade+movePage) ⇒ Object
+ * [.moveFile(path, newName, folderPath)](#Cascade+moveFile) ⇒ Object
+ * [.moveFolder(path, newName, folderPath)](#Cascade+moveFolder) ⇒ Object
+ * [.doMove(path, newName, folderPath, type)](#Cascade+doMove) ⇒ Object
+ * [.copyPage(path, newName, folderPath)](#Cascade+copyPage) ⇒ Object
+ * [.copyFile(path, newName, folderPath)](#Cascade+copyFile) ⇒ Object
+ * [.copyFolder(path, newName, folderPath)](#Cascade+copyFolder) ⇒ Object
+ * [.makeCopy(path, newName, folderPath, type)](#Cascade+makeCopy) ⇒ Object
+ * [.checkRelationshipsPage(path)](#Cascade+checkRelationshipsPage) ⇒ Object
+ * [.checkRelationshipsFile(path)](#Cascade+checkRelationshipsFile) ⇒ Object
+ * [.checkRelationshipsFolder(path)](#Cascade+checkRelationshipsFolder) ⇒ Object
@@ -111,7 +122,7 @@ Return a blank folder, this is helpful when creating new assets.
**Returns**: [CascadeAsset
](#CascadeAsset) - Blank folder
-### cascade.APICall(operation, [type], [assetIDPath], [assetObject]) ⇒ Object
+### cascade.APICall(operation, [type], [assetIDPath], [assetObject], [ajaxParameters]) ⇒ Object
Make an API call. Using the pre-defined functions is generally preferred, but if not all APIs
have wrapper functions, this can be called directly. While most parameters are optional,
most calls will need some number of them to be included.
@@ -132,6 +143,7 @@ did not succeed. The error should be caught on the front end.
| [type] | string
| false
| Optional. Required for calls where an identifier is needed (read, publish, etc). If not needed use default. |
| [assetIDPath] | string
| false
| Optional. Either the path or id of the asset, needed where an identifier is needed, like type. If not needed use default. |
| [assetObject] | Object
| false
| Optional. Asset to be acted upon, needed for some calls (create, edit). Must have an attribute for the asset type that's being acted upon (page, block, etc) |
+| [ajaxParameters] | Object
| false
| Optional. Parameters to be added to the body, examples being copyParameters or moveParameters which are required for those operations. |
@@ -379,6 +391,209 @@ but it can be created manually as well.
| --- | --- | --- |
| assetObject | Object
| Cascade object representing the folder. |
+
+
+### cascade.movePage(path, newName, folderPath) ⇒ Object
+Do a move operation on a page, given a path, name, and folder. Unlike the Move and Rename operations in Cascade,
+which have separate functionality, this combines them into a single operation.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of the page to move. |
+| newName | string
| New name of the page. If the asset is being moved to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to move to. If the asset is not being moved to a different folder, this can be the same as the current folder. |
+
+
+
+### cascade.moveFile(path, newName, folderPath) ⇒ Object
+Do a move operation on a file, given a path, name, and folder. Unlike the Move and Rename operations in Cascade,
+which have separate functionality, this combines them into a single operation.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of the file to move. |
+| newName | string
| New name of the file. If the asset is being moved to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to move to. If the asset is not being moved to a different folder, this can be the same as the current folder. |
+
+
+
+### cascade.moveFolder(path, newName, folderPath) ⇒ Object
+Do a move operation on a folder, given a path, name, and folder. Unlike the Move and Rename operations in Cascade,
+which have separate functionality, this combines them into a single operation.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of the folder to move. |
+| newName | string
| New name of the folder. If the asset is being moved to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to move to. If the asset is not being moved to a different folder, this can be the same as the current folder. |
+
+
+
+### cascade.doMove(path, newName, folderPath, type) ⇒ Object
+Do a move operation on an asset, given a path, name, folder, and type. Unlike the Move and Rename operations in Cascade,
+which have separate functionality, this combines them into a single operation.
+
+This should generally not be called directly, and instead a wrapper function like [movePage](#Cascade+movePage) or [moveFile](#Cascade+moveFile) should
+be used instead. But if you need to move or rename an asset that doesn't have a type this can be used.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of the asset to move. |
+| newName | string
| New name of the asset. If the asset is being moved to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to move to. If the asset is not being moved to a different folder, this can be the same as the current folder. |
+| type | string
| Type of the asset being moved. |
+
+
+
+### cascade.copyPage(path, newName, folderPath) ⇒ Object
+Make a copy of a a page, given a path, type, new name, and folder.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of page to copy. |
+| newName | string
| New name of the page. If the asset is being copied to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to copy to. If the asset is not being copied to a different folder, this can be the same as the current folder. |
+
+
+
+### cascade.copyFile(path, newName, folderPath) ⇒ Object
+Make a copy of a a file, given a path, type, new name, and folder.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of file to copy. |
+| newName | string
| New name of the file. If the asset is being copied to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to copy to. If the asset is not being copied to a different folder, this can be the same as the current folder. |
+
+
+
+### cascade.copyFolder(path, newName, folderPath) ⇒ Object
+Make a copy of a a folder, given a path, type, new name, and folder.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of folder to copy. |
+| newName | string
| New name of the folder. If the asset is being copied to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to copy to. If the asset is not being copied to a different folder, this can be the same as the current folder. |
+
+
+
+### cascade.makeCopy(path, newName, folderPath, type) ⇒ Object
+Make a copy of an asset, given a path, type, new name, and folder. This should generally not be called directly,
+and instead a wrapper method like [copyPage](#Cascade+copyPage) or [copyFile](#Cascade+copyFile) should
+be used. If the type doesn't have a wrapper function, this can be used instead.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of asset to copy. |
+| newName | string
| New name of the item to use. If the asset is being copied to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to copy to. If the asset is not being copied to a different folder, this can be the same as the current folder. |
+| type | string
| Type of the asset being copied. |
+
+
+
+### cascade.checkRelationshipsPage(path) ⇒ Object
+Check relationships for a page, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of page to check. |
+
+
+
+### cascade.checkRelationshipsFile(path) ⇒ Object
+Check relationships for a file, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of file to check. |
+
+
+
+### cascade.checkRelationshipsFolder(path) ⇒ Object
+Check relationships for a folder, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of folder to check. |
+
## CascadeAsset
diff --git a/test-cascade-api.js b/test-cascade-api.js
index d57ec20..23b7b5c 100644
--- a/test-cascade-api.js
+++ b/test-cascade-api.js
@@ -3,7 +3,7 @@
const Cascade = require("./cascade.js");
// Replace values with your Cascade API URL, password, and site
-const cascadeAPI = new Cascade("https://cascade.example.edu","username","password","site name");
+const cascadeAPI = new Cascade("https://cascade.georgefox.edu",{apiKey: "API_KEY"},"www Redesign");
// Example reading a page
/*
@@ -46,6 +46,19 @@ cascadeAPI.readFile("/template/t1/css/main.css")
});
*/
+// Exmaple reading a folder
+/*
+cascadeAPI.readFolder("/test")
+.then(response=>{
+ console.log("Success reading folder:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Erroring reading folder:");
+ console.error(error);
+});
+*/
+
// Create New Page
/*
const newPage = cascadeAPI.createBlankPage();
@@ -113,6 +126,37 @@ cascadeAPI.deleteFile("/test/test.txt")
});
*/
+// Example creating a folder
+/*
+const newFolder = cascadeAPI.createBlankFolder();
+newFolder.siteName = cascadeAPI.site;
+newFolder.parentFolderPath = "/test";
+newFolder.name = "test2";
+console.log(newFolder);
+cascadeAPI.createFolder(newFolder)
+.then(response=>{
+ console.log("Success creating folder:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error creating folder:");
+ console.error(error);
+});
+*/
+
+// Delete Folder
+/*
+cascadeAPI.deleteFolder("/test/test2")
+.then(response=>{
+ console.log("Success deleting folder:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error deleting folder:");
+ console.error(error);
+});
+*/
+
// Example editing a page
/*
cascadeAPI.readPage("/test/test")
@@ -159,6 +203,28 @@ cascadeAPI.readFile("/test/test.txt")
});
*/
+// Example editing a folder
+/*
+cascadeAPI.readFolder("/test/test2")
+.then(response=>{
+ console.log("Success reading folder:");
+ const foundFolder = response.asset.folder;
+ foundFolder.name = "new-name";
+ cascadeAPI.editFolder(foundFolder)
+ .then(response=>{
+ console.log("Success editing folder:");
+ console.log(response);
+ })
+ .catch(error => {
+ console.errer("Error editing folder:");
+ console.errer(error);
+ });
+})
+.catch(error=>{
+ console.error("Error reading folder:");
+ console.error(error);
+});
+*/
// Example publishing a page
/*
@@ -186,9 +252,139 @@ cascadeAPI.publishFile("/test/test.txt")
});
*/
+// Example publishing a folder
+/*
+cascadeAPI.publishFolder("/test/test2")
+.then(response=>{
+ console.log("Success publishing folder:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error publishing folder:");
+ console.error(error);
+});
+*/
+
+// Example checking relationships on a page
+/*
+cascadeAPI.checkRelationshipsPage("/test/page-1")
+.then(response=>{
+ console.log("Success getting relationships:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error getting relationships:");
+ console.error(error);
+});
+*/
+
+// Example checking relationships on a file
+/*
+cascadeAPI.checkRelationshipsFile("/test/_assets-image-file-test/images/airplane.png")
+.then(response=>{
+ console.log("Success getting relationships:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error getting relationships:");
+ console.error(error);
+});
+*/
+
+// Example checking relationships on a folder
+/*
+cascadeAPI.checkRelationshipsFolder("/test")
+.then(response=>{
+ console.log("Success getting relationships:");
+ console.log(response);
+})
+.catch(error=>{
+ console.error("Error getting relationships:");
+ console.error(error);
+});
+*/
+
+// Example copying a page
+/*
+cascadeAPI.copyPage("/test/page","page-copy",{path:"/test"})
+.then(response=>{
+ console.log("Copy succeeded");
+ console.log(response);
+})
+.catch(error=>{
+ console.log("Copy failed");
+ console.log(error);
+});
+*/
+
+// Example copying a file
+/*
+cascadeAPI.copyFile("/test/test-banner.jpg","test-banner-copy.jpg",{path:"/test"})
+.then(response=>{
+ console.log("Copy succeeded");
+ console.log(response);
+})
+.catch(error=>{
+ console.log("Copy failed");
+ console.log(error);
+});
+*/
+
+// Example copying a folder
+/*
+cascadeAPI.copyFolder("/test/subfolder","subfolder-copy",{path:"/test"})
+.then(response=>{
+ console.log("Copy succeeded");
+ console.log(response);
+})
+.catch(error=>{
+ console.log("Copy failed");
+ console.log(error);
+});
+*/
+
+// Example moving a page
+/*
+cascadeAPI.movePage("/test/page","page-new",{path:"/test"})
+.then(response=>{
+ console.log("Move succeeded");
+ console.log(response);
+})
+.catch(error=>{
+ console.log("Move failed");
+ console.log(error);
+});
+*/
+
+// Example moving a file
+/*
+cascadeAPI.moveFile("/test/test-banner.jpg","test-banner-new.jpg",{path:"/test"})
+.then(response=>{
+ console.log("Move succeeded");
+ console.log(response);
+})
+.catch(error=>{
+ console.log("Move failed");
+ console.log(error);
+});
+*/
+
+// Example moving a folder
+/*
+cascadeAPI.moveFolder("/test/subfolder","subfolder-new",{path:"/test"})
+.then(response=>{
+ console.log("Move succeeded");
+ console.log(response);
+})
+.catch(error=>{
+ console.log("Move failed");
+ console.log(error);
+});
+*/
+
// Example making a direct API call
/*
-cascadeAPI.APICall("listSubscribers","page","/counseling-programs/index")
+cascadeAPI.APICall("readAccessRights","page","/counseling-programs/index")
.then(response=>{
console.log("Call succeeded");
console.log(response);
From ea2604ff768f4cbf8ce99a707452593506457599 Mon Sep 17 00:00:00 2001
From: Peter Crackenberg Test content
"; +console.log(newBlock); +cascadeAPI.createBlock(newBlock) +.then(response=>{ + console.log("Success creating block:"); + console.log(response); +}) +.catch(error=>{ + console.error("Error creating block:"); + console.error(error); +}); +*/ + +// Delete block +/* +cascadeAPI.deleteBlock("/test/test-block") +.then(response=>{ + console.log("Success deleting block:"); + console.log(response); +}) +.catch(error=>{ + console.error("Error deleting block:"); + console.error(error); +}); +*/ + // Example editing a page /* cascadeAPI.readPage("/test/test") @@ -226,6 +272,29 @@ cascadeAPI.readFolder("/test/test2") }); */ +// Example editing a block +/* +cascadeAPI.readBlock("/test/test-block") +.then(response=>{ + console.log("Success reading block:"); + const foundBlock = response.asset.xhtmlDataDefinitionBlock; + foundBlock.xhtml = "New content
"; + cascadeAPI.editBlock(foundBlock) + .then(response=>{ + console.log("Success editing block:"); + console.log(response); + }) + .catch(error => { + console.errer("Error editing block:"); + console.errer(error); + }); +}) +.catch(error=>{ + console.error("Error reading block:"); + console.error(error); +}); +*/ + // Example publishing a page /* cascadeAPI.publishPage("/test/test") @@ -304,6 +373,19 @@ cascadeAPI.checkRelationshipsFolder("/test") }); */ +// Example checking relationships on a block +/* +cascadeAPI.checkRelationshipsBlock("/test/block") +.then(response=>{ + console.log("Success getting relationships:"); + console.log(response); +}) +.catch(error=>{ + console.error("Error getting relationships:"); + console.error(error); +}); +*/ + // Example copying a page /* cascadeAPI.copyPage("/test/page","page-copy",{path:"/test"}) @@ -343,6 +425,19 @@ cascadeAPI.copyFolder("/test/subfolder","subfolder-copy",{path:"/test"}) }); */ +// Example copying a block +/* +cascadeAPI.copyBlock("/test/test-block","test-block-copy",{path:"/test"}) +.then(response=>{ + console.log("Copy succeeded"); + console.log(response); +}) +.catch(error=>{ + console.log("Copy failed"); + console.log(error); +}); +*/ + // Example moving a page /* cascadeAPI.movePage("/test/page","page-new",{path:"/test"}) @@ -382,6 +477,19 @@ cascadeAPI.moveFolder("/test/subfolder","subfolder-new",{path:"/test"}) }); */ +// Example moving a block +/* +cascadeAPI.moveBlock("/test/test-block","test-block-new",{path:"/test"}) +.then(response=>{ + console.log("Move succeeded"); + console.log(response); +}) +.catch(error=>{ + console.log("Move failed"); + console.log(error); +}); +*/ + // Example making a direct API call /* cascadeAPI.APICall("readAccessRights","page","/counseling-programs/index") From 7f7c7e9cdf41ab6aed2c9869919edd9e769fbad7 Mon Sep 17 00:00:00 2001 From: Peter CrackenbergTest content
"; From 2276e70f9e1cc6e15129b7daa11a50e43103f239 Mon Sep 17 00:00:00 2001 From: Peter CrackenbergNew content
"; + cascadeAPI.editBlock(foundBlock) + .then(response=>{ + console.log("Success editing block:"); + console.log(response); + }) + .catch(error => { + console.errer("Error editing block:"); + console.errer(error); + }); +}) +.catch(error=>{ + console.error("Error reading block:"); + console.error(error); +}); +``` + +## Create Block +When creating a new block, you must send Cascade the asset you'd like to create. You can use the `createBlankBlockDataDef()` helper function to return a blank asset that you can then edit with the values you want. You can also manually create the object if you need a block of a different type, or if +you just want to work with it manually. + +This example uses a data definition block, which is the default type, but if a different type of block needs to be edited an optional +`blockType` parameter can be sent in to the read function. If the block is a data defintion block, the `structuredData` property should +be updated instead of the `xhtml` property that is changed here. + +The asset ID of the newly created page will be returned on success. +```javascript +const newBlock = cascadeAPI.createBlankBlockDataDef(); +newBlock.siteName = cascadeAPI.site; +newBlock.parentFolderPath = "/test"; +newBlock.name = "test-block"; +newBlock.metadataSetPath = "Default"; +newBlock.xhtml = "Test content
"; +console.log(newBlock); +cascadeAPI.createBlock(newBlock) +.then(response=>{ + console.log("Success creating block:"); + console.log(response); +}) +.catch(error=>{ + console.error("Error creating block:"); + console.error(error); +}); +``` + +## Delete Block + +```javascript +cascadeAPI.deleteBlock("/test/test-block") +.then(response=>{ + console.log("Success deleting block:"); + console.log(response); +}) +.catch(error=>{ + console.error("Error deleting block:"); + console.error(error); +}); +``` + +## Check Block Relationships + +```javascript +cascadeAPI.checkRelationshipsBlock("/test/block") +.then(response=>{ + console.log("Success getting relationships:"); + console.log(response); +}) +.catch(error=>{ + console.error("Error getting relationships:"); + console.error(error); +}); +``` \ No newline at end of file From 74ba310bd7103151e3b9578d7090a7b9360e848e Mon Sep 17 00:00:00 2001 From: Peter CrackenbergCascadeAsset
](#CascadeAsset)
* [.createBlankFile()](#Cascade+createBlankFile) ⇒ [CascadeAsset
](#CascadeAsset)
+ * [.createBlankBlockDataDef()](#Cascade+createBlankBlockDataDef) ⇒ [CascadeAsset
](#CascadeAsset)
* [.createBlankFolder()](#Cascade+createBlankFolder) ⇒ [CascadeAsset
](#CascadeAsset)
* [.APICall(operation, [type], [assetIDPath], [assetObject], [ajaxParameters])](#Cascade+APICall) ⇒ Object
* [.readPage(path)](#Cascade+readPage) ⇒ Object
* [.readFile(path)](#Cascade+readFile) ⇒ Object
+ * [.readBlock(path)](#Cascade+readBlock) ⇒ Object
* [.readFolder(path)](#Cascade+readFolder) ⇒ Object
* [.deletePage(path)](#Cascade+deletePage) ⇒ Object
* [.deleteFile(path)](#Cascade+deleteFile) ⇒ Object
+ * [.deleteBlock(path)](#Cascade+deleteBlock) ⇒ Object
* [.deleteFolder(path)](#Cascade+deleteFolder) ⇒ Object
* [.editPage(assetObject)](#Cascade+editPage) ⇒ Object
* [.editFile(assetObject)](#Cascade+editFile) ⇒ Object
+ * [.editBlock(assetObject, [blockType])](#Cascade+editBlock) ⇒ Object
* [.editFolder(assetObject)](#Cascade+editFolder) ⇒ Object
* [.publishPage(path)](#Cascade+publishPage) ⇒ Object
* [.publishFile(path)](#Cascade+publishFile) ⇒ Object
* [.publishFolder(path)](#Cascade+publishFolder) ⇒ Object
* [.createPage(assetObject)](#Cascade+createPage) ⇒ Object
* [.createFile(assetObject)](#Cascade+createFile) ⇒ Object
+ * [.createBlock(assetObject, [blockType])](#Cascade+createBlock) ⇒ Object
* [.createFolder(assetObject)](#Cascade+createFolder) ⇒ Object
* [.movePage(path, newName, folderPath)](#Cascade+movePage) ⇒ Object
* [.moveFile(path, newName, folderPath)](#Cascade+moveFile) ⇒ Object
+ * [.moveBlock(path, newName, folderPath)](#Cascade+moveBlock) ⇒ Object
* [.moveFolder(path, newName, folderPath)](#Cascade+moveFolder) ⇒ Object
* [.doMove(path, newName, folderPath, type)](#Cascade+doMove) ⇒ Object
* [.copyPage(path, newName, folderPath)](#Cascade+copyPage) ⇒ Object
* [.copyFile(path, newName, folderPath)](#Cascade+copyFile) ⇒ Object
+ * [.copyBlock(path, newName, folderPath)](#Cascade+copyBlock) ⇒ Object
* [.copyFolder(path, newName, folderPath)](#Cascade+copyFolder) ⇒ Object
* [.makeCopy(path, newName, folderPath, type)](#Cascade+makeCopy) ⇒ Object
* [.checkRelationshipsPage(path)](#Cascade+checkRelationshipsPage) ⇒ Object
* [.checkRelationshipsFile(path)](#Cascade+checkRelationshipsFile) ⇒ Object
+ * [.checkRelationshipsBlock(path)](#Cascade+checkRelationshipsBlock) ⇒ Object
* [.checkRelationshipsFolder(path)](#Cascade+checkRelationshipsFolder) ⇒ Object
@@ -109,10 +117,19 @@ Return a blank page, this is helpful when creating new assets.
### cascade.createBlankFile() ⇒ [CascadeAsset
](#CascadeAsset)
-Return a blank file, this is helpful when creating new assets.
+Return a blank file, this is helpful when creating new assets. This should either have information in the
+`data` attribute, or text in the `text` attribute.
**Kind**: instance method of [Cascade
](#Cascade)
**Returns**: [CascadeAsset
](#CascadeAsset) - Blank file
+
+
+### cascade.createBlankBlockDataDef() ⇒ [CascadeAsset
](#CascadeAsset)
+Return a blank XHTML/Data Definition block, this is helpful when creating new assets. This should either
+have properly escaped XHTML in the `xhtml` attribute, or a structured data object in the `structuredData` attribute.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: [CascadeAsset
](#CascadeAsset) - Blank block
### cascade.createBlankFolder() ⇒ [CascadeAsset
](#CascadeAsset)
@@ -177,6 +194,22 @@ Read a file, given a path or ID (depending on the mode of the Cascade object) an
| --- | --- | --- |
| path | string
| Path or ID of file to read |
+
+
+### cascade.readBlock(path) ⇒ Object
+Read a block, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response. Block that was found will depend on what type of block it was
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of block to read |
+
### cascade.readFolder(path) ⇒ Object
@@ -225,6 +258,22 @@ Delete a file, given a path or ID (depending on the mode of the Cascade object)
| --- | --- | --- |
| path | string
| Path or ID of file to delete |
+
+
+### cascade.deleteBlock(path) ⇒ Object
+Delete a block, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of block to delete |
+
### cascade.deleteFolder(path) ⇒ Object
@@ -261,7 +310,7 @@ but it can be manually created as well.
### cascade.editFile(assetObject) ⇒ Object
-Edit a file, given a Cascade file object. Typically the page to edit is read in via [readFile](#Cascade+readFile),
+Edit a file, given a Cascade file object. Typically the file to edit is read in via [readFile](#Cascade+readFile),
but it can be manually created as well.
**Kind**: instance method of [Cascade
](#Cascade)
@@ -275,10 +324,30 @@ but it can be manually created as well.
| --- | --- | --- |
| assetObject | Object
| Cascade object representing the file. |
+
+
+### cascade.editBlock(assetObject, [blockType]) ⇒ Object
+Edit a block, given a Cascade block object. Typically the block to edit is read in via [readBlock](#Cascade+readBlock),
+but it can be manually created as well.
+
+Unlike other assets, blocks need to specify
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| assetObject | Object
| | Cascade object representing the block. |
+| [blockType] | string
| "xhtmlDataDefinitionBlock"
| Type of the block to interact with, this defaults to an XHTML/Data Defintion Block |
+
### cascade.editFolder(assetObject) ⇒ Object
-Edit a folder, given a Cascade folder object. Typically the page to edit is read in via [readFolder](#Cascade+readFolder),
+Edit a folder, given a Cascade folder object. Typically the folder to edit is read in via [readFolder](#Cascade+readFolder),
but it can be manually created as well.
**Kind**: instance method of [Cascade
](#Cascade)
@@ -374,6 +443,24 @@ but it can be created manually as well.
| --- | --- | --- |
| assetObject | Object
| Cascade object representing the file. |
+
+
+### cascade.createBlock(assetObject, [blockType]) ⇒ Object
+Create a block, given a Cascade block object. Typically this is created using [createBlankBlockDataDef](#Cascade+createBlankBlockDataDef),
+but it can be created manually as well.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Default | Description |
+| --- | --- | --- | --- |
+| assetObject | Object
| | Cascade object representing the block. |
+| [blockType] | string
| "xhtmlDataDefinitionBlock"
| Type of the block to interact with, this defaults to an XHTML/Data Defintion Block |
+
### cascade.createFolder(assetObject) ⇒ Object
@@ -429,6 +516,25 @@ which have separate functionality, this combines them into a single operation.
| newName | string
| New name of the file. If the asset is being moved to a different folder, this can be the same as the current name. |
| folderPath | string
| Path or ID of the folder to move to. If the asset is not being moved to a different folder, this can be the same as the current folder. |
+
+
+### cascade.moveBlock(path, newName, folderPath) ⇒ Object
+Do a move operation on a block, given a path, name, and folder. Unlike the Move and Rename operations in Cascade,
+which have separate functionality, this combines them into a single operation.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of the block to move. |
+| newName | string
| New name of the block. If the asset is being moved to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the block to move to. If the asset is not being moved to a different folder, this can be the same as the current folder. |
+
### cascade.moveFolder(path, newName, folderPath) ⇒ Object
@@ -507,6 +613,24 @@ Make a copy of a a file, given a path, type, new name, and folder.
| newName | string
| New name of the file. If the asset is being copied to a different folder, this can be the same as the current name. |
| folderPath | string
| Path or ID of the folder to copy to. If the asset is not being copied to a different folder, this can be the same as the current folder. |
+
+
+### cascade.copyBlock(path, newName, folderPath) ⇒ Object
+Make a copy of a a block, given a path, type, new name, and folder.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of block to copy. |
+| newName | string
| New name of the block. If the asset is being copied to a different folder, this can be the same as the current name. |
+| folderPath | string
| Path or ID of the folder to copy to. If the asset is not being copied to a different folder, this can be the same as the current folder. |
+
### cascade.copyFolder(path, newName, folderPath) ⇒ Object
@@ -574,6 +698,22 @@ Check relationships for a file, given a path or ID (depending on the mode of the
- Will throw an error if the Cascade API operation was not successful.
+| Param | Type | Description |
+| --- | --- | --- |
+| path | string
| Path or ID of file to check. |
+
+
+
+### cascade.checkRelationshipsBlock(path) ⇒ Object
+Check relationships for a file, given a path or ID (depending on the mode of the Cascade object) and return a Cascade response.
+
+**Kind**: instance method of [Cascade
](#Cascade)
+**Returns**: Object
- Object representing the Cascade response.
+**Throws**:
+
+- Will throw an error if the Cascade API operation was not successful.
+
+
| Param | Type | Description |
| --- | --- | --- |
| path | string
| Path or ID of file to check. |
From cc86294282c1e45762962a32237a67d98095ff71 Mon Sep 17 00:00:00 2001
From: Peter Crackenberg