From 7f09d4ce3cdd82a538071dec0f50191c7fa01520 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 19 Nov 2020 00:31:33 +0100 Subject: [PATCH 1/3] google expects plain schema-org url https://yoast.com/json-ld/ resolves #574 --- pygeoapi/linked_data.py | 2 +- tests/test_api.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygeoapi/linked_data.py b/pygeoapi/linked_data.py index fb89c05fa..f7b6410d2 100644 --- a/pygeoapi/linked_data.py +++ b/pygeoapi/linked_data.py @@ -60,7 +60,7 @@ def inner(*args, **kwargs): provider = meta.get('provider', {}) ident = meta.get('identification', {}) fcmld = { - "@context": "https://schema.org/docs/jsonldcontext.jsonld", + "@context": "https://schema.org/", "@type": "DataCatalog", "@id": cfg.get('server', {}).get('url', None), "url": cfg.get('server', {}).get('url', None), diff --git a/tests/test_api.py b/tests/test_api.py index 2a9484f74..a89e41ca7 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -154,7 +154,7 @@ def test_root_structured_data(config, api_): assert root['description'] == 'pygeoapi provides an API to geospatial data' assert '@context' in root - assert root['@context'] == 'https://schema.org/docs/jsonldcontext.jsonld' + assert root['@context'] == 'https://schema.org/' expanded = jsonld.expand(root)[0] assert '@type' in expanded assert 'http://schema.org/DataCatalog' in expanded['@type'] From 3a7e6aa158f598cb4bb3725ca065632c954fc0d2 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 24 Nov 2020 08:32:38 +0100 Subject: [PATCH 2/3] Revert "google expects plain schema-org url" This reverts commit 7f09d4ce3cdd82a538071dec0f50191c7fa01520. --- pygeoapi/linked_data.py | 2 +- tests/test_api.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygeoapi/linked_data.py b/pygeoapi/linked_data.py index f7b6410d2..fb89c05fa 100644 --- a/pygeoapi/linked_data.py +++ b/pygeoapi/linked_data.py @@ -60,7 +60,7 @@ def inner(*args, **kwargs): provider = meta.get('provider', {}) ident = meta.get('identification', {}) fcmld = { - "@context": "https://schema.org/", + "@context": "https://schema.org/docs/jsonldcontext.jsonld", "@type": "DataCatalog", "@id": cfg.get('server', {}).get('url', None), "url": cfg.get('server', {}).get('url', None), diff --git a/tests/test_api.py b/tests/test_api.py index a89e41ca7..2a9484f74 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -154,7 +154,7 @@ def test_root_structured_data(config, api_): assert root['description'] == 'pygeoapi provides an API to geospatial data' assert '@context' in root - assert root['@context'] == 'https://schema.org/' + assert root['@context'] == 'https://schema.org/docs/jsonldcontext.jsonld' expanded = jsonld.expand(root)[0] assert '@type' in expanded assert 'http://schema.org/DataCatalog' in expanded['@type'] From 5b5f775c03da5a08dca6153c0b96553e519568dc Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 24 Nov 2020 08:36:33 +0100 Subject: [PATCH 3/3] hack to replace full path for short path, because pyld requires full, search engine expects short --- pygeoapi/templates/base.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygeoapi/templates/base.html b/pygeoapi/templates/base.html index c016b9020..4f66b31ff 100644 --- a/pygeoapi/templates/base.html +++ b/pygeoapi/templates/base.html @@ -69,7 +69,8 @@ var head = document.getElementsByTagName('head')[0]; var jsonld_datablock = document.createElement('script'); jsonld_datablock.type = "application/ld+json"; - jsonld_datablock.textContent = xhr.responseText; + //remove full context path, because search engines don't expect it here, pyld requires it. + jsonld_datablock.textContent = xhr.responseText.replace('docs/jsonldcontext.jsonld',''); head.appendChild(jsonld_datablock); } };