dbm-graph-api 1.1.35 → 1.1.36
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/package.json +1 -1
- package/src/dbm-graph-api/action/development/ReRenderPages.js +26 -0
- package/src/dbm-graph-api/action/development/index.js +2 -1
- package/src/dbm-graph-api/index.js +4 -3
- package/src/dbm-graph-api/processAction/pageUpdates/UpdateRenderedContent.js +31 -25
- package/src/dbm-graph-api/schema/JsonLdGenerator.js +5 -5
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import { exec } from 'node:child_process';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
|
|
5
|
+
export default class ReRenderPages extends Dbm.core.BaseObject {
|
|
6
|
+
_construct() {
|
|
7
|
+
super._construct();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async performAction(aData, aEncodeSession) {
|
|
11
|
+
let returnObject = {};
|
|
12
|
+
|
|
13
|
+
let database = Dbm.getRepositoryItem("graphDatabase").controller;
|
|
14
|
+
|
|
15
|
+
let pages = await database.getObjectsOfType("page");
|
|
16
|
+
let currentArray = pages;
|
|
17
|
+
let currentArrayLength = currentArray.length;
|
|
18
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
19
|
+
let page = currentArray[i];
|
|
20
|
+
|
|
21
|
+
await database.addActionToProcess("pageUpdates/updateRenderedContent", [page]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return returnObject;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export {default as RestartServer} from "./RestartServer.js";
|
|
2
|
-
export {default as RestartDatabaseConnection} from "./RestartDatabaseConnection.js";
|
|
2
|
+
export {default as RestartDatabaseConnection} from "./RestartDatabaseConnection.js";
|
|
3
|
+
export {default as ReRenderPages} from "./ReRenderPages.js";
|
|
@@ -276,6 +276,8 @@ let fullActionSetup = function() {
|
|
|
276
276
|
|
|
277
277
|
registerActionFunction("development/restartServer", new DbmGraphApi.action.development.RestartServer());
|
|
278
278
|
registerActionFunction("development/restartDatabaseConnection", new DbmGraphApi.action.development.RestartDatabaseConnection());
|
|
279
|
+
|
|
280
|
+
registerActionFunction("development/reRenderPages", new DbmGraphApi.action.development.ReRenderPages());
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
export {fullActionSetup};
|
|
@@ -538,7 +540,7 @@ export const setupEndpoints = function(aServer) {
|
|
|
538
540
|
export const setupSite = function(aServer) {
|
|
539
541
|
|
|
540
542
|
aServer.get('/cdn-cgi/image/:options/*', async function(request, reply) {
|
|
541
|
-
console.log("/cdn-cgi/image/");
|
|
543
|
+
//console.log("/cdn-cgi/image/");
|
|
542
544
|
|
|
543
545
|
let publicDir = Dbm.getInstance().repository.getItem("site").publicDir;
|
|
544
546
|
|
|
@@ -548,8 +550,7 @@ export const setupSite = function(aServer) {
|
|
|
548
550
|
let realPath;
|
|
549
551
|
try {
|
|
550
552
|
realPath = fs.realpathSync(publicDir + "/" + imageUrl);
|
|
551
|
-
console.log(realPath);
|
|
552
|
-
console.log(realPath);
|
|
553
|
+
//console.log(realPath);
|
|
553
554
|
if(realPath.indexOf(publicDir + "/") !== 0) {
|
|
554
555
|
throw("Not in folder");
|
|
555
556
|
}
|
|
@@ -9,39 +9,45 @@ export default class UpdateRenderedContent extends Dbm.core.BaseObject {
|
|
|
9
9
|
console.log("UpdateRenderedContent:process");
|
|
10
10
|
//console.log(aAction);
|
|
11
11
|
|
|
12
|
-
let database = Dbm.
|
|
12
|
+
let database = Dbm.getRepositoryItem("graphDatabase").controller;
|
|
13
13
|
let page = await aAction.singleObjectRelationQuery("out:from:page");
|
|
14
14
|
|
|
15
|
-
let
|
|
15
|
+
let fields = await page.getFields();
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
let webcrawler = Dbm.getRepositoryItem("webcrawler");
|
|
18
|
+
let renderedContent = null;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
if(!fields["seo/noIndex"]) {
|
|
21
|
+
if(webcrawler.domain && webcrawler.renderPageUrl) {
|
|
22
|
+
let url = await page.getUrl();
|
|
23
|
+
|
|
24
|
+
let fullUrl = webcrawler.domain + url;
|
|
25
|
+
|
|
26
|
+
let body = {
|
|
27
|
+
"url": fullUrl,
|
|
28
|
+
"key": webcrawler.key
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let headers = {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let response = await fetch(webcrawler.renderPageUrl, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: headers,
|
|
38
|
+
body: JSON.stringify(body),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
let data = await response.json();
|
|
42
|
+
|
|
43
|
+
renderedContent = Dbm.objectPath(data, "data.html");
|
|
29
44
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
headers: headers,
|
|
34
|
-
body: JSON.stringify(body),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
let data = await response.json();
|
|
38
|
-
|
|
39
|
-
let renderedContent = Dbm.objectPath(data, "data.html");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if(renderedContent !== fields["renderedContent"]) {
|
|
40
48
|
await page.updateField("renderedPageContent", renderedContent);
|
|
41
49
|
|
|
42
50
|
await database.addActionToProcess("pageUpdates/clearCache", [page]);
|
|
43
51
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
52
|
}
|
|
47
53
|
}
|
|
@@ -10,7 +10,7 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async encodeWebsiteEntity(aDatabaseObject) {
|
|
13
|
-
console.log("encodeWebsiteEntity");
|
|
13
|
+
//console.log("encodeWebsiteEntity");
|
|
14
14
|
|
|
15
15
|
let site = Dbm.getInstance().repository.getItem("site");
|
|
16
16
|
let fields = await aDatabaseObject.getFields();
|
|
@@ -27,7 +27,7 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async encodeOrganizationEntity(aDatabaseObject) {
|
|
30
|
-
console.log("encodeOrganizationEntity");
|
|
30
|
+
//console.log("encodeOrganizationEntity");
|
|
31
31
|
|
|
32
32
|
let site = Dbm.getInstance().repository.getItem("site");
|
|
33
33
|
let fields = await aDatabaseObject.getFields();
|
|
@@ -124,7 +124,7 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
async getWebsiteEntites() {
|
|
127
|
-
console.log("getWebsiteEntites");
|
|
127
|
+
//console.log("getWebsiteEntites");
|
|
128
128
|
|
|
129
129
|
let returnArray = [];
|
|
130
130
|
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
@@ -142,9 +142,9 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
|
|
|
142
142
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
143
143
|
let currentLocalBusiness = currentArray[i];
|
|
144
144
|
if(currentLocalBusiness) {
|
|
145
|
-
console.log(currentLocalBusiness);
|
|
145
|
+
//console.log(currentLocalBusiness);
|
|
146
146
|
returnArray.push(await this.encodeLocalBusiness(currentLocalBusiness));
|
|
147
|
-
console.log("-");
|
|
147
|
+
//console.log("-");
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|