[![Tests](https://github.com/mutantsan/ckanext-alias/workflows/Tests/badge.svg?branch=master)](https://github.com/mutantsan/ckanext-alias/actions)
The extension allow you to create a URL aliases for datasets. For example, if you have a dataset with `my-dataset` name, it can be accessed via URL like that `https://your-domain/dataset/my-dataset`. Now you could add multiple aliases that will redirect user to the dataset.
Creating and managing aliases is easy. There are two ways to create an alias.
1. An alias could be created automatically, if the `ckanext.alias.autosave_alias` config option in enabled. (_see [Config settings section](#config-settings) below_)
![Alt Text](doc/auto-alias.gif)
The automatic creation will be triggered only if the new `name` differs from the previous one.
2. An alias could be created manually via dataset create/edit form.
![Alt Text](doc/manual-alias.gif)
## Requirements
The extension has only been tested with CKAN `2.10.1` and will most likely not work with versions below `2.10`.
Also, the extension relies on `ckanext-scheming` to add an `alias` field into schema. It won't work without scheming.
If you don't know what is it and how to use it, check its [repo](https://github.com/ckan/ckanext-scheming).
## Installation
1. Use `pip` to install an extension: `pip install ckanext-alias`
2. Add `alias` to the `ckan.plugins` setting in your CKAN config file.
### Add an `alias` field to schema
`ckanext-alias` requires adjusting a dataset schema, to add an alias field that will store all the information. The extension provides multiple presets, which you could use to easilly adjust the schema.
1. Add presets `scheming.presets = ckanext.alias:presets.yaml`
2. Open you schema. You have to edit `name` field and add a new `alias` field:
```
- field_name: name
preset: dataset_alias_slug
- field_name: alias
preset: dataset_alias
```
- The `alias` field name must be the same as `ckanext.alias.alias_fieldname`.
- Check `presets.yaml` file to see the presets in details.
- If your `name` field was altered before, you don't have to use the `dataset_alias_slug` preset. Just add the `name_doesnt_conflict_with_alias` validator to list of yours.
## Config settings
The extension provides several configuration options to customize it.
```
# Specify a list of dataset types that is going to support aliases. Each specified dataset type schema
# must contain an alias field, otherwise, the extension isn't going to work (optional, default: dataset).
ckanext.alias.dataset_types = dataset project
```
```
# Specify an alias field name in dataset schema. The extension won't work, if the schema
# doesn't contain a specified field (optional, default: alias).
ckanext.alias.alias_fieldname = pkg_alias
```
```
# Specify whether a new alias will be created automatically on dataset update.
# If the name differs from the previous one, the alias will be created (optional, default: false).
ckanext.alias.autosave_alias = true
```
## Developer installation
To install ckanext-alias for development, activate your CKAN virtualenv and do:
git clone https://github.com/mutantsan/ckanext-alias.git
cd ckanext-alias
python setup.py develop
pip install -r dev-requirements.txt
## Tests
To run the tests, do:
pytest --ckan-ini=test.ini
## License
[AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
Raw data
{
"_id": null,
"home_page": "https://github.com/mutantsan/ckanext-alias",
"name": "ckanext-alias",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "CKAN",
"author": "Oleksandr Cherniavskyi",
"author_email": "mutantsan@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/50/16/44c52242bf9112487f8a007084e30c345472ca7d0832fafe87911998f8dc/ckanext-alias-1.0.1.tar.gz",
"platform": null,
"description": "\n\n[![Tests](https://github.com/mutantsan/ckanext-alias/workflows/Tests/badge.svg?branch=master)](https://github.com/mutantsan/ckanext-alias/actions)\n\nThe extension allow you to create a URL aliases for datasets. For example, if you have a dataset with `my-dataset` name, it can be accessed via URL like that `https://your-domain/dataset/my-dataset`. Now you could add multiple aliases that will redirect user to the dataset.\n\nCreating and managing aliases is easy. There are two ways to create an alias.\n1. An alias could be created automatically, if the `ckanext.alias.autosave_alias` config option in enabled. (_see [Config settings section](#config-settings) below_)\n ![Alt Text](doc/auto-alias.gif)\n The automatic creation will be triggered only if the new `name` differs from the previous one.\n2. An alias could be created manually via dataset create/edit form.\n ![Alt Text](doc/manual-alias.gif)\n\n## Requirements\n\nThe extension has only been tested with CKAN `2.10.1` and will most likely not work with versions below `2.10`.\nAlso, the extension relies on `ckanext-scheming` to add an `alias` field into schema. It won't work without scheming.\nIf you don't know what is it and how to use it, check its [repo](https://github.com/ckan/ckanext-scheming).\n\n## Installation\n\n1. Use `pip` to install an extension: `pip install ckanext-alias`\n2. Add `alias` to the `ckan.plugins` setting in your CKAN config file.\n\n### Add an `alias` field to schema\n`ckanext-alias` requires adjusting a dataset schema, to add an alias field that will store all the information. The extension provides multiple presets, which you could use to easilly adjust the schema.\n\n\n1. Add presets `scheming.presets = ckanext.alias:presets.yaml`\n2. Open you schema. You have to edit `name` field and add a new `alias` field:\n\n\t```\n\t- field_name: name\n\t preset: dataset_alias_slug\n\n\t- field_name: alias\n\t preset: dataset_alias\n\t```\n\n\t- The `alias` field name must be the same as `ckanext.alias.alias_fieldname`.\n\t- Check `presets.yaml` file to see the presets in details.\n\t- If your `name` field was altered before, you don't have to use the `dataset_alias_slug` preset. Just add the `name_doesnt_conflict_with_alias` validator to list of yours.\n\n## Config settings\n\nThe extension provides several configuration options to customize it.\n\n```\n# Specify a list of dataset types that is going to support aliases. Each specified dataset type schema\n# must contain an alias field, otherwise, the extension isn't going to work (optional, default: dataset).\nckanext.alias.dataset_types = dataset project\n```\n```\n# Specify an alias field name in dataset schema. The extension won't work, if the schema\n# doesn't contain a specified field (optional, default: alias).\nckanext.alias.alias_fieldname = pkg_alias\n```\n```\n# Specify whether a new alias will be created automatically on dataset update.\n# If the name differs from the previous one, the alias will be created (optional, default: false).\nckanext.alias.autosave_alias = true\n```\n## Developer installation\n\nTo install ckanext-alias for development, activate your CKAN virtualenv and do:\n\n git clone https://github.com/mutantsan/ckanext-alias.git\n cd ckanext-alias\n python setup.py develop\n pip install -r dev-requirements.txt\n\n## Tests\n\nTo run the tests, do:\n\n pytest --ckan-ini=test.ini\n\n\n## License\n\n[AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)\n",
"bugtrack_url": null,
"license": "AGPL",
"summary": "An extension to create URL aliases for datasets",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/mutantsan/ckanext-alias"
},
"split_keywords": [
"ckan"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c5b8f833e21b52d387b3b661224f1b1b8a03e537a81c0b86ccf3415cadd3044d",
"md5": "f0cdd5c5e3dca89586a6d08c288863e2",
"sha256": "449fd2db730c470fa078dc15863ea1cad8ead9e45e2387290f4f03418d737b5b"
},
"downloads": -1,
"filename": "ckanext_alias-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f0cdd5c5e3dca89586a6d08c288863e2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 23161,
"upload_time": "2023-09-04T06:06:02",
"upload_time_iso_8601": "2023-09-04T06:06:02.387484Z",
"url": "https://files.pythonhosted.org/packages/c5/b8/f833e21b52d387b3b661224f1b1b8a03e537a81c0b86ccf3415cadd3044d/ckanext_alias-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "501644c52242bf9112487f8a007084e30c345472ca7d0832fafe87911998f8dc",
"md5": "8a05bba2c04a042c1839d9df20b6dc19",
"sha256": "be17e208f80b37651c3a98c7aee560e1c24904932143c81821d86487787043c2"
},
"downloads": -1,
"filename": "ckanext-alias-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "8a05bba2c04a042c1839d9df20b6dc19",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21984,
"upload_time": "2023-09-04T06:06:04",
"upload_time_iso_8601": "2023-09-04T06:06:04.336996Z",
"url": "https://files.pythonhosted.org/packages/50/16/44c52242bf9112487f8a007084e30c345472ca7d0832fafe87911998f8dc/ckanext-alias-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-04 06:06:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mutantsan",
"github_project": "ckanext-alias",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "ckanext-alias"
}