equal
deleted
inserted
replaced
2 """user interface libraries |
2 """user interface libraries |
3 |
3 |
4 contains some functions designed to help implementation of cubicweb user interface |
4 contains some functions designed to help implementation of cubicweb user interface |
5 |
5 |
6 :organization: Logilab |
6 :organization: Logilab |
7 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
7 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
9 """ |
9 """ |
10 __docformat__ = "restructuredtext en" |
10 __docformat__ = "restructuredtext en" |
11 |
11 |
12 import csv |
12 import csv |
210 return text[:length] + u'...' |
210 return text[:length] + u'...' |
211 |
211 |
212 |
212 |
213 |
213 |
214 # HTML generation helper functions ############################################ |
214 # HTML generation helper functions ############################################ |
|
215 |
|
216 def simple_sgml_tag(tag, content=None, **attrs): |
|
217 """generation of a simple sgml tag (eg without children tags) easier |
|
218 |
|
219 content and attributes will be escaped |
|
220 """ |
|
221 value = u'<%s' % tag |
|
222 if attrs: |
|
223 value += u' ' + u' '.join(u'%s="%s"' % (attr, html_escape(unicode(value))) |
|
224 for attr, value in attrs.items()) |
|
225 if content: |
|
226 value += u'>%s</%s>' % (html_escape(unicode(content)), tag) |
|
227 else: |
|
228 value += u'/>' |
|
229 return value |
215 |
230 |
216 def tooltipize(text, tooltip, url=None): |
231 def tooltipize(text, tooltip, url=None): |
217 """make an HTML tooltip""" |
232 """make an HTML tooltip""" |
218 url = url or '#' |
233 url = url or '#' |
219 return u'<a href="%s" title="%s">%s</a>' % (url, tooltip, text) |
234 return u'<a href="%s" title="%s">%s</a>' % (url, tooltip, text) |