small script changes and notes
This commit is contained in:
1
Scripts/GoogleScripts/Confluence_Test/.clasp.json
Normal file
1
Scripts/GoogleScripts/Confluence_Test/.clasp.json
Normal file
@ -0,0 +1 @@
|
||||
{"scriptId":"1ZUQXaSRZHjVpzJBBFuHdfnLijMJ5jf3swTbonwXJ3nrgeMIh9ffCqe7j","rootDir":"/Users/normrasmussen/Documents/Work/Scripts/GoogleScripts/Confluence_Test"}
|
||||
18
Scripts/GoogleScripts/Confluence_Test/ConfGet.js
Normal file
18
Scripts/GoogleScripts/Confluence_Test/ConfGet.js
Normal file
@ -0,0 +1,18 @@
|
||||
function getPages() {
|
||||
var url = 'https://northpass.atlassian.net/wiki/rest/api/content';
|
||||
const settings = {
|
||||
//async: true,
|
||||
//crossDomain: true,
|
||||
method: 'get',
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"X-Atlassian-Token": "no-check",
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Basic bnJhc211c3NlbkBub3J0aHBhc3MuY29tOkFUQVRUM3hGZkdGMFFaVW9tQzFzM2h2RDRIaXFoX3VzT1ZGQVZMc1QxbjhsdDZnekQ3d2ZMOEQ4eDVuZXIzU0UyNEpENEU1OTB4b1Q5UEtQSWkxRXBwYW54MTJxNUFMek1IS2NlLUtyY0laUlQyM0J2TzhNRFh3eXZiekFPMlI0aEFMYzhaVVRJXzgtT00teDlvX3RqYkNITHhFTUZPcjZRRkRZcHJ3ZEhHWmpBeHB2aVN3WHJDUT0yMThBQzQzOA=="
|
||||
},
|
||||
};
|
||||
|
||||
const sendData = UrlFetchApp.fetch(url, settings);
|
||||
var response = sendData.getContentText();
|
||||
Logger.log(response);
|
||||
}
|
||||
7
Scripts/GoogleScripts/Confluence_Test/appsscript.json
Normal file
7
Scripts/GoogleScripts/Confluence_Test/appsscript.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"timeZone": "America/New_York",
|
||||
"dependencies": {
|
||||
},
|
||||
"exceptionLogging": "STACKDRIVER",
|
||||
"runtimeVersion": "V8"
|
||||
}
|
||||
1
Scripts/GoogleScripts/Courtney_Confluence/.clasp.json
Normal file
1
Scripts/GoogleScripts/Courtney_Confluence/.clasp.json
Normal file
@ -0,0 +1 @@
|
||||
{"scriptId":"1TM7cFM57LKm9BoB21N9sCD7j_KDy9z1zrqGDXV8clcwXVwgOKJBpz_0J","rootDir":"/Users/normrasmussen/Documents/Work/Scripts/GoogleScripts/Courtney_Confluence"}
|
||||
40
Scripts/GoogleScripts/Courtney_Confluence/Adv.js
Normal file
40
Scripts/GoogleScripts/Courtney_Confluence/Adv.js
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Test harness to demonstrate getting named styles from the Advanced Docs Service
|
||||
*/
|
||||
function getStylesTestHarness() {
|
||||
// Get the current document
|
||||
var doc = DocumentApp.getActiveDocument()
|
||||
|
||||
// https://developers.google.com/apps-script/reference/document/paragraph-heading
|
||||
var namedStyleType = DocumentApp.ParagraphHeading.HEADING2;
|
||||
getStyles_(doc.getId(), namedStyleType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get named styles from the Advanced Docs Service
|
||||
* Assumes that heading text is unique, which it should be with date stamp
|
||||
* @param {string} documentId
|
||||
* @param {string} styleType https://developers.google.com/apps-script/reference/document/paragraph-heading
|
||||
* @private
|
||||
*/
|
||||
function getStyles_(documentId, styleType) {
|
||||
|
||||
var namedStyleArr;
|
||||
var namedStyleObj;
|
||||
var appsScriptNamedStyle;
|
||||
|
||||
// Get the corresponding document from the Advanced Docs Service
|
||||
var document = Docs.Documents.get(documentId);
|
||||
var namedStyleArr = document.namedStyles.styles;
|
||||
|
||||
for (var i=namedStyleArr.length;i--;) {
|
||||
namedStyleObj = namedStyleArr[i];
|
||||
// convert from Advanced Docs Service style names which have separating underscores
|
||||
appsScriptNamedStyle = namedStyleObj.namedStyleType.split('_').join('');
|
||||
if (appsScriptNamedStyle == styleType) {
|
||||
console.log('namedStyleType '+namedStyleObj.namedStyleType);
|
||||
console.log('textStyle '+JSON.stringify(namedStyleObj.textStyle));
|
||||
console.log('paragraphStyle '+JSON.stringify(namedStyleObj.paragraphStyle));
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Scripts/GoogleScripts/Courtney_Confluence/Confluence.js
Normal file
29
Scripts/GoogleScripts/Courtney_Confluence/Confluence.js
Normal file
@ -0,0 +1,29 @@
|
||||
function uploadToConfluence() {
|
||||
var doc = DocumentApp.getActiveDocument();
|
||||
var body = doc.getText();
|
||||
var company = doc.getName();
|
||||
//Logger.log(typeof body);
|
||||
//Logger.log(typeof company)
|
||||
|
||||
var url = 'https://northpass.atlassian.net/wiki/rest/api/content';
|
||||
const payload = JSON.stringify({
|
||||
"type": "page",
|
||||
"title": company,
|
||||
"status": "current",
|
||||
"ancestors": [{"id": 2210463745}],
|
||||
"space": {"key": "~350535240"},
|
||||
"body": {"storage": {"value": body, "representation": "storage"}},
|
||||
});
|
||||
const settings = {
|
||||
method: 'post',
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"X-Atlassian-Token": "no-check",
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Basic bnJhc211c3NlbkBub3J0aHBhc3MuY29tOkFUQVRUM3hGZkdGMFFaVW9tQzFzM2h2RDRIaXFoX3VzT1ZGQVZMc1QxbjhsdDZnekQ3d2ZMOEQ4eDVuZXIzU0UyNEpENEU1OTB4b1Q5UEtQSWkxRXBwYW54MTJxNUFMek1IS2NlLUtyY0laUlQyM0J2TzhNRFh3eXZiekFPMlI0aEFMYzhaVVRJXzgtT00teDlvX3RqYkNITHhFTUZPcjZRRkRZcHJ3ZEhHWmpBeHB2aVN3WHJDUT0yMThBQzQzOA=="},
|
||||
payload: payload
|
||||
};
|
||||
const sendData = UrlFetchApp.fetch(url, settings);
|
||||
var response = sendData.getContentText();
|
||||
Logger.log(response);
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
{
|
||||
"timeZone": "America/New_York",
|
||||
"dependencies": {
|
||||
},
|
||||
"exceptionLogging": "STACKDRIVER",
|
||||
"runtimeVersion": "V8"
|
||||
}
|
||||
Reference in New Issue
Block a user