Skip to main content

Tests

ckanext-pages

This extension gives you an easy way to add simple pages to CKAN.

By default you can add pages to the main CKAN menu.

Tested on CKAN 2.10 and newer.

This is a fork of ckan/ckanext-pages, adapted for the Fair3R CKAN portal (CNRS/IGBMC).

Installation

Use pip to install this plugin. This example installs it in /home/www-data/pyenv, assuming you have setup a virtualenv there:

source /usr/lib/ckan/default/bin/activate
pip install ckanext-fair3r-pages

Or, to install from source:

source /usr/lib/ckan/default/bin/activate
git clone <url-of-this-repository>
cd ckanext-pages
pip install -e .

Make sure to add pages to ckan.plugins in your config file:

ckan.plugins = pages

Database initialization

You need to initialize database from command line with the following commands:

ON CKAN >= 2.9:

(pyenv) $ ckan --config=/etc/ckan/default/ckan.ini db upgrade -p pages

Configuration

Extra config options allow you to control the creation of extra pages against groups and organizations.

To swich on this behaviour, to your config add:

ckanext.pages.organization = True
ckanext.pages.group = True

These options are False by default.

This module also gives you a quick way to remove default elements from the CKAN menu and you may need todo this in order for you to have space for the new items you add. These options are:

ckanext.pages.about_menu = False
ckanext.pages.group_menu = False
ckanext.pages.organization_menu = False

By default these are all set to True, like on a default install.

To enable HTML output for the pages (along with Markdown), add the following to your config:

ckanext.pages.allow_html = True

By default this option is set to False. Note that this feature is only available for CKAN >= 2.3. For older versions of CKAN, this option has no effect. Use this option with care and only allow this if you trust the input of your users.

If you want to use the WYSIWYG editor instead of Markdown:

ckanext.pages.editor = medium

or

ckanext.pages.editor = ckeditor

This enables either the medium or ckeditor

ckanext.pages.revisions_limit = 3

By default the value is set to 3 revisions to be stored. While adding this option with a higher number, the amount of stored revisions will be increased.

ckanext.pages.revisions_force_limit = true

By default is set to False. Needed when the ckanext.pages.revisions_limit number is decresed from the original (e.g. from 5 to 2) and we want to make sure that all Pages after update will have only specified number of Revisions instead of the old setting number. Without it, if Page had previously 5 Revisions, the page will continue to have 5 Revisions as it removes only the last one, so the new number limit will effect only new Pages, while setting this option to true, will force old Pages after update to have the spcific amount of last Revisions.

Extending ckanext-pages schema

This extension defines an IPagesSchema interface that allows other extensions to update the pages schema and add custom fields.

To do so, you can implement the method update_pages_schema in your extension:

import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
from ckanext.pages.interfaces import IPagesSchema

class MyextPlugin(plugins.SingletonPlugin):
    plugins.implements(IPagesSchema)

    #IPagesSchema
    def update_pages_schema(self, schema):
        schema.update({
            'new_field': [
                toolkit.get_validator('not_empty'),
                toolkit.get_validator('boolean_validator')]
            })
        return schema

and also extends ckanext_pages/base_form.html and override the extra_pages_form block to add it to the form:

{% ckan_extends %}

{% set options = [{'value': True, 'text': _('Yes')}, {'value': False, 'text': _('No')}]%}
{% block extra_pages_form %}
    {{ form.select('new_field', id = 'new_field', label = 'New Field', options=options, selected=data.testing) }}
{% endblock extra_pages_form %}

If you want to override, make sure your extension is added before pages in the ckan.plugins config.

Extending the default CKEditor configuration

The default configuration used by the CKEditor widget is defined in the ckanext/pages/assets/js/ckedit.js file. This configuration can be overriden from your own plugin setting the window.ckan.pages.override_config variable. For example, create the following script in your extension:

```js
this.ckan = this.ckan || {};
this.ckan.pages = this.ckan.pages || {};

$(document).ready(function() {

  window.ckan.pages.override_config = {
      toolbarGroups: [
        //... your custom toolbar
      ],
      extraPlugins: '', // Add extra plugins here (make sure to also load their js/css assets from your plugin)
      // ...

  }

});
```

Configure your plugin assets to serve the script above, and extend the ckanext_pages/base_form.html template to add the asset to the ckanext-pages form page:

```
{% ckan_extends %}

{% asset 'my-plugin/pages-extra-config.js' %}

```

Dependencies

  • lxml (optional, only used for injecting resource views into pages)

Tests

docker exec -u ckan -it ckan-app pytest --ckan-ini=/plugins/ckanext-pages/test.ini /plugins/ckanext-pages/ckanext/pages/tests

License

Released under the GNU Affero General Public License (AGPL) v3.0. See the file LICENSE for details.

History

See the file CHANGELOG.md.

Release files for ckanext-fair3r-pages 0.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ckanext-fair3r-pages 0.7.3
File Size Uploaded
ckanext_fair3r_pages-0.7.3.tar.gz 2.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for ckanext-fair3r-pages 0.7.3
File Interpreter ABI Platform
ckanext_fair3r_pages-0.7.3-py3-none-any.whl Python 3 none any Details

Total release size: 4.8 MB

Release files / ckanext_fair3r_pages-0.7.3.tar.gz

Download URL ckanext_fair3r_pages-0.7.3.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
1a0fefddfd2619685b07da6fb40054fc74072986dbe1fbbc2c89d9d9c33a0a0e
BLAKE2b-256 checksum
How to use checksums
9b6dee62387e63eae9913a98a1fb70a63850cb00d3b768e84c576ac84f431ad4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / ckanext_fair3r_pages-0.7.3-py3-none-any.whl

Download URL ckanext_fair3r_pages-0.7.3-py3-none-any.whl
Size 2.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1db777a515eddd6c12248cacf4ef3e5ee94ed31df1007dcaba22d8c647f36530
BLAKE2b-256 checksum
How to use checksums
070e9c50ed55f987db9f74707585e157209b2642b85f7753ae18777af005f45d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release history Release notifications | RSS feed

This release

0.7.3 This release

2 release files

0.7.2

2 release files

0.6.10

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page