dbm-graph-api 1.1.29 → 1.1.31
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 +2 -2
- package/src/dbm-graph-api/action/admin/AddAndProcessAction.js +2 -2
- package/src/dbm-graph-api/admin/edit/AddAction.js +15 -0
- package/src/dbm-graph-api/admin/edit/index.js +7 -0
- package/src/dbm-graph-api/index.js +80 -72
- package/src/dbm-graph-api/processAction/index.js +2 -0
- package/src/dbm-graph-api/processAction/pageUpdates/UpdateCategoryListing.js +71 -0
- package/src/dbm-graph-api/processAction/pageUpdates/index.js +1 -0
- package/src/dbm-graph-api/range/encode/LinkPreview.js +38 -0
- package/src/dbm-graph-api/range/encode/PublishDate.js +21 -0
- package/src/dbm-graph-api/range/encode/UrlRequest.js +1 -1
- package/src/dbm-graph-api/range/encode/index.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.31",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@aws-sdk/client-s3": "^3.741.0",
|
|
15
15
|
"@aws-sdk/s3-request-presigner": "^3.741.0",
|
|
16
|
-
"dbm": "^1.2.
|
|
16
|
+
"dbm": "^1.2.1",
|
|
17
17
|
"mime": "^4.0.6",
|
|
18
18
|
"sharp": "^0.33.5",
|
|
19
19
|
"ws": "^8.18.0"
|
|
@@ -23,8 +23,8 @@ export default class AddAndProcessAction extends Dbm.core.BaseObject {
|
|
|
23
23
|
await action.addIncomingRelation(actionType, "for");
|
|
24
24
|
|
|
25
25
|
if(aData["from"]) {
|
|
26
|
-
let fromItem = database.
|
|
27
|
-
await action.
|
|
26
|
+
let fromItem = database.getObject(1*aData["from"]);
|
|
27
|
+
await action.addOutgoingRelation(fromItem, "from");
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
let processingActionStatus = await database.getTypeObject("status/actionStatus", "processing");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EditBaseObject from "./EditBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class AddAction extends EditBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async performChange(aObject, aData, aRequest) {
|
|
10
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
11
|
+
|
|
12
|
+
console.log(aData["type"], aObject);
|
|
13
|
+
await database.addActionToProcess(aData["type"], [aObject]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -14,6 +14,7 @@ export {default as ReplaceMultipleIncomingRelations} from "./ReplaceMultipleInco
|
|
|
14
14
|
export {default as ReplaceMultipleOutgoingRelations} from "./ReplaceMultipleOutgoingRelations.js";
|
|
15
15
|
export {default as AddObjectType} from "./AddObjectType.js";
|
|
16
16
|
export {default as RemoveObjectType} from "./RemoveObjectType.js";
|
|
17
|
+
export {default as AddAction} from "./AddAction.js";
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
export const fullSetup = function() {
|
|
@@ -95,4 +96,10 @@ export const fullSetup = function() {
|
|
|
95
96
|
let currentSelect = new DbmGraphApi.admin.edit.RemoveObjectType();
|
|
96
97
|
currentSelect.item.register(prefix + name);
|
|
97
98
|
}
|
|
99
|
+
|
|
100
|
+
{
|
|
101
|
+
let name = "addAction";
|
|
102
|
+
let currentSelect = new DbmGraphApi.admin.edit.AddAction();
|
|
103
|
+
currentSelect.item.register(prefix + name);
|
|
104
|
+
}
|
|
98
105
|
}
|
|
@@ -211,6 +211,8 @@ let fullEncodeSetup = function() {
|
|
|
211
211
|
registerEncoding("atLocation", new DbmGraphApi.range.encode.AtLocation());
|
|
212
212
|
registerEncoding("location", new DbmGraphApi.range.encode.Location());
|
|
213
213
|
registerEncoding("mainImage", new DbmGraphApi.range.encode.MainImage());
|
|
214
|
+
registerEncoding("linkPreview", new DbmGraphApi.range.encode.LinkPreview());
|
|
215
|
+
registerEncoding("publishDate", new DbmGraphApi.range.encode.PublishDate());
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
export {fullEncodeSetup};
|
|
@@ -276,6 +278,8 @@ let fullProcessActionSetup = function() {
|
|
|
276
278
|
registerProcessActionFunction("example", new DbmGraphApi.processAction.Example());
|
|
277
279
|
|
|
278
280
|
registerProcessActionFunction("handleFormSubmission", new DbmGraphApi.processAction.HandleFormSubmission());
|
|
281
|
+
|
|
282
|
+
registerProcessActionFunction("pageUpdates/updateCategoryListing", new DbmGraphApi.processAction.pageUpdates.UpdateCategoryListing());
|
|
279
283
|
}
|
|
280
284
|
|
|
281
285
|
export {fullProcessActionSetup};
|
|
@@ -389,7 +393,6 @@ export const setupEndpoints = function(aServer) {
|
|
|
389
393
|
url += "/";
|
|
390
394
|
}
|
|
391
395
|
|
|
392
|
-
console.log(url);
|
|
393
396
|
//METODO: check visibility in database
|
|
394
397
|
let request = new UrlRequest();
|
|
395
398
|
request.setup(aRequest, aReply);
|
|
@@ -651,18 +654,17 @@ export const setupSite = function(aServer) {
|
|
|
651
654
|
reply.code(404);
|
|
652
655
|
reply.type('text/html');
|
|
653
656
|
|
|
654
|
-
let returnString =
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
<title>Page not found - ${siteName}</title>`;
|
|
657
|
+
let returnString = `<!doctype html>
|
|
658
|
+
<html lang="${language}">
|
|
659
|
+
<head>
|
|
660
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
661
|
+
<title>Page not found - ${siteName}</title>`;
|
|
660
662
|
|
|
661
663
|
{
|
|
662
664
|
let currentArray = site.preconnectUrls;
|
|
663
|
-
let currentArrayLength =currentArray.length;
|
|
665
|
+
let currentArrayLength = currentArray.length;
|
|
664
666
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
665
|
-
returnString += `<link rel="preconnect" href="${currentArray[i]}" crossorigin
|
|
667
|
+
returnString += `<link rel="preconnect" href="${currentArray[i]}" crossorigin />`;
|
|
666
668
|
}
|
|
667
669
|
}
|
|
668
670
|
|
|
@@ -681,7 +683,7 @@ export const setupSite = function(aServer) {
|
|
|
681
683
|
returnString += `<link rel="stylesheet" type="text/css" href="${assetsUri}css/main.css?version=${version}" />
|
|
682
684
|
<meta name="viewport" content="initial-scale=1,user-scalable=yes" />
|
|
683
685
|
<meta name="HandheldFriendly" content="true" />
|
|
684
|
-
<link rel="icon" type="image/png" href="${assetsUri}img/favicon.png"
|
|
686
|
+
<link rel="icon" type="image/png" href="${assetsUri}img/favicon.png" />
|
|
685
687
|
</head>
|
|
686
688
|
<body>
|
|
687
689
|
<div id="site"></div>
|
|
@@ -705,21 +707,48 @@ export const setupSite = function(aServer) {
|
|
|
705
707
|
|
|
706
708
|
let fields = await urlObject.getFields();
|
|
707
709
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
710
|
+
let baseUrl = request.protocol + "://" + request.hostname;
|
|
711
|
+
if(request.port && request.port !== 80 && request.port !== 443) {
|
|
712
|
+
baseUrl += ":" + request.port;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
let fullUrl = baseUrl + url;
|
|
716
|
+
|
|
717
|
+
let robotsText;
|
|
718
|
+
|
|
719
|
+
if(site.disableSearchEngines) {
|
|
720
|
+
robotsText = "noindex, nofollow";
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
let robotsSettings = ["index", "follow"];
|
|
724
|
+
if(fields["seo/noIndex"]) {
|
|
725
|
+
robotsSettings[0] = "noindex";
|
|
726
|
+
}
|
|
727
|
+
if(fields["seo/noFollow"]) {
|
|
728
|
+
robotsSettings[1] = "nofollow";
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
robotsText = robotsSettings.join(", ");
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
let returnString = `<!doctype html>
|
|
735
|
+
<html lang="${language}">
|
|
736
|
+
<head>
|
|
712
737
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
713
738
|
<meta name="viewport" content="initial-scale=1,user-scalable=yes" />
|
|
714
739
|
<meta name="HandheldFriendly" content="true" />
|
|
715
|
-
|
|
716
|
-
|
|
740
|
+
<title>${fields.title} - ${siteName}</title>` + "\n";
|
|
741
|
+
if(fields['meta/description']) {
|
|
742
|
+
returnString += ` <meta name="description" content="${fields['meta/description']}" />` + "\n";
|
|
743
|
+
}
|
|
744
|
+
returnString += ` <link rel="canonical" href="${fullUrl}" />`+ "\n";
|
|
745
|
+
returnString += ` <meta name="robots" content="${robotsText}" />`+ "\n";
|
|
717
746
|
|
|
718
747
|
{
|
|
719
748
|
let currentArray = site.preconnectUrls;
|
|
720
749
|
let currentArrayLength =currentArray.length;
|
|
721
750
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
722
|
-
returnString +=
|
|
751
|
+
returnString += ` <link rel="preconnect" href="${currentArray[i]}" crossorigin />`+ "\n";
|
|
723
752
|
}
|
|
724
753
|
}
|
|
725
754
|
|
|
@@ -727,93 +756,72 @@ export const setupSite = function(aServer) {
|
|
|
727
756
|
let currentArray = fields["contentPreloadTags"];
|
|
728
757
|
let currentArrayLength = currentArray.length;
|
|
729
758
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
730
|
-
returnString += currentArray[i];
|
|
759
|
+
returnString += " " + currentArray[i] + "\n";
|
|
731
760
|
}
|
|
732
761
|
}
|
|
733
762
|
|
|
734
|
-
|
|
735
|
-
returnString += `<meta name="robots" content="noindex, nofollow" />`;
|
|
736
|
-
}
|
|
737
|
-
else {
|
|
738
|
-
let robotsSettings = ["index", "follow"];
|
|
739
|
-
if(fields["seo/noIndex"]) {
|
|
740
|
-
robotsSettings[0] = "noindex";
|
|
741
|
-
}
|
|
742
|
-
if(fields["seo/noFollow"]) {
|
|
743
|
-
robotsSettings[1] = "nofollow";
|
|
744
|
-
}
|
|
763
|
+
|
|
745
764
|
|
|
746
|
-
|
|
747
|
-
returnString += `<meta name="robots" content="${content}" />`;
|
|
748
|
-
}
|
|
765
|
+
|
|
749
766
|
|
|
750
|
-
|
|
751
|
-
if(request.port && request.port !== 80 && request.port !== 443) {
|
|
752
|
-
baseUrl += ":" + request.port;
|
|
753
|
-
}
|
|
767
|
+
|
|
754
768
|
|
|
755
769
|
let schemaGenrator = new DbmGraphApi.schema.JsonLdGenerator();
|
|
756
770
|
schemaGenrator.baseUrl = baseUrl;
|
|
757
771
|
let schemaMarkup = await schemaGenrator.getWebsiteEntites();
|
|
758
772
|
schemaMarkup = schemaMarkup.concat(await schemaGenrator.getPageEntites(urlObject))
|
|
759
|
-
let encodedMarkup = JSON.stringify(schemaMarkup, null, 2);
|
|
773
|
+
let encodedMarkup = JSON.stringify(schemaMarkup, null, 2).split("\n").join("\n\t\t\t\t");
|
|
760
774
|
|
|
761
|
-
returnString +=
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
775
|
+
returnString += ` <script type="application/ld+json">
|
|
776
|
+
{
|
|
777
|
+
"@context": "https://schema.org",
|
|
778
|
+
"@graph": ${encodedMarkup}
|
|
779
|
+
}
|
|
780
|
+
</script>`+ "\n";
|
|
767
781
|
|
|
768
|
-
|
|
782
|
+
|
|
769
783
|
|
|
770
|
-
<meta property="og:type" content="website" />
|
|
784
|
+
returnString += ` <meta property="og:type" content="website" />
|
|
771
785
|
<meta property="og:locale" content="${language}" />
|
|
772
786
|
<meta property="og:site_name" content="${siteName}" />
|
|
773
|
-
<meta property="og:title" content="${fields.title}"
|
|
787
|
+
<meta property="og:title" content="${fields.title}" />`+ "\n";
|
|
774
788
|
|
|
775
789
|
{
|
|
776
790
|
let currentArray = site.injectCodeSnippets;
|
|
777
791
|
let currentArrayLength = currentArray.length;
|
|
778
792
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
779
|
-
returnString += currentArray[i];
|
|
793
|
+
returnString += " " + currentArray[i] + "\n";
|
|
780
794
|
}
|
|
781
795
|
}
|
|
782
796
|
|
|
783
797
|
if(process.env.INLINE_STYLE_SHEET == 1) {
|
|
784
|
-
returnString +=
|
|
798
|
+
returnString += ` <style>`+ "\n";
|
|
785
799
|
|
|
786
800
|
let assetsDir = Dbm.getInstance().repository.getItem("site").assetsDir;
|
|
787
801
|
let cssContent = await fs.promises.readFile(assetsDir + "/css/main.css", 'utf8');
|
|
788
802
|
|
|
789
803
|
returnString += cssContent;
|
|
790
804
|
|
|
791
|
-
returnString +=
|
|
805
|
+
returnString += ` </style>`+ "\n";
|
|
792
806
|
}
|
|
793
807
|
else {
|
|
794
|
-
returnString +=
|
|
808
|
+
returnString += ` <link rel="stylesheet" type="text/css" href="${assetsUri}css/main.css?version=${version}" />`+ "\n";
|
|
795
809
|
}
|
|
796
810
|
|
|
797
811
|
|
|
798
812
|
|
|
799
|
-
returnString +=
|
|
813
|
+
returnString += ` <link rel="icon" type="image/png" href="${baseUrl}${assetsUri}img/favicon.png" />`+ "\n";
|
|
800
814
|
|
|
801
815
|
if(fields['meta/description']) {
|
|
802
|
-
returnString += `
|
|
803
|
-
<meta name="description" content="${fields['meta/description']}" />
|
|
804
|
-
<meta property="og:description" content="${fields['meta/description']}" />
|
|
805
|
-
`;
|
|
816
|
+
returnString += ` <meta property="og:description" content="${fields['meta/description']}" />`+ "\n";;
|
|
806
817
|
}
|
|
807
818
|
|
|
808
|
-
|
|
819
|
+
|
|
809
820
|
|
|
810
|
-
returnString += `
|
|
811
|
-
<link rel="canonical" href="${fullUrl}" />
|
|
812
|
-
<meta property="og:url" content="${fullUrl}" />
|
|
813
|
-
`;
|
|
821
|
+
returnString += ` <meta property="og:url" content="${fullUrl}" />`+ "\n";
|
|
814
822
|
|
|
815
823
|
if(fields["lastModified"]) {
|
|
816
|
-
returnString +=
|
|
824
|
+
returnString += ` <meta property="article:modified_time" content="${fields["lastModified"]}" />`+ "\n";;
|
|
817
825
|
}
|
|
818
826
|
|
|
819
827
|
let image = await urlObject.singleObjectRelationQuery("in:isMainImageFor:image");
|
|
@@ -825,16 +833,16 @@ export const setupSite = function(aServer) {
|
|
|
825
833
|
let scaleString = "width=1200,height=630,fit=cover,format=jpeg";
|
|
826
834
|
imageUrl = imageUrl.split("{scale}").join(scaleString);
|
|
827
835
|
|
|
828
|
-
returnString +=
|
|
829
|
-
returnString +=
|
|
830
|
-
returnString +=
|
|
831
|
-
returnString +=
|
|
832
|
-
returnString +=
|
|
836
|
+
returnString += ` <meta property="og:image" content="${imageUrl}" />`+ "\n";;
|
|
837
|
+
returnString += ` <meta property="og:image:width" content="1200" />`+ "\n";;
|
|
838
|
+
returnString += ` <meta property="og:image:height" content="630" />`+ "\n";;
|
|
839
|
+
returnString += ` <meta property="og:image:type" content="image/jpeg" />`+ "\n";;
|
|
840
|
+
returnString += ` <meta property="twitter:card" content="summary_large_image" />`+ "\n";;
|
|
833
841
|
}
|
|
834
842
|
else {
|
|
835
843
|
let imageUrl = imageFields["url"];
|
|
836
|
-
returnString +=
|
|
837
|
-
returnString +=
|
|
844
|
+
returnString += ` <meta property="og:image" content="${imageUrl}" />`+ "\n";;
|
|
845
|
+
returnString += ` <meta property="twitter:card" content="summary_large_image" />`+ "\n";;
|
|
838
846
|
}
|
|
839
847
|
}
|
|
840
848
|
|
|
@@ -842,8 +850,8 @@ export const setupSite = function(aServer) {
|
|
|
842
850
|
<meta property="article:publisher" content="https://sv-se.facebook.com/..." />
|
|
843
851
|
*/
|
|
844
852
|
|
|
845
|
-
returnString +=
|
|
846
|
-
|
|
853
|
+
returnString += ` </head>
|
|
854
|
+
<body>
|
|
847
855
|
<div id="site"></div>
|
|
848
856
|
<script>
|
|
849
857
|
(function(d,b,m,j,s){
|
|
@@ -853,8 +861,8 @@ export const setupSite = function(aServer) {
|
|
|
853
861
|
|
|
854
862
|
dbmstartup.modules.create(document.getElementById("site"), "${moduleName}", {});
|
|
855
863
|
</script>
|
|
856
|
-
|
|
857
|
-
|
|
864
|
+
</body>
|
|
865
|
+
</html>`;
|
|
858
866
|
|
|
859
867
|
return returnString;
|
|
860
868
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class UpdateCategoryListing extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async process(aAction) {
|
|
9
|
+
console.log("UpdateCategoryListing:process");
|
|
10
|
+
console.log(aAction);
|
|
11
|
+
|
|
12
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
13
|
+
let page = await aAction.singleObjectRelationQuery("out:from:page");
|
|
14
|
+
|
|
15
|
+
let categories = await page.objectRelationQuery("out:in:group/pageCategory");
|
|
16
|
+
let links = await page.objectRelationQuery("in:for:linkPreview");
|
|
17
|
+
|
|
18
|
+
let defaultLinks = [];
|
|
19
|
+
{
|
|
20
|
+
let currentArray = links;
|
|
21
|
+
let currentArrayLength = currentArray.length;
|
|
22
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
23
|
+
let currentLink = currentArray[i];
|
|
24
|
+
|
|
25
|
+
let mode = await currentLink.getSingleLinkedType("type/listUpdateMode");
|
|
26
|
+
|
|
27
|
+
if(mode === "byCategories") {
|
|
28
|
+
defaultLinks.push(currentLink);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if(defaultLinks.length === 0) {
|
|
33
|
+
let link = await database.createObject("public", ["linkPreview"]);
|
|
34
|
+
await link.addLinkedType("type/listUpdateMode", "byCategories");
|
|
35
|
+
await link.addOutgoingRelation(page, "for");
|
|
36
|
+
|
|
37
|
+
defaultLinks.push(link);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let categoryListIds = [];
|
|
42
|
+
{
|
|
43
|
+
let currentArray = categories;
|
|
44
|
+
let currentArrayLength = currentArray.length;
|
|
45
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
46
|
+
let currentCategory = currentArray[i];
|
|
47
|
+
|
|
48
|
+
let list = await currentCategory.singleObjectRelationQuery("out:for:linkList");
|
|
49
|
+
|
|
50
|
+
if(!list) {
|
|
51
|
+
list = await database.createObject("public", ["linkList"]);
|
|
52
|
+
let fields = await currentCategory.getFields();
|
|
53
|
+
await list.updateField("name", fields["name"] + " (page category list)");
|
|
54
|
+
await currentCategory.addOutgoingRelation(list, "for");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
categoryListIds.push(list.id);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
{
|
|
62
|
+
let currentArray = defaultLinks;
|
|
63
|
+
let currentArrayLength = currentArray.length;
|
|
64
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
65
|
+
let currentLink = currentArray[i];
|
|
66
|
+
|
|
67
|
+
await currentLink.replaceMultipleOutgoingRelations(categoryListIds, "in", "linkList");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as UpdateCategoryListing} from "./UpdateCategoryListing.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class LinkPreview extends EncodeBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async getEncodedData(aId, aEncodingSession) {
|
|
10
|
+
|
|
11
|
+
let returnObject = {};
|
|
12
|
+
|
|
13
|
+
let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getObject(aId);
|
|
14
|
+
|
|
15
|
+
let fields = await object.getFields();
|
|
16
|
+
returnObject["title"] = fields["title"] !== undefined ? fields["title"] : null;
|
|
17
|
+
returnObject["description"] = fields["description"] !== undefined ? fields["description"] : null;
|
|
18
|
+
returnObject["linkText"] = fields["linkText"] !== undefined ? fields["linkText"] : null;
|
|
19
|
+
|
|
20
|
+
await aEncodingSession.encodeObjectOrNull(object, "mainImage");
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
let relatedItem = await object.singleObjectRelationQuery("out:for:page");
|
|
24
|
+
|
|
25
|
+
if(relatedItem) {
|
|
26
|
+
returnObject["page"] = await aEncodingSession.encodeObjectOrNull(relatedItem, "url");
|
|
27
|
+
await aEncodingSession.encodeObjectOrNull(relatedItem, "title");
|
|
28
|
+
await aEncodingSession.encodeObjectOrNull(relatedItem, "mainImage");
|
|
29
|
+
await aEncodingSession.encodeObjectOrNull(relatedItem, "publishDate");
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
returnObject["link"] = fields["link"] !== undefined ? fields["link"] : null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return returnObject;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class PublishDate extends EncodeBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async getEncodedData(aId, aEncodingSession) {
|
|
10
|
+
|
|
11
|
+
let returnObject = {};
|
|
12
|
+
|
|
13
|
+
let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getObject(aId);
|
|
14
|
+
|
|
15
|
+
let fields = await object.getFields();
|
|
16
|
+
|
|
17
|
+
returnObject["publishDate"] = fields["publishDate"] ? fields["publishDate"] : null;
|
|
18
|
+
|
|
19
|
+
return returnObject;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -20,5 +20,7 @@ export {default as HelpSection} from "./HelpSection.js";
|
|
|
20
20
|
export {default as MainImage} from "./MainImage.js";
|
|
21
21
|
export {default as Location} from "./Location.js";
|
|
22
22
|
export {default as AtLocation} from "./AtLocation.js";
|
|
23
|
+
export {default as LinkPreview} from "./LinkPreview.js";
|
|
24
|
+
export {default as PublishDate} from "./PublishDate.js";
|
|
23
25
|
|
|
24
26
|
export * as admin from "./admin/index.js";
|