The CKAN GitImport Plugin enables users to fetch and display GitHub repository metadata within a specialized "GitHub" template in the CKAN user interface. After the metadata is displayed, it can be stored within CKAN datasets. This plugin streamlines the process of linking GitHub repositories with CKAN datasets, making it more efficient and user-friendly.
- Fetch GitHub Repository Metadata: Automatically retrieves metadata from GitHub repositories by simply adding the repository name then pressing the "Fetch Metadata" button.
- Dynamic Field Population: Dynamically populates CKAN dataset fields with fetched GitHub metadata, such as contributors, topics, etc., as needed.
- User-Friendly Interface: Seamlessly integrates with CKAN's UI.
Compatibility with core CKAN versions:
CKAN version | Compatible? |
---|---|
2.10 | yes |
2.9 and earlier | not tested |
To install ckanext-gitimport:
-
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://github.com/SDM-TIB/ckanext-gitimport cd ckanext-gitimport pip install -e . pip install -r requirements.txt
-
Add support for the "GitHub" dataset type title in your CKAN theme:
If you are using a custom CKAN theme such asckanext-TIBtheme
, you must update the methodget_dataset_type_title
in:Plugins/ckanext-TIBtheme/ckanext/TIBtheme/plugin.py
to this:
def get_dataset_type_title(dataset_type): aux_list = { 'dataset': 'Dataset', 'vdataset': 'Imported Dataset', 'service': 'Service', 'github': 'GitHub' # Add this line }
This step is required to ensure the "GitHub" dataset type displays correctly in the CKAN UI.
-
Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
-
Add the plugin
gitimport
to theckan.plugins
list in the CKAN config fileckan-entrypoint.sh
. -
Add the yaml File
ckanext.scheming:ckan_github.yaml
to thescheming.dataset_schemas
list in the CKAN config fileckan-entrypoint.sh
. -
The plugin requires a GitHub access token to fetch repository data. Please ensure that the token is valid as they usually expire after a certain time. You will need to regenerate a new token periodically to maintain functionality.
-
Add your GitHub access token to the CKAN config file(ckan-entrypoint.sh):
ckanext.gitimport.github_access_token = YOUR_GITHUB_ACCESS_TOKEN
To use the plugin:
- In your CKAN instance, access the "GitHub Import" button in navigation bar.
- Then click on "Add GitHub" where you will find the template.
- Enter the GitHub repository name (e.g., SDM-TIB/ckanext-gitimport) in the provided template field then press the "Fetch Metadata" button.
- The plugin will then fetch and display the repository metadata.
This plugin is designed to work with the "GitHub" template, which is created using the ckanext-scheming extension. The template consists of a YAML file that details the schema and the necessary HTML files. Ensure that ckanext-scheming is also installed and properly configured in your CKAN instance.