This extension contains a set of possibly reusable plugins developed for the EPOS MSL CKAN portal.
Plugins contained in this extension:
- msl_custom_facets
- msl_repeating_fields
- msl_search
This extension has been developed and tested with CKAN version 2.9.* Use of this extension is depended on the CKAN scheming extension being loaded.
To install ckanext-msl_ckan_util:
-
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
-
Clone the source and install it on the virtualenv
git clone https://git.science.uu.nl/epos-msl/msl_ckan_util.git cd ckanext-msl_ckan_util pip install -e . pip install -r requirements.txt
-
Add names of plugins to the
ckan.plugins
setting in your CKAN config file (by default the config file is located at/etc/ckan/default/ckan.ini
). Specific names and settings per plugin are described in the section of the plugins. -
Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
When config settings are required they are described per plugin.
The custom facets plugin enables easy configuring of displayed facets in plugin by supplying a configuration json file. A default facet list should be given and optional facet lists per specific package type (configured in CKAN scheming) can be configured.
To activate this plugin add the name msl_custom_facets
to the ckan.plugin
setting in the ckan.ini
.
This plugin requires a json config file to function. The location of the config file must be set in the ckan.ini
file.
The setting that should be added: mslfacets.dataset_config
the value should contain the reference to the config
file. The value should be formatted like <ckan_extension_name>:<path><filename>
. To reference the sample file config
supplied with this extension use: ckanext.msl_ckan_util:samples/facets.json
.
Sample json config file:
{
"default":
{
"dataset_type": "Type",
"organization": "Organizations",
"groups": "Groups"
},
"rockphysics" :
{
"msl_material": "Materials",
"tags": "Tags",
"msl_rock_measured_property": "Measured property"
}
The default key should always be given. A list of facets can be supplied. The keys contain the fields that should be faceted on and the value contains the displayed label at the text. Other lists of facets can be configured to be displayed for specific dataset types. These should be configured using ckan scheming.
The default implemented CKAN facets are:
"organization": "Organizations",
"groups": "Groups",
"tags": "Tags",
"res_format": "Formats",
"license_id": "Licenses"
This plugin 'flattens' repeating subfields defined in scheming schemas to enable solr to index the field.
To activate this plugin add the name msl_repeating_fields
to the ckan.plugin
setting in the ckan.ini
.
This plugin requires a json config file to function. The location of the config file must be set in the ckan.ini
file.
The setting that should be added: mslindexfield.field_config
the value should contain the reference to the config
file. The value should be formatted like <ckan_extension_name>:<path><filename>
. To reference the sample file config
supplied with this extension use: ckanext.msl_ckan_util:samples/msl_index_fields.json
.
Sample json config file:
{
"special_index_fields": [
"msl_material",
"msl_rock_measured_property"
],
"remove_index_fields": [
"msl_tags"
]
}
The special_index_fields
should contain a list of fields that should be 'flattened' for SOLR indexing.
The remove_index_fields
contains a list to specify which fields should be removed from the data send to SOLR.
This plugin changes all searches to use the SOLR eDisMax query parser instead of the dismax version.
To activate this plugin add the name msl_search
to the ckan.plugin
setting in the ckan.ini
.
To install ckanext-msl_ckan_util for development, activate your CKAN virtualenv and do:
git clone https://git.science.uu.nl/epos-msl/msl_ckan_util.git
cd ckanext-msl_ckan_util
python setup.py develop
pip install -r dev-requirements.txt
To run the tests, do:
pytest --ckan-ini=test.ini
If ckanext-msl_ckan_util should be available on PyPI you can follow these steps to publish a new version:
-
Update the version number in the
setup.py
file. See PEP 440 for how to choose version numbers. -
Make sure you have the latest version of necessary packages:
pip install --upgrade setuptools wheel twine
-
Create a source and binary distributions of the new version:
python setup.py sdist bdist_wheel && twine check dist/*
Fix any errors you get.
-
Upload the source distribution to PyPI:
twine upload dist/*
-
Commit any outstanding changes:
git commit -a git push
-
Tag the new release of the project on GitHub with the version number from the
setup.py
file. For example if the version number insetup.py
is 0.0.1 then do:git tag 0.0.1 git push --tags