riklaunim/django-ckeditor — pull request #33 by christianglodt (2014-02-28 07:48:16+00:00)
Title: Add support for external plugin resource declarations.

This commit adds keyword arguments to fields.RichTextField that allow the
overriding of extraPlugins on a per-field basis, and that allow the declaration
of external plugin resources (using CKEDITOR.plugins.addExternal()).

This improves the implementation of CKEditor plugins in django apps,
because they can be hosted and deployed separately from the CKEditor sources.

As an example, here's how to define a custom RichTextField by just currying
the existing one's constructor with the new arguments:

```python
from django.utils.functional import curry

extra_plugins = ['custom_plugin']
external_plugin_resources=[('custom_plugin', '/custom_plugin_base/', 'plugin.js')]
CustomRichTextField = curry(RichTextField, extra_plugins=extra_plugins, external_plugin_resources=external_plugin_resources)
```

The external_plugin_resources kwarg is a list of tuples that contain the same
information as the parameters to CKEDITOR.plugins.addExternal().
You may want to write "reverse('some_view')" for the second parameter.
If that fails due to circular imports, wrap the reverse() call in a
SimpleLazyObject, like this:

```python
from django.utils.functional import SimpleLazyObject
external_plugin_resources=[('custom_plugin', SimpleLazyObject(lambda: reverse('custom_plugin_view', kwargs=...) + 'some_relative_path/'), 'plugin.js')]
```