Mercurial > libervia-backend
comparison sat/tools/common/template_xmlui.py @ 2783:442ab697f831
frontends, jp, templates: added XHTMLBox widget:
for jp, the XHTML is rendered for now using markdown.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Jan 2019 11:39:02 +0100 |
parents | 003b8b4b56a7 |
children | ab2696e34d29 |
comparison
equal
deleted
inserted
replaced
2782:b17e6fa1e607 | 2783:442ab697f831 |
---|---|
25 from sat.core.log import getLogger | 25 from sat.core.log import getLogger |
26 | 26 |
27 log = getLogger(__name__) | 27 log = getLogger(__name__) |
28 from sat_frontends.tools import xmlui | 28 from sat_frontends.tools import xmlui |
29 from functools import partial | 29 from functools import partial |
30 try: | |
31 from jinja2 import Markup as safe | |
32 except ImportError: | |
33 # Safe marks XHTML values as usable as it. | |
34 # If jinja2 is not there, we can use a simple lamba | |
35 safe = lambda x: x | |
30 | 36 |
31 | 37 |
32 ## Widgets ## | 38 ## Widgets ## |
33 | 39 |
34 | 40 |
134 | 140 |
135 class TextBoxWidget(xmlui.TextWidget, InputWidget): | 141 class TextBoxWidget(xmlui.TextWidget, InputWidget): |
136 type = u"textbox" | 142 type = u"textbox" |
137 | 143 |
138 | 144 |
145 class XHTMLBoxWidget(xmlui.XHTMLBoxWidget, InputWidget): | |
146 type = u"xhtmlbox" | |
147 | |
148 def __init__(self, xmlui_parent, value, read_only=False): | |
149 # XXX: XHTMLBoxWidget value must be cleaned (harmful XHTML must be removed) | |
150 # This is normally done in the backend, the frontends should not need to | |
151 # worry about it. | |
152 super(XHTMLBoxWidget, self).__init__( | |
153 xmlui_parent=xmlui_parent, value=safe(value), read_only=read_only) | |
154 | |
155 | |
139 class ListWidget(xmlui.ListWidget, OptionsWidget): | 156 class ListWidget(xmlui.ListWidget, OptionsWidget): |
140 type = u"list" | 157 type = u"list" |
141 | 158 |
142 | 159 |
143 ## Containers ## | 160 ## Containers ## |