frontends, jp, templates: added XHTMLBox widget:
for jp, the XHTML is rendered for now using markdown.
This commit is contained in:
parent
87871fabca
commit
37ea73b19f
1 changed files with 44 additions and 0 deletions
|
|
@ -27,6 +27,12 @@ from sat.core.log import getLogger
|
|||
log = getLogger(__name__)
|
||||
from sat_frontends.tools import xmlui
|
||||
from functools import partial
|
||||
try:
|
||||
from jinja2 import Markup as safe
|
||||
except ImportError:
|
||||
# Safe marks XHTML values as usable as it.
|
||||
# If jinja2 is not there, we can use a simple lamba
|
||||
safe = lambda x: x
|
||||
|
||||
|
||||
## Widgets ##
|
||||
|
|
@ -136,6 +142,17 @@ class TextBoxWidget(xmlui.TextWidget, InputWidget):
|
|||
type = u"textbox"
|
||||
|
||||
|
||||
class XHTMLBoxWidget(xmlui.XHTMLBoxWidget, InputWidget):
|
||||
type = u"xhtmlbox"
|
||||
|
||||
def __init__(self, xmlui_parent, value, read_only=False):
|
||||
# XXX: XHTMLBoxWidget value must be cleaned (harmful XHTML must be removed)
|
||||
# This is normally done in the backend, the frontends should not need to
|
||||
# worry about it.
|
||||
super(XHTMLBoxWidget, self).__init__(
|
||||
xmlui_parent=xmlui_parent, value=safe(value), read_only=read_only)
|
||||
|
||||
|
||||
class ListWidget(xmlui.ListWidget, OptionsWidget):
|
||||
type = u"list"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue