Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Release #6

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@ jobs:
# needs: lint
strategy:
matrix:
ckan-version: [2.9]
ckan-base-version: [2.9]
ckan-version: [py3.9]
solr-version: [solr8]
fail-fast: false

name: CKAN ${{ matrix.ckan-version }}
name: CKAN ${{ matrix.ckan-base-version }}
runs-on: ubuntu-latest
container:
image: openknowledge/ckan-dev:${{ matrix.ckan-version }}
image: ckan/ckan-dev:${{ matrix.ckan-base-version }}-${{ matrix.ckan-version }}
options: --user root
services:
solr:
image: ckan/ckan-solr:${{ matrix.ckan-version }}-solr9
image: ckan/ckan-solr:${{ matrix.ckan-base-version }}-${{ matrix.solr-version }}
postgres:
image: ckan/ckan-postgres-dev:${{ matrix.ckan-version }}
image: ckan/ckan-postgres-dev:${{ matrix.ckan-base-version }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
Expand All @@ -48,6 +51,8 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Install CURL
run: apt install curl -y
- name: Install requirements
run: |
pip install -r dev-requirements.txt
Expand All @@ -66,8 +71,8 @@ jobs:
ckan -c test.ini db init
- name: Run tests
run: pytest --ckan-ini=test.ini --cov=ckanext.datasetsnippets --cov-report=xml --cov-append --disable-warnings ckanext/datasetsnippets/tests
- name: Upload coverage report to codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
token: ${{secrets.CODECOV_TOKEN}}
- name: Upload coverage reports to Codecov
run: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Development

## [0.1.10](https://github.com/berlinonline/ckanext-datasetsnippets/releases/tag/0.1.10)

_(2024-09-02)_

- Sanitize user input & handle author_string/author

## [0.1.9](https://github.com/berlinonline/ckanext-datasetsnippets/releases/tag/0.1.9)

_(2024-08-29)_
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ datasetsnippets.datenportal_title = 'Berlin Open Data'

## License

This material is copyright © [BerlinOnline Stadtportal GmbH](https://www.berlinonline.net/).
This material is copyright © [BerlinOnline GmbH](https://www.berlinonline.net/).

This extension is open and licensed under the GNU Affero General Public License (AGPL) v3.0.
Its full text may be found at:
Expand Down
2 changes: 1 addition & 1 deletion ckanext/datasetsnippets/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.9
0.1.10
14 changes: 11 additions & 3 deletions ckanext/datasetsnippets/blueprints/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,23 @@ def custom():
fields = request.params.get(u'fields', u'')
fq = u''
search_params = {}
# some facets are not with the name used in CKAN
changed_facets = {'author_string': 'author'}

for (param, value) in request.params.items():
if param not in [u'q', u'page', u'sort'] \
and len(value) and not param.startswith(u'_'):
if param == 'fq':
value_tmp = value.split('&')
result_dict = dict(pair.split('=') for pair in value_tmp)
for res in result_dict:
search_params[res] = result_dict[res]
fq += u' +%s:%s' % (res, result_dict[res])
if res in changed_facets.keys():
res_tmp = changed_facets[res]
search_params[res] = result_dict[res]
fq += u' +%s:%s' % (res_tmp, result_dict[res])
else:
search_params[res] = result_dict[res]
fq += u' +%s:%s' % (res, result_dict[res])
else:
search_params[param] = value
fq += u' %s:%s' % (param, value)
Expand Down Expand Up @@ -508,7 +516,7 @@ def _create_rss_id(resource_path, authority_name=None, date_string=None):

# Construct the GUID as a full URL
if authority_name:
return f"http://{authority_name}{resource_path}"
return f"https://{authority_name}{resource_path}"
else:
# Fallback to just the resource path if authority_name is not available
return resource_path
Expand Down
4 changes: 3 additions & 1 deletion ckanext/datasetsnippets/blueprints/snippet_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import ckan.plugins as plugins
from ckan.plugins import toolkit
from ckan.common import _, c, request, config
from six.moves.urllib.parse import unquote

from ckanext.datasetsnippets.blueprints import feeds

Expand Down Expand Up @@ -156,7 +157,8 @@ def search_dataset():
if k != 'root_breadcrumb']

# unicode format (decoded from utf8)
q = c.q = request.params.get('q', u'')
q = request.params.get('q', u'')
c.q = unquote(q)
c.query_error = False
page = h.get_page_number(request.params)

Expand Down
144 changes: 144 additions & 0 deletions publiccode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# This repository adheres to the publiccode.yml standard by including this
# metadata file that makes public software easily discoverable.
# More info at https://github.com/italia/publiccode.yml

publiccodeYmlVersion: '0.2'
name: ckanext-datasetsnippets
url: 'https://github.com/berlinonline/ckanext-datasetsnippets'
releaseDate: '2022-02-22'
softwareVersion: 0.1.11
developmentStatus: stable
softwareType: addon
categories:
- it-development
- knowledge-management
maintenance:
type: internal
contacts:
- name: Dr. Knud Möller
email: [email protected]
legal:
license: AGPL-3.0-only
mainCopyrightOwner: BerlinOnline GmbH
repoOwner: BerlinOnline GmbH
localisation:
localisationReady: false
description:
it:
genericName: ckanext-datasetsnippets
documentation: >-
https://github.com/berlinonline/ckanext-datasetsnippets?tab=readme-ov-file#ckanext-datasetsnippets
apiDocumentation: >-
https://github.com/berlinonline/ckanext-datasetsnippets?tab=readme-ov-file#api
shortDescription: >-
ckanext-datasetsnippets provides markup snippets for dataset pages and
dataset search. These snippets can be loaded from the data portal's public
CMS
longDescription: >
This plugin belongs to a set of plugins for the _Datenregister_ – the
non-public [CKAN](https://ckan.org/) instance that is part of Berlin's
open data portal [daten.berlin.de](https://daten.berlin.de/).
_ckanext-datasetsnippets_ provides markup snippets for dataset pages and
dataset search. These snippets can be loaded from the data portal's public
CMS to handle all requests for datasets.


The plugin implements the following CKAN interfaces:


-
[ITemplateHelpers](http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.plugins.interfaces.ITemplateHelpers)

-
[IBlueprint](http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.plugins.interfaces.IBlueprint)

-
[IAuthFunctions](http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html#ckan.plugins.interfaces.IAuthFunctions)


## Requirements


This plugin has been tested with CKAN 2.9.9 (which requires Python 3).


## API


The Snippet API has the following two endpoints:


### `/snippet/dataset`


This is the search endpoint of the snippet API, which is equivalent to
`/dataset` in the regular CKAN UI. Without additional parameters, this
returns markup for the paginated list of all datasets. Parameters (search
facets, ordering etc.) can be use to restrict the result. The parameters
are identical to the regular CKAN search parameters.


### `/snippet/dataset/<id>`


This is the dataset detail endpoint of the snippet API, which is
equivalent to `/dataset/<id>` in the regular CKAN UI. `<id>` is the name
or id of a dataset.


### Parameters


Both endpoints allow a `root\_breadcrumb` parameter to set the root
element of the breadcrumb returned in the snippets. The
`root\_breadcrumb`-URL-parameter takes precedence over the
`datasetsnippets.default\_root\_breadcrumb` config (see below).


## Configuration


The plugin introduces the following configuration options:


### datasetsnippets.path


Defines the path component that is prefixed to links that the snippets
contain. In the regular CKAN UI, this would be `dataset`, but the site
calling the snippet API might require a different path.

datasetsnippets.path = 'datensaetze'

### datasetsnippets.datasets\_per\_page


Defines how many datasets are shown per result page in pagination. The
option is equivalent to
[ckan.datasets\_per\_page](https://docs.ckan.org/en/2.9/maintaining/configuration.html#ckan-datasets-per-page),
but only applies to the snippets and leaves the regular CKAN UI untouched.

datasetsnippets.datasets\_per\_page = 10

### datasetsnippets.default\_root\_breadcrumb


Defines the string that is used as the root element for the breadcrumb
that is part of the returned snippets.

datasetsnippets.default\_root\_breadcrumb = 'Berlin Open Data'

### datasetsnippets.datenportal\_url


Defines the url to the datenportal. The url will then be used for
generating the feeds using the provided url.

datasetsnippets.datenportal\_url = link\_to\_portal

### datasetsnippets.datenportal\_title


Defines a string that will be used as a title in the feeds.

datasetsnippets.datenportal\_title = 'Berlin Open Data'
Loading