Skip to main content

CKAN Python PyPI License

ckanext-pages

Adds simple content pages to CKAN - an About page, a guide, a licence, news in a blog - written in Markdown or with a visual editor, without touching any template. Pages can sit in the site's main menu, or belong to an organization or a group and appear as one of its tabs.

Fork of ckan/ckanext-pages, maintained by Phen-ICS (CNRS/IGBMC) for the FAIR3R catalogue. Published on PyPI as ckanext-fair3r-pages; the plugin is still called pages.

What this fork changes

  • One page order everywhere, set in the page form with two choices:

    • Position: where among the menu entries the page goes - 0 before the first entry, n after the n-th.
    • Rank (1-9): its order among the pages sharing that position, ties broken by title.

    It works the same for the site menu and for an organization's or group's tabs. Stored in the existing column: no migration.

  • Organization and group pages become tabs: a page with an order appears in that organization's or group's own menu (next to Datasets, Members, Activity Stream...), highlighted when open. "Not in menu" keeps it in the Pages list only. A private page is shown to members only.

  • CKAN 2.12 fixes: the Pages tab of an organization's activity stream no longer crashes, group/organization menu links point to the right endpoints, the page delete form has its CSRF token.

  • French translation, and CI that tests, builds and publishes to PyPI on every merge.

Installation

  1. Install the package in CKAN's virtualenv:

    pip install ckanext-fair3r-pages
    
  2. Enable the plugin in ckan.ini. Put it before any plugin that overrides the same templates (FAIR3R puts it before fair3r):

    ckan.plugins = ... pages
    
  3. Create its tables:

    ckan -c /path/to/ckan.ini db upgrade -p pages
    
  4. Restart CKAN. Logged-in users get Pages and Blog icons in the account bar; sysadmins create site pages and blog posts there, and organization/group admins their own pages from its Pages tab.

Configuration

All optional.

Setting Default Meaning
ckanext.pages.organization false Allow pages for organizations (shown as their tabs)
ckanext.pages.group false Allow pages for groups
ckanext.pages.editor Markdown ckeditor or medium for a visual editor instead of Markdown
ckanext.pages.allow_html false Render HTML as well as Markdown. Only if you trust everyone who edits pages
ckanext.pages.about_menu true Keep CKAN's own About entry in the main menu
ckanext.pages.group_menu true Keep the Groups entry
ckanext.pages.organization_menu true Keep the Organizations entry
ckanext.pages.revisions_limit 3 Revisions kept per page (0: all)
ckanext.pages.revisions_force_limit false Also trim pages that already have more revisions than the limit (after lowering it)
ckanext.pages.form ckanext_pages/base_form.html Template of the page form, to replace it with your own

Extending

Extra fields on pages: IPagesSchema

Add fields to the page schema from your plugin (listed before pages in ckan.plugins):

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


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

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

and show them in the form by extending ckanext_pages/base_form.html:

{% ckan_extends %}

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

Your own CKEditor toolbar

The default CKEditor setup is in assets/js/ckedit.js. Override it from a script of your plugin, loaded on the page form:

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

$(document).ready(function () {
  window.ckan.pages.override_config = {
    toolbarGroups: [/* your toolbar */],
    extraPlugins: "",  // and load their assets from your plugin
  };
});
{% ckan_extends %}
{% asset 'my-plugin/pages-extra-config.js' %}

Tests

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

Always pass --ckan-ini: the fixtures empty the database they run against, and refuse to run unless its name contains test.

Credits and license

Originally written by the CKAN community. Released under the GNU Affero General Public License v3.0 - see LICENSE. History in CHANGELOG.md.

Optional dependency: lxml, only used to embed resource views in pages.

Metadata

Release files for ckanext-fair3r-pages 0.7.9

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.9
File Size Uploaded Provenance Actions
ckanext_fair3r_pages-0.7.9.tar.gz 1.7 MB Without provenance Details for ckanext_fair3r_pages-0.7.9.tar.gz

Built distribution (wheel)

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

Total release size: 4.1 MB

Release files / ckanext_fair3r_pages-0.7.9.tar.gz

Download URL ckanext_fair3r_pages-0.7.9.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
430602bcaaaa5618102cf5e40fe0fd89b0deea83962da274c04ce90ef4bc4ec2
BLAKE2b-256 checksum
How to use checksums
4a9cdbf170af07b88238c071b9fdb192565aae0215f23f4d2401947345427410
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

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

Download URL ckanext_fair3r_pages-0.7.9-py3-none-any.whl
Size 2.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
e53f1db34fa47ec9b512180c222bb93df34fb44c2cf2b5772f5e7c92327e41cf
BLAKE2b-256 checksum
How to use checksums
3264f1f24691f3430eedcbd3054f09bc11e2384e9d5b9f910f59a3962ad4a186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.22

Security for ckanext-fair3r-pages 0.7.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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