Added a sample IDatasetForm to show how we can implement a custom form from a plugin.
[ckanext-datagovau.git] / README.rst
1 This CKAN Extension demonstrates some common patterns for customising a CKAN instance.
2
3 It comprises:
4
rgrp 5 * A CKAN Extension "plugin" at ``ckanext/example/plugin.py`` which, when
6 loaded, overrides various settings in the core ``ini``-file to provide:
7
rgrp 8 * A path to local customisations of the core templates and stylesheets
9 * A "stream filter" that replaces arbitrary strings in rendered templates
10 * A "route" to override and extend the default behaviour of a core CKAN page
11
12 * A custom Pylons controller for overriding some core CKAN behaviour
13
14 * A custom Package edit form
15
Ian Murray 16 * Some simple template customisations
17
rgrp 18 Installation
19 ============
Seb Bacon 20
21 To install this package, from your CKAN virtualenv, run the following from your CKAN base folder (e.g. ``pyenv/``)::
22
23 pip install -e git+https://github.com/okfn/ckanext-example#egg=ckanext-example
24
rgrp 25 Then activate it by setting ``ckan.plugins = example`` in your main ``ini``-file.
Seb Bacon 26
rgrp 27
Seb Bacon 28 Orientation
29 ===========
30
31 * Examine the source code, starting with ``ckanext/example/plugin.py``
32
rgrp 33 * To understand the nuts and bolts of this file, which is a CKAN
Seb Bacon 34 *Extension*, read in conjunction with the "Extension
35 documentation":http://packages.python.org/ckan/plugins.html
36
David Read 37 * One thing the extension does is set the values of
Seb Bacon 38 ``extra_public_paths`` and ``extra_template_paths`` in the CKAN
39 config, which are "documented
40 here":http://packages.python.org/ckan/configuration.html#extra-template-paths
41
David Read 42 * These are set to point at directories within
Seb Bacon 43 `ckanext/example/theme/`` (in this package). Here, we override
44 the home page, provide some extra style with an ``extra.css``, and
David Read 45 customise the navigation and header of the main template in the file ``layout.html``.
46
47 The latter file is a great place to make global theme alterations.
48 It uses the _layout template_ pattern "described in the Genshi
Seb Bacon 49 documentation":http://genshi.edgewall.org/wiki/GenshiTutorial#AddingaLayoutTemplate.
50 This allows you to use Xpath selectors to override snippets of HTML
51 globally.
52
53 * The custom package edit form at ``package_form.py`` follows the
54 conventions in the "main CKAN
55 documentation":http://packages.python.org/ckan/forms.html
Ian Murray 56