dbm-graph-api 1.1.28 → 1.1.30
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/index.js +76 -71
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.30",
|
|
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.
|
|
16
|
+
"dbm": "^1.2.0",
|
|
17
17
|
"mime": "^4.0.6",
|
|
18
18
|
"sharp": "^0.33.5",
|
|
19
19
|
"ws": "^8.18.0"
|
|
@@ -651,18 +651,17 @@ export const setupSite = function(aServer) {
|
|
|
651
651
|
reply.code(404);
|
|
652
652
|
reply.type('text/html');
|
|
653
653
|
|
|
654
|
-
let returnString =
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
<title>Page not found - ${siteName}</title>`;
|
|
654
|
+
let returnString = `<!doctype html>
|
|
655
|
+
<html lang="${language}">
|
|
656
|
+
<head>
|
|
657
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
658
|
+
<title>Page not found - ${siteName}</title>`;
|
|
660
659
|
|
|
661
660
|
{
|
|
662
661
|
let currentArray = site.preconnectUrls;
|
|
663
|
-
let currentArrayLength =currentArray.length;
|
|
662
|
+
let currentArrayLength = currentArray.length;
|
|
664
663
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
665
|
-
returnString += `<link rel="preconnect" href="${currentArray[i]}" crossorigin
|
|
664
|
+
returnString += `<link rel="preconnect" href="${currentArray[i]}" crossorigin />`;
|
|
666
665
|
}
|
|
667
666
|
}
|
|
668
667
|
|
|
@@ -681,7 +680,7 @@ export const setupSite = function(aServer) {
|
|
|
681
680
|
returnString += `<link rel="stylesheet" type="text/css" href="${assetsUri}css/main.css?version=${version}" />
|
|
682
681
|
<meta name="viewport" content="initial-scale=1,user-scalable=yes" />
|
|
683
682
|
<meta name="HandheldFriendly" content="true" />
|
|
684
|
-
<link rel="icon" type="image/png" href="${assetsUri}img/favicon.png"
|
|
683
|
+
<link rel="icon" type="image/png" href="${assetsUri}img/favicon.png" />
|
|
685
684
|
</head>
|
|
686
685
|
<body>
|
|
687
686
|
<div id="site"></div>
|
|
@@ -705,21 +704,48 @@ export const setupSite = function(aServer) {
|
|
|
705
704
|
|
|
706
705
|
let fields = await urlObject.getFields();
|
|
707
706
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
707
|
+
let baseUrl = request.protocol + "://" + request.hostname;
|
|
708
|
+
if(request.port && request.port !== 80 && request.port !== 443) {
|
|
709
|
+
baseUrl += ":" + request.port;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
let fullUrl = baseUrl + url;
|
|
713
|
+
|
|
714
|
+
let robotsText;
|
|
715
|
+
|
|
716
|
+
if(site.disableSearchEngines) {
|
|
717
|
+
robotsText = "noindex, nofollow";
|
|
718
|
+
}
|
|
719
|
+
else {
|
|
720
|
+
let robotsSettings = ["index", "follow"];
|
|
721
|
+
if(fields["seo/noIndex"]) {
|
|
722
|
+
robotsSettings[0] = "noindex";
|
|
723
|
+
}
|
|
724
|
+
if(fields["seo/noFollow"]) {
|
|
725
|
+
robotsSettings[1] = "nofollow";
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
robotsText = robotsSettings.join(", ");
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
let returnString = `<!doctype html>
|
|
732
|
+
<html lang="${language}">
|
|
733
|
+
<head>
|
|
712
734
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
713
735
|
<meta name="viewport" content="initial-scale=1,user-scalable=yes" />
|
|
714
736
|
<meta name="HandheldFriendly" content="true" />
|
|
715
|
-
|
|
716
|
-
|
|
737
|
+
<title>${fields.title} - ${siteName}</title>` + "\n";
|
|
738
|
+
if(fields['meta/description']) {
|
|
739
|
+
returnString += ` <meta name="description" content="${fields['meta/description']}" />` + "\n";
|
|
740
|
+
}
|
|
741
|
+
returnString += ` <link rel="canonical" href="${fullUrl}" />`+ "\n";
|
|
742
|
+
returnString += ` <meta name="robots" content="${robotsText}" />`+ "\n";
|
|
717
743
|
|
|
718
744
|
{
|
|
719
745
|
let currentArray = site.preconnectUrls;
|
|
720
746
|
let currentArrayLength =currentArray.length;
|
|
721
747
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
722
|
-
returnString +=
|
|
748
|
+
returnString += ` <link rel="preconnect" href="${currentArray[i]}" crossorigin />`+ "\n";
|
|
723
749
|
}
|
|
724
750
|
}
|
|
725
751
|
|
|
@@ -727,93 +753,72 @@ export const setupSite = function(aServer) {
|
|
|
727
753
|
let currentArray = fields["contentPreloadTags"];
|
|
728
754
|
let currentArrayLength = currentArray.length;
|
|
729
755
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
730
|
-
returnString += currentArray[i];
|
|
756
|
+
returnString += " " + currentArray[i] + "\n";
|
|
731
757
|
}
|
|
732
758
|
}
|
|
733
759
|
|
|
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
|
-
}
|
|
760
|
+
|
|
745
761
|
|
|
746
|
-
|
|
747
|
-
returnString += `<meta name="robots" content="${content}" />`;
|
|
748
|
-
}
|
|
762
|
+
|
|
749
763
|
|
|
750
|
-
|
|
751
|
-
if(request.port && request.port !== 80 && request.port !== 443) {
|
|
752
|
-
baseUrl += ":" + request.port;
|
|
753
|
-
}
|
|
764
|
+
|
|
754
765
|
|
|
755
766
|
let schemaGenrator = new DbmGraphApi.schema.JsonLdGenerator();
|
|
756
767
|
schemaGenrator.baseUrl = baseUrl;
|
|
757
768
|
let schemaMarkup = await schemaGenrator.getWebsiteEntites();
|
|
758
769
|
schemaMarkup = schemaMarkup.concat(await schemaGenrator.getPageEntites(urlObject))
|
|
759
|
-
let encodedMarkup = JSON.stringify(schemaMarkup, null, 2);
|
|
770
|
+
let encodedMarkup = JSON.stringify(schemaMarkup, null, 2).split("\n").join("\n\t\t\t\t");
|
|
760
771
|
|
|
761
|
-
returnString +=
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
772
|
+
returnString += ` <script type="application/ld+json">
|
|
773
|
+
{
|
|
774
|
+
"@context": "https://schema.org",
|
|
775
|
+
"@graph": ${encodedMarkup}
|
|
776
|
+
}
|
|
777
|
+
</script>`+ "\n";
|
|
767
778
|
|
|
768
|
-
|
|
779
|
+
|
|
769
780
|
|
|
770
|
-
<meta property="og:type" content="website" />
|
|
781
|
+
returnString += ` <meta property="og:type" content="website" />
|
|
771
782
|
<meta property="og:locale" content="${language}" />
|
|
772
783
|
<meta property="og:site_name" content="${siteName}" />
|
|
773
|
-
<meta property="og:title" content="${fields.title}"
|
|
784
|
+
<meta property="og:title" content="${fields.title}" />`+ "\n";
|
|
774
785
|
|
|
775
786
|
{
|
|
776
787
|
let currentArray = site.injectCodeSnippets;
|
|
777
788
|
let currentArrayLength = currentArray.length;
|
|
778
789
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
779
|
-
returnString += currentArray[i];
|
|
790
|
+
returnString += " " + currentArray[i] + "\n";
|
|
780
791
|
}
|
|
781
792
|
}
|
|
782
793
|
|
|
783
794
|
if(process.env.INLINE_STYLE_SHEET == 1) {
|
|
784
|
-
returnString +=
|
|
795
|
+
returnString += ` <style>`+ "\n";
|
|
785
796
|
|
|
786
797
|
let assetsDir = Dbm.getInstance().repository.getItem("site").assetsDir;
|
|
787
798
|
let cssContent = await fs.promises.readFile(assetsDir + "/css/main.css", 'utf8');
|
|
788
799
|
|
|
789
800
|
returnString += cssContent;
|
|
790
801
|
|
|
791
|
-
returnString +=
|
|
802
|
+
returnString += ` </style>`+ "\n";
|
|
792
803
|
}
|
|
793
804
|
else {
|
|
794
|
-
returnString +=
|
|
805
|
+
returnString += ` <link rel="stylesheet" type="text/css" href="${assetsUri}css/main.css?version=${version}" />`+ "\n";
|
|
795
806
|
}
|
|
796
807
|
|
|
797
808
|
|
|
798
809
|
|
|
799
|
-
returnString +=
|
|
810
|
+
returnString += ` <link rel="icon" type="image/png" href="${baseUrl}${assetsUri}img/favicon.png" />`+ "\n";
|
|
800
811
|
|
|
801
812
|
if(fields['meta/description']) {
|
|
802
|
-
returnString += `
|
|
803
|
-
<meta name="description" content="${fields['meta/description']}" />
|
|
804
|
-
<meta property="og:description" content="${fields['meta/description']}" />
|
|
805
|
-
`;
|
|
813
|
+
returnString += ` <meta property="og:description" content="${fields['meta/description']}" />`+ "\n";;
|
|
806
814
|
}
|
|
807
815
|
|
|
808
|
-
|
|
816
|
+
|
|
809
817
|
|
|
810
|
-
returnString += `
|
|
811
|
-
<link rel="canonical" href="${fullUrl}" />
|
|
812
|
-
<meta property="og:url" content="${fullUrl}" />
|
|
813
|
-
`;
|
|
818
|
+
returnString += ` <meta property="og:url" content="${fullUrl}" />`+ "\n";
|
|
814
819
|
|
|
815
820
|
if(fields["lastModified"]) {
|
|
816
|
-
returnString +=
|
|
821
|
+
returnString += ` <meta property="article:modified_time" content="${fields["lastModified"]}" />`+ "\n";;
|
|
817
822
|
}
|
|
818
823
|
|
|
819
824
|
let image = await urlObject.singleObjectRelationQuery("in:isMainImageFor:image");
|
|
@@ -825,16 +830,16 @@ export const setupSite = function(aServer) {
|
|
|
825
830
|
let scaleString = "width=1200,height=630,fit=cover,format=jpeg";
|
|
826
831
|
imageUrl = imageUrl.split("{scale}").join(scaleString);
|
|
827
832
|
|
|
828
|
-
returnString +=
|
|
829
|
-
returnString +=
|
|
830
|
-
returnString +=
|
|
831
|
-
returnString +=
|
|
832
|
-
returnString +=
|
|
833
|
+
returnString += ` <meta property="og:image" content="${imageUrl}" />`+ "\n";;
|
|
834
|
+
returnString += ` <meta property="og:image:width" content="1200" />`+ "\n";;
|
|
835
|
+
returnString += ` <meta property="og:image:height" content="630" />`+ "\n";;
|
|
836
|
+
returnString += ` <meta property="og:image:type" content="image/jpeg" />`+ "\n";;
|
|
837
|
+
returnString += ` <meta property="twitter:card" content="summary_large_image" />`+ "\n";;
|
|
833
838
|
}
|
|
834
839
|
else {
|
|
835
840
|
let imageUrl = imageFields["url"];
|
|
836
|
-
returnString +=
|
|
837
|
-
returnString +=
|
|
841
|
+
returnString += ` <meta property="og:image" content="${imageUrl}" />`+ "\n";;
|
|
842
|
+
returnString += ` <meta property="twitter:card" content="summary_large_image" />`+ "\n";;
|
|
838
843
|
}
|
|
839
844
|
}
|
|
840
845
|
|
|
@@ -842,8 +847,8 @@ export const setupSite = function(aServer) {
|
|
|
842
847
|
<meta property="article:publisher" content="https://sv-se.facebook.com/..." />
|
|
843
848
|
*/
|
|
844
849
|
|
|
845
|
-
returnString +=
|
|
846
|
-
|
|
850
|
+
returnString += ` </head>
|
|
851
|
+
<body>
|
|
847
852
|
<div id="site"></div>
|
|
848
853
|
<script>
|
|
849
854
|
(function(d,b,m,j,s){
|
|
@@ -853,8 +858,8 @@ export const setupSite = function(aServer) {
|
|
|
853
858
|
|
|
854
859
|
dbmstartup.modules.create(document.getElementById("site"), "${moduleName}", {});
|
|
855
860
|
</script>
|
|
856
|
-
|
|
857
|
-
|
|
861
|
+
</body>
|
|
862
|
+
</html>`;
|
|
858
863
|
|
|
859
864
|
return returnString;
|
|
860
865
|
});
|