-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaldryn_config.py
66 lines (56 loc) · 2.32 KB
/
aldryn_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
from aldryn_client import forms
class Form(forms.BaseForm):
style_set = forms.CharField(
'The "styles definition set" to use in the editor',
required=False,
)
content_css = forms.CharField(
'List of CSS files to be used to apply style to editor content',
required=False,
)
def clean(self):
data = super(Form, self).clean()
if data.get('content_css'):
files = data['content_css'].split(',')
data['content_css'] = [item.strip() for item in files if item]
return data
def to_settings(self, data, settings):
# boilerplate must provide /static/js/modules/ckeditor.wysiwyg.js and /static/css/base.css
CKEDITOR_SETTINGS = {
'height': 300,
'language': '{{ language }}',
'toolbar': 'CMS',
'skin': 'moono-lisa',
'extraPlugins': 'cmsplugins',
'toolbar_HTMLField': [
['Undo', 'Redo'],
['cmsplugins', '-', 'ShowBlocks'],
['Format', 'Styles'],
['TextColor', 'BGColor', '-', 'PasteText', 'PasteFromWord'],
['Maximize', ''],
'/',
['Bold', 'Italic', 'Underline', '-', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
['HorizontalRule'],
['Link', 'Unlink'],
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Table'],
['Source'],
['Link', 'Unlink', 'Anchor'],
],
}
# This could fail if aldryn-django-cms has not been configured yet.
boilerplate_name = settings['ALDRYN_BOILERPLATE_NAME']
if data.get('content_css'):
CKEDITOR_SETTINGS['contentsCss'] = data['content_css']
else:
CKEDITOR_SETTINGS['contentsCss'] = ['/static/css/base.css']
if data.get('style_set'):
style_set = data['style_set']
elif boilerplate_name == 'bootstrap3':
style_set = '/static/js/addons/ckeditor.wysiwyg.js'
else:
style_set = ''
CKEDITOR_SETTINGS['stylesSet'] = 'default:{}'.format(style_set)
settings['CKEDITOR_SETTINGS'] = CKEDITOR_SETTINGS
return settings