@@ -247,6 +247,8 @@ public function getLandingPage(string $id, Request $request) {
247
247
$ this ->cache ->set ($ cid , $ renderArray , CacheBackendInterface::CACHE_PERMANENT , [$ cid ]);
248
248
}
249
249
250
+ // Handle caching.
251
+ $ this ->renderer ->addCacheableDependency ($ renderArray , $ main_config );
250
252
return $ renderArray ;
251
253
252
254
}
@@ -378,15 +380,16 @@ protected function generateLandingPage($main_config, $host, $fullhost, $id, $id_
378
380
}
379
381
380
382
// Add article prefix.
383
+ $ renderArray = [];
381
384
$ renderArray ['#prefix ' ] = '<div class=dynamic-landing-page> ' ;
382
385
$ renderArray ['#suffix ' ] = '</div> ' ;
383
- $ renderArray = [];
384
386
385
387
$ renderArray ['timestamp ' ] = [
386
388
'#type ' => 'value ' ,
387
389
'#value ' => strtotime ($ fields ['timestamp ' ]),
388
390
];
389
-
391
+ // Add page title.
392
+ $ renderArray ['#title ' ] = $ fields ['title ' ][0 ];
390
393
// Render the title.
391
394
$ renderArray ['title ' ] = [
392
395
'#type ' => 'markup ' ,
@@ -989,7 +992,8 @@ protected function generateLandingPage($main_config, $host, $fullhost, $id, $id_
989
992
$ renderArray ['#attached ' ]['library ' ][] = 'metsis_lib/landing_page ' ;
990
993
$ renderArray ['#attached ' ]['library ' ][] = 'metsis_lib/fa_academia ' ;
991
994
$ renderArray ['#cache ' ] = [
992
- 'contexts ' => ['url ' ],
995
+ 'contexts ' => ['url.path ' ],
996
+ 'bin ' => 'dynamic_landingpages ' ,
993
997
'tags ' => ['dataset: ' . $ dataset_id ],
994
998
'max-age ' => Cache::PERMANENT ,
995
999
];
@@ -1069,28 +1073,149 @@ public function getJsonld($fields, $host, $id_prefix) {
1069
1073
if (isset ($ fields ['temporal_extent_end_date ' ])) {
1070
1074
$ end_date = $ fields ['temporal_extent_end_date ' ][0 ];
1071
1075
}
1076
+ else {
1077
+ $ end_date = '.. ' ;
1078
+ }
1072
1079
$ mid = $ fields ['metadata_identifier ' ];
1073
1080
if ($ id_prefix === 'no-met-nbs ' ) {
1074
1081
$ mid = explode (': ' , $ fields ['metadata_identifier ' ])[1 ];
1075
1082
}
1083
+ $ keywords = [];
1084
+ if (isset ($ fields ['keywords_gcmd ' ])) {
1085
+ foreach ($ fields ['keywords_gcmd ' ] as $ gcmd ) {
1086
+ $ keywords [] = [
1087
+ '@type ' => 'DefinedTerm ' ,
1088
+ 'name ' => $ gcmd ,
1089
+ 'inDefinedTermSet ' => 'https://gcmd.earthdata.nasa.gov/kms/concepts/concept_scheme/sciencekeywords '
1090
+ ];
1091
+ }
1092
+ }
1093
+ if (isset ($ fields ['keywords_cfstdn ' ])) {
1094
+ foreach ($ fields ['keywords_cfstdn ' ] as $ cfstdn ) {
1095
+ $ keywords [] = [
1096
+ '@type ' => 'DefinedTerm ' ,
1097
+ 'name ' => $ cfstdn ,
1098
+ 'inDefinedTermSet ' => 'https://vocab.nerc.ac.uk/standard_name/ ' ,
1099
+ 'url ' => 'https://vocab.nerc.ac.uk/standard_name/ ' . $ cfstdn
1100
+ ];
1101
+ }
1102
+ }
1103
+ if (isset ($ fields ['project_long_name ' ])) {
1104
+ $ projects = [];
1105
+ foreach ($ fields ['project_long_name ' ] as $ projectln ) {
1106
+ $ projects [] = [
1107
+ '@type ' => 'MonetaryGrant ' ,
1108
+ 'name ' => $ projectln
1109
+ ];
1110
+ }
1111
+ }
1112
+ if (isset ($ fields ['personnel_investigator_name ' ])) {
1113
+ $ creators = [];
1114
+ foreach ($ fields ['personnel_investigator_name ' ] as $ creator ) {
1115
+ $ creators [] = [
1116
+ '@type ' => 'Person ' ,
1117
+ 'name ' => $ creator
1118
+ ];
1119
+ }
1120
+ }
1121
+ if (isset ($ fields ['personnel_investigator_organisation ' ])) {
1122
+ $ providers = [];
1123
+ foreach ($ fields ['personnel_investigator_organisation ' ] as $ provider ) {
1124
+ $ providers [] = [
1125
+ '@type ' => 'Organization ' ,
1126
+ 'name ' => $ provider
1127
+ ];
1128
+ }
1129
+ }
1130
+ if (isset ($ fields ['personnel_technical_name ' ]) or isset ($ fields ['personnel_metadata_author_name ' ])) {
1131
+ $ contributors = [];
1132
+ if (isset ($ fields ['personnel_technical_name ' ])) {
1133
+ foreach ($ fields ['personnel_investigator_name ' ] as $ contributor ) {
1134
+ $ contributors [] = [
1135
+ '@type ' => 'Person ' ,
1136
+ 'name ' => $ contributor ,
1137
+ ];
1138
+ }
1139
+ }
1140
+ if (isset ($ fields ['personnel_metadata_author_name ' ])) {
1141
+ foreach ($ fields ['personnel_metadata_author_name ' ] as $ contributor ) {
1142
+ $ contributors [] = [
1143
+ '@type ' => 'Person ' ,
1144
+ 'name ' => $ contributor
1145
+ ];
1146
+ }
1147
+ }
1148
+ }
1149
+ if (isset ($ fields ['data_access_url_http ' ])) {
1150
+ $ datadownloads = [];
1151
+ foreach ($ fields ['data_access_url_http ' ] as $ datadownload ) {
1152
+ $ datadownloads [] = [
1153
+ '@type ' => 'DataDownload ' ,
1154
+ 'description ' => 'Direct dowload ' ,
1155
+ 'contentUrl ' => $ datadownload
1156
+ ];
1157
+ }
1158
+ }
1159
+ if (isset ($ fields ['geographic_extent_rectangle_north ' ])) {
1160
+ $ spatialcoverage = [
1161
+ '@type ' => 'Place ' ,
1162
+ 'geo ' => [
1163
+ '@type ' => 'GeoShape ' ,
1164
+ 'box ' => implode (" " , [$ fields ['geographic_extent_rectangle_south ' ],
1165
+ $ fields ['geographic_extent_rectangle_west ' ],
1166
+ $ fields ['geographic_extent_rectangle_north ' ],
1167
+ $ fields ['geographic_extent_rectangle_east ' ],
1168
+ ]),
1169
+ ],
1170
+ 'additionalProperty ' => [
1171
+ '@type ' => 'PropertyValue ' ,
1172
+ 'propertyID ' => 'http://inspire.ec.europa.eu/glossary/SpatialReferenceSystem ' ,
1173
+ 'value ' => 'http://www.opengis.net/def/crs/EPSG/0/ '
1174
+ . $ fields ['geographic_extent_rectangle_srsName ' ],
1175
+ ],
1176
+ ];
1177
+ }
1178
+ if (in_array ("Created " , $ fields ['last_metadata_update_type ' ])) {
1179
+ $ i = 0 ;
1180
+ foreach ($ fields ['last_metadata_update_type ' ] as $ mdupdatedt ) {
1181
+ if ($ mdupdatedt == 'Created ' ) {
1182
+ $ datecreated = $ fields ['last_metadata_update_datetime ' ][$ i ];
1183
+ }
1184
+ $ i ++;
1185
+ }
1186
+ }
1076
1187
$ json = [
1077
- '@context ' => ' https://schema.org/ ' ,
1188
+ '@context ' => [ ' @vocab ' => ' https://schema.org/ '] ,
1078
1189
'@type ' => 'Dataset ' ,
1079
- '@id ' => $ fields ['related_url_landing_page ' ][0 ] ?? '' ,
1190
+ '@id ' => $ fields ['metadata_identifier ' ],
1191
+ 'identifier ' => [
1192
+ '@type ' => 'PropertyValue ' ,
1193
+ '@id ' => $ fields ['related_url_landing_page ' ][0 ] ?? '' ,
1194
+ 'url ' => $ fields ['related_url_landing_page ' ][0 ] ?? '' ,
1195
+ 'value ' => $ mid ,
1196
+ ],
1080
1197
'name ' => $ fields ['title ' ][0 ],
1081
1198
'description ' => $ fields ['abstract ' ][0 ],
1082
1199
'url ' => $ fields ['related_url_landing_page ' ][0 ] ?? '' ,
1083
- 'identifier ' => [
1084
- $ mid ,
1085
- ],
1086
- 'keywords ' => $ fields ['keywords_keyword ' ],
1087
- 'license ' => $ fields ['use_constraint_resource ' ] ?? "" ,
1200
+ 'dateCreated ' => $ datecreated ?? '' ,
1201
+ 'license ' => $ fields ['use_constraint_resource ' ] ?? '' ,
1202
+ 'keywords ' => $ keywords ,
1088
1203
'includedInDataCatalog ' => [
1089
1204
'@type ' => 'DataCatalog ' ,
1090
1205
'name: ' => $ host ,
1091
1206
],
1092
- 'temporalCoverage ' => $ start_date . '/ ' . $ end_date ?? '' ,
1093
-
1207
+ 'temporalCoverage ' => $ start_date . '/ ' . $ end_date ,
1208
+ 'spatialCoverage ' => $ spatialcoverage ,
1209
+ 'conditionsOfAccess ' => $ fields ['access_constraint ' ] ?? '' ,
1210
+ 'creator ' => $ creators ?? '' ,
1211
+ 'contributor ' => $ contributors ?? '' ,
1212
+ 'provider ' => $ providers ?? '' ,
1213
+ 'publisher ' => [
1214
+ '@type ' => 'Organization ' ,
1215
+ 'name ' => $ fields ['data_center_long_name ' ][0 ] ?? '' ,
1216
+ 'url ' => $ fields ['data_center_url ' ][0 ] ?? '' ,
1217
+ ],
1218
+ 'funding ' => $ projects ?? '' ,
1094
1219
];
1095
1220
return $ json ;
1096
1221
}
0 commit comments