Skip to main content
# django-resckeditor

This is a django app which provides and infrastructure you can use to include custom contents of other apps directly inside ckeditor.

It requires [django-ckeditor](https://github.com/django-ckeditor/django-ckeditor)

It defines a custom CKEDITOR plugin which implements two dialog tabs: the first to select the resource, and the second to dynamically set options.

**Full documentation**: [https://django-resckeditor.readthedocs.io/en/latest/](https://django-resckeditor.readthedocs.io/en/latest/)

![Screenshot](docs/images/list.png)
![Screenshot](docs/images/options.png)

## Getting Started

Install django-resckeditor:

$ pip install django-resckeditor

Add resckeditor to your installed apps:

INSTALLED_APPS = (
# ...
'ckeditor',
'ckeditor_uploader',
'resckeditor',
# ...
)

add the urls in your core application:

urlpatterns = [
# ...
url(r'^resckeditor/', include('resckeditor.urls', namespace='resckeditor')),
]

**N.B.** do not change the **resckeditor** path, since it is hardcoded in the js code.

Add the resource and ajax plugins to your ckeditor instance:

CKEDITOR_CONFIGS = {
'default': {
'skin': 'moono',
'toolbar_Full': [
// ..
['Res'/*, ...*/],
// ..
],
'toolbar': 'Full',
// ...
'extraPlugins': 'ajax,resource',
}
}

Define functions export resources for ckeditor, so for example in your settings:

RESCKEDITOR_CONFIG = {
'RESOURCES': [
{
'list': 'path.to.module.func.defining.resources',
'output': 'path.to.module.func.returning.html',
'label': 'My group of widgets'
},
]
}


The `list` function is invoked without arguments and should return a dictionary defining all the available resources
(i.e. all the news we want to export) and the available options:

def my_list_function():
res = []
for n in News.objects.published():
res.append({
'label': n.title,
'id': n.id
})
return {
'resources': res,
'options': [
{
'type': 'text',
'name': 'news-dialog-options-section-title',
'label': 'Last News',
'default': ''
},
{
'type': 'checkbox',
'name': 'news-dialog-options-show-title',
'label': 'Show title',
'default': True
},
{
'type': 'number',
'name': 'news-dialog-options-num-chars',
'label': 'Number of chars',
'default': 50
},
{
'type': 'select',
'name': 'news-dialog-options-layout',
'label': 'Layout',
'data': [
{'label': 'one row', 'value': 'row'},
{'label': 'two columns', 'value': 'col-2'},
{'label': 'three columns', 'value': 'col-3'},
{'label': 'four columns', 'value': 'col-4'},
]
}
]

}

The `output` function will receive the id of the resource selected and a dictionary containing the provided options.
It should return the html output of the resource.

def my_output_function(id, options):
n = News.objects.get(pk=id)
return '<h1>%s</h1>' % n.title

## Supported options

Currently only 4 types of options are supported: checkbox, text, number and select, but should be sufficient for almost all use cases.
The syntax and required properties are the one you may se in the example above (text has the same props as number).


Metadata

Release files for django-resckeditor 1.0.0

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

Source distribution (sdist)

Source distribution for django-resckeditor 1.0.0
File Size Uploaded
django-resckeditor-1.0.0.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-resckeditor 1.0.0
File Interpreter ABI Platform
django_resckeditor-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.9 kB

Release files / django-resckeditor-1.0.0.tar.gz

Download URL django-resckeditor-1.0.0.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e8030034b6ad49724fa918adb0de125cb5a266b81d9b16bed8ff27dd8a44cf26
BLAKE2b-256 checksum
How to use checksums
89ffffab60d13068c1f4953f98f679151dde0d7d6989fd007b19350fad783ad0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.7

Release files / django_resckeditor-1.0.0-py3-none-any.whl

Download URL django_resckeditor-1.0.0-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee770ce9b2f0ff3f16c0c0971041fe1a72d417a5a5f84fd3f8984c065a253642
BLAKE2b-256 checksum
How to use checksums
462146c53a71cb3182b17c55575c11ab4a01412c9a3740855613ed9af3c999f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.0.0 This release

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