Skip to content

Commit

Permalink
Updated NewmanRichTextAreaWidget based on django-markup widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
whit committed Apr 19, 2009
1 parent 29d8990 commit a751250
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions ella/newman/options.py
Expand Up @@ -56,6 +56,7 @@ def formfield_for_dbfield_factory(cls, db_field, **kwargs):
'field_name': db_field.name,
'instance': custom_params.get('instance', None),
'model': custom_params.get('model'),
'widget': widgets.NewmanRichTextAreaWidget
})
rich_text_field = RichTextField(**kwargs)
if css_class:
Expand Down
34 changes: 34 additions & 0 deletions ella/newman/widgets.py
Expand Up @@ -5,6 +5,18 @@
from django.contrib.admin import widgets
from django.utils.text import truncate_words
from ella.ellaadmin.utils import admin_url
from djangomarkup.widgets import RichTextAreaWidget

MARKITUP_SET = getattr(settings, 'DEFAULT_MARKUP', 'default')
MEDIA_PREFIX = getattr(settings, 'NEWMAN_MEDIA_PREFIX', settings.ADMIN_MEDIA_PREFIX)

# Rich text editor
JS_MARKITUP = 'js/markitup/jquery.markitup.js'
JS_MARKITUP_SET = 'js/markitup/sets/%s/set.js' % MARKITUP_SET
JS_EDITOR = 'js/editor.js'
CSS_MARKITUP = 'js/markitup/skins/markitup/style.css'
CSS_MARKITUP_SET = 'js/markitup/sets/%s/style.css' % MARKITUP_SET
CLASS_RICHTEXTAREA = 'rich_text_area'

# Generic suggester media files
JS_GENERIC_SUGGEST = 'js/generic.suggest.js'
Expand All @@ -23,6 +35,28 @@
JS_FLASH_IMAGE_INPUT = 'js/flash_image.js'
SWF_FLASH_IMAGE_INPUT = 'swf/PhotoUploader.swf'

class NewmanRichTextAreaWidget(RichTextAreaWidget):
"""
Newman's implementation of markup, based on markitup editor.
"""
class Media:
js = (
MEDIA_PREFIX + JS_MARKITUP,
MEDIA_PREFIX + JS_MARKITUP_SET,
MEDIA_PREFIX + JS_EDITOR,
)
css = {
'screen': (
MEDIA_PREFIX + CSS_MARKITUP,
MEDIA_PREFIX + CSS_MARKITUP_SET,
),
}

def __init__(self, attrs={}):
css_class = CLASS_RICHTEXTAREA
super(RichTextAreaWidget, self).__init__(attrs={'class': css_class})


class FlashImageWidget(widgets.AdminFileWidget):
class Media:
js = (
Expand Down

0 comments on commit a751250

Please sign in to comment.