Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
web2py_ckeditor (2014 fork, v1.0)
===============
V1.2.1 Permit lazy_tables = True
Updated ckeditor to 4.8 March 2018
Add ckeditor configuration file to simplify javascript in python module

v1.2 Updated to ckeditor 4.5.7 Feb 2016.

Expand Down Expand Up @@ -74,6 +77,12 @@ To solve: ...use the following code in your model before ckeditor.define_tables(
ckeditor.settings.url_upload = URL(request.app, 'plugin_ckeditor', 'upload', extension='html')
ckeditor.settings.url_browse = URL(request.app, 'plugin_ckeditor', 'browse', extension='html')

##### Tips for V1.2.1 (From Jonathan Clark)

- The plugin uses the standard web2py download function found in `controllers/default.py` for displaying images. Don't do what I did and delete it.
- ckeditor provides a toolbar configuration tool in
`static/plugin_ckeditor/samples` which you can use to create a config.js file. You can adjust which config file is loaded via the customConfig parameter in the load function in `modules/plugin_ckeditor.py`. There is a sample one called `ckeditor_config.js` in the static folder.


=======
v 0.4 Updated to ckeditor 4.4.3 July 15 2014
Expand Down Expand Up @@ -148,3 +157,4 @@ Leonel Câmara: "You use the XML helper. For instance, let's suppose I have a t
{{=XML(page.body, sanitize=False)}}

If you can trust the input "sanitize=False" is a good idea (for instance if it can only be changed in the backoffice by members of the administration), otherwise remove the sanitize=False."

2 changes: 1 addition & 1 deletion create_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# modules/plugin_ckeditor.py
# static/plugin_ckeditor
# views/plugin_ckeditor
tar czvf web2py.plugin.ckeditor.w2p --exclude='*.sh' controllers/plugin_ckeditor.py modules/plugin_ckeditor.py static/plugin_ckeditor views/plugin_ckeditor
tar czvf web2py.plugin.ckeditor.w2p --exclude='*.sh' controllers/plugin_ckeditor.py modules/plugin_ckeditor.py static/plugin_ckeditor views/plugin_ckeditor static/ckeditor_config.js
4 changes: 3 additions & 1 deletion models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
db = DAL('sqlite://storage.sqlite',pool_size=1,
check_reserved=['all'],
lazy_tables=True)
else:
## connect to Google BigTable (optional 'google:datastore://namespace')
db = DAL('google:datastore')
Expand Down
18 changes: 5 additions & 13 deletions modules/plugin_ckeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def define_tables(self, migrate=True, fake_migrate=False):
"""
upload_name = self.settings.table_upload_name

self.settings.table_upload = self.db.define_table(upload_name,
self.db.define_table(upload_name,
Field('title', length=255),
Field('filename', length=255),
Field('flength', 'integer'),
Expand All @@ -62,6 +62,7 @@ def define_tables(self, migrate=True, fake_migrate=False):
fake_migrate = fake_migrate,
format = '%(title)s'
)
self.settings.table_upload = self.db[upload_name]


def widget(self, field, value, **attributes):
Expand Down Expand Up @@ -146,6 +147,7 @@ def load(self, selector=None, use_caching=True):
upload_url = self.settings.url_upload
browse_url = self.settings.url_browse
ckeditor_js = URL('static', 'plugin_ckeditor/ckeditor.js')
ckeditor_config = URL('static', 'ckeditor_config.js')
jquery_js = URL('static', 'plugin_ckeditor/adapters/jquery.js')

contents_css = "['%s']" % URL('static', 'plugin_ckeditor/contents.css')
Expand All @@ -172,28 +174,18 @@ def load(self, selector=None, use_caching=True):
<script type="text/javascript">
function ckeditor_config() {
return {
customConfig: '%(ckeditor_config)s',
contentsCss: %(contents_css)s,
filebrowserUploadUrl: '%(upload_url)s',
filebrowserBrowseUrl: '%(browse_url)s',
/*
toolbar: [
{name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
{name: 'editing', items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt']},
{name: 'links', items: ['Link', 'Unlink', 'Anchor']},
{name: 'insert', items: ['Image', 'Flash', 'Table', 'SpecialChar']},
{name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'Source']},
'/',
{name: 'styles', items: ['Format', 'Font', 'FontSize']},
{name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat']},
{name: 'paragraph', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']},
],*/
scayt_autoStartup: %(scayt)s,
}
}
%(immediate)s
</script>
""" % dict(
ckeditor_js = ckeditor_js,
ckeditor_config = ckeditor_config,
jquery_js = jquery_js,

contents_css = contents_css,
Expand Down
21 changes: 21 additions & 0 deletions static/ckeditor_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CKEDITOR.editorConfig = function( config ) {
config.toolbarGroups = [
{ name: 'styles', groups: [ 'styles' ] },
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
{ name: 'insert', groups: [ 'insert' ] },
'/',
{ name: 'links', groups: [ 'links' ] },
{ name: 'forms', groups: [ 'forms' ] },
{ name: 'tools', groups: [ 'tools' ] },
{ name: 'others', groups: [ 'others' ] },
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'colors', groups: [ 'colors' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
{ name: 'about', groups: [ 'about' ] }
];

config.removeButtons = 'Subscript,Superscript,Cut,Anchor,Maximize,Strike,RemoveFormat,About,Scayt,Styles';

};
Loading