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