Skip to content

Commit

Permalink
Merge branch 'ckan:master' into add-hvds-to-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
seitenbau-govdata authored Jan 19, 2024
2 parents 1701094 + 1109205 commit 35d1f3e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion ckanext/dcat/blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def read_catalog(_format=None, package_type=None):
def read_dataset(_id, _format=None, package_type=None):
return utils.read_dataset_page(_id, _format)

if toolkit.asbool(config.get(utils.ENABLE_RDF_ENDPOINTS_CONFIG, True)):

if utils.endpoints_enabled():

# requirements={'_format': 'xml|rdf|n3|ttl|jsonld'}
dcat.add_url_rule(config.get('ckanext.dcat.catalog_endpoint',
Expand Down
1 change: 1 addition & 0 deletions ckanext/dcat/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def get_helpers(self):
return {
'helper_available': utils.helper_available,
'dcat_get_endpoint': utils.get_endpoint,
'dcat_endpoints_enabled': utils.endpoints_enabled,
}

# IActions
Expand Down
16 changes: 10 additions & 6 deletions ckanext/dcat/templates/package/read_base.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{% ckan_extends %}
{% block links %}

{{ super() }}
{% with endpoint=h.dcat_get_endpoint('dataset') %}
<link rel="alternate" type="text/n3" href="{{ h.url_for(endpoint, _id=pkg.id, _format='n3', _external=True) }}"/>
<link rel="alternate" type="text/turtle" href="{{ h.url_for(endpoint, _id=pkg.id, _format='ttl', _external=True) }}"/>
<link rel="alternate" type="application/rdf+xml" href="{{ h.url_for(endpoint, _id=pkg.id, _format='xml', _external=True) }}"/>
<link rel="alternate" type="application/ld+json" href="{{ h.url_for(endpoint, _id=pkg.id, _format='jsonld', _external=True) }}"/>
{% endwith %}

{% if h.dcat_endpoints_enabled() %}
{% with endpoint=h.dcat_get_endpoint('dataset') %}
<link rel="alternate" type="text/n3" href="{{ h.url_for(endpoint, _id=pkg.id, _format='n3', _external=True) }}"/>
<link rel="alternate" type="text/turtle" href="{{ h.url_for(endpoint, _id=pkg.id, _format='ttl', _external=True) }}"/>
<link rel="alternate" type="application/rdf+xml" href="{{ h.url_for(endpoint, _id=pkg.id, _format='xml', _external=True) }}"/>
<link rel="alternate" type="application/ld+json" href="{{ h.url_for(endpoint, _id=pkg.id, _format='jsonld', _external=True) }}"/>
{% endwith %}
{% endif %}
{% endblock -%}
{% block body_extras %}
{{ super() }}
Expand Down
4 changes: 4 additions & 0 deletions ckanext/dcat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,5 +452,9 @@ def read_catalog_page(_format):
return response


def endpoints_enabled():
return toolkit.asbool(config.get(ENABLE_RDF_ENDPOINTS_CONFIG, True))


def get_endpoint(_type='dataset'):
return 'dcat.read_dataset' if _type == 'dataset' else 'dcat.read_catalog'

0 comments on commit 35d1f3e

Please sign in to comment.