author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Thu, 23 Jul 2009 15:28:41 +0200 | |
changeset 2456 | aa25d6b244c8 |
parent 2312 | af4d8f75c5db |
child 2468 | 93853b6f3bad |
permissions | -rw-r--r-- |
0 | 1 |
"""Set of HTML generic base views: |
2 |
||
3 |
* noresult, final |
|
4 |
* primary, sidebox |
|
5 |
* secondary, oneline, incontext, outofcontext, text |
|
6 |
* list |
|
7 |
||
8 |
||
9 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1882
diff
changeset
|
10 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 11 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1882
diff
changeset
|
12 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 13 |
""" |
964
a711c7c185d1
gargl, this shouldn't be there in case we're running py 2.4
sylvain.thenault@logilab.fr
parents:
958
diff
changeset
|
14 |
#from __future__ import with_statement |
0 | 15 |
__docformat__ = "restructuredtext en" |
1882 | 16 |
_ = unicode |
0 | 17 |
|
18 |
from rql import nodes |
|
19 |
||
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
20 |
from logilab.mtconverter import TransformError, xml_escape, xml_escape |
0 | 21 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
1477
diff
changeset
|
22 |
from cubicweb import NoSelectableObject |
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
23 |
from cubicweb.selectors import yes, empty_rset |
756 | 24 |
from cubicweb.view import EntityView, AnyRsetView, View |
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
25 |
from cubicweb.common.uilib import cut, printable_value |
0 | 26 |
|
27 |
||
28 |
class NullView(AnyRsetView): |
|
29 |
"""default view when no result has been found""" |
|
30 |
id = 'null' |
|
758
0c0dfd33a76d
instantiate selectors wherever needed
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
742
diff
changeset
|
31 |
__select__ = yes() |
0 | 32 |
def call(self, **kwargs): |
33 |
pass |
|
34 |
cell_call = call |
|
35 |
||
36 |
||
632 | 37 |
class NoResultView(View): |
0 | 38 |
"""default view when no result has been found""" |
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
647
diff
changeset
|
39 |
__select__ = empty_rset() |
0 | 40 |
id = 'noresult' |
1451 | 41 |
|
0 | 42 |
def call(self, **kwargs): |
43 |
self.w(u'<div class="searchMessage"><strong>%s</strong></div>\n' |
|
44 |
% self.req._('No result matching query')) |
|
45 |
||
46 |
||
47 |
class FinalView(AnyRsetView): |
|
48 |
"""display values without any transformation (i.e. get a number for |
|
1451 | 49 |
entities) |
0 | 50 |
""" |
51 |
id = 'final' |
|
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
52 |
# record generated i18n catalog messages |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
53 |
_('%d years') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
54 |
_('%d months') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
55 |
_('%d weeks') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
56 |
_('%d days') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
57 |
_('%d hours') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
58 |
_('%d minutes') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
59 |
_('%d seconds') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
60 |
_('%d years') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
61 |
_('%d months') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
62 |
_('%d weeks') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
63 |
_('%d days') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
64 |
_('%d hours') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
65 |
_('%d minutes') |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
66 |
_('%d seconds') |
1451 | 67 |
|
573
9c8fd72ba6c1
try to get raw text values in rset csv view
sylvain.thenault@logilab.fr
parents:
570
diff
changeset
|
68 |
def cell_call(self, row, col, props=None, displaytime=False, format='text/html'): |
0 | 69 |
etype = self.rset.description[row][col] |
70 |
value = self.rset.rows[row][col] |
|
1760
6b97d286eb5a
[reledit] relation edition : cleanup a bit #343123
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1712
diff
changeset
|
71 |
|
0 | 72 |
if etype == 'String': |
73 |
entity, rtype = self.rset.related_entity(row, col) |
|
74 |
if entity is not None: |
|
75 |
# yes ! |
|
573
9c8fd72ba6c1
try to get raw text values in rset csv view
sylvain.thenault@logilab.fr
parents:
570
diff
changeset
|
76 |
self.w(entity.printable_value(rtype, value, format=format)) |
0 | 77 |
return |
78 |
if etype in ('Time', 'Interval'): |
|
1451 | 79 |
# value is DateTimeDelta but we have no idea about what is the |
0 | 80 |
# reference date here, so we can only approximate years and months |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
81 |
if format == 'text/html': |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
82 |
space = ' ' |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
83 |
else: |
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
84 |
space = ' ' |
0 | 85 |
if value.days > 730: # 2 years |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
86 |
self.w(self.req.__('%%d%syears' % space) % (value.days // 365)) |
0 | 87 |
elif value.days > 60: # 2 months |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
88 |
self.w(self.req.__('%%d%smonths' % space) % (value.days // 30)) |
0 | 89 |
elif value.days > 14: # 2 weeks |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
90 |
self.w(self.req.__('%%d%sweeks' % space) % (value.days // 7)) |
0 | 91 |
elif value.days > 2: |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
92 |
self.w(self.req.__('%%d%sdays' % space) % int(value.days)) |
1712
32ab85031814
fix a bug deltatime hasn't a hours or minutes attributes
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1680
diff
changeset
|
93 |
elif value.seconds > 3600: |
32ab85031814
fix a bug deltatime hasn't a hours or minutes attributes
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1680
diff
changeset
|
94 |
self.w(self.req.__('%%d%shours' % space) % int(value.seconds // 3600)) |
32ab85031814
fix a bug deltatime hasn't a hours or minutes attributes
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1680
diff
changeset
|
95 |
elif value.seconds >= 120: |
32ab85031814
fix a bug deltatime hasn't a hours or minutes attributes
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1680
diff
changeset
|
96 |
self.w(self.req.__('%%d%sminutes' % space) % int(value.seconds // 60)) |
0 | 97 |
else: |
978
536c748e7b3f
use non-breakable space in time display
sylvain.thenault@logilab.fr
parents:
964
diff
changeset
|
98 |
self.w(self.req.__('%%d%sseconds' % space) % int(value.seconds)) |
0 | 99 |
return |
100 |
self.wdata(printable_value(self.req, etype, value, props, displaytime=displaytime)) |
|
101 |
||
102 |
||
103 |
class SecondaryView(EntityView): |
|
104 |
id = 'secondary' |
|
105 |
title = _('secondary') |
|
1451 | 106 |
|
0 | 107 |
def cell_call(self, row, col): |
108 |
"""the secondary view for an entity |
|
109 |
secondary = icon + view(oneline) |
|
110 |
""" |
|
111 |
entity = self.entity(row, col) |
|
112 |
self.w(u' ') |
|
113 |
self.wview('oneline', self.rset, row=row, col=col) |
|
114 |
||
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
115 |
|
0 | 116 |
class OneLineView(EntityView): |
117 |
id = 'oneline' |
|
1451 | 118 |
title = _('oneline') |
0 | 119 |
|
120 |
def cell_call(self, row, col): |
|
121 |
"""the one line view for an entity: linked text view |
|
122 |
""" |
|
123 |
entity = self.entity(row, col) |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
124 |
self.w(u'<a href="%s">' % xml_escape(entity.absolute_url())) |
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
125 |
self.w(xml_escape(self.view('text', self.rset, row=row, col=col))) |
0 | 126 |
self.w(u'</a>') |
127 |
||
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
128 |
|
0 | 129 |
class TextView(EntityView): |
532
ce3e94cbb074
specify content type for text views
sylvain.thenault@logilab.fr
parents:
531
diff
changeset
|
130 |
"""the simplest text view for an entity""" |
0 | 131 |
id = 'text' |
132 |
title = _('text') |
|
532
ce3e94cbb074
specify content type for text views
sylvain.thenault@logilab.fr
parents:
531
diff
changeset
|
133 |
content_type = 'text/plain' |
647
49bb57a9606b
some selectors update + drop EntityRelationView (only used by jpl)
sylvain.thenault@logilab.fr
parents:
632
diff
changeset
|
134 |
|
0 | 135 |
def call(self, **kwargs): |
136 |
"""the view is called for an entire result set, by default loop |
|
137 |
other rows of the result set and call the same view on the |
|
138 |
particular row |
|
139 |
||
140 |
Views applicable on None result sets have to override this method |
|
141 |
""" |
|
142 |
rset = self.rset |
|
143 |
if rset is None: |
|
144 |
raise NotImplementedError, self |
|
145 |
for i in xrange(len(rset)): |
|
146 |
self.wview(self.id, rset, row=i, **kwargs) |
|
147 |
if len(rset) > 1: |
|
148 |
self.w(u"\n") |
|
1451 | 149 |
|
0 | 150 |
def cell_call(self, row, col=0, **kwargs): |
151 |
entity = self.entity(row, col) |
|
152 |
self.w(cut(entity.dc_title(), |
|
153 |
self.req.property_value('navigation.short-line-size'))) |
|
154 |
||
137
7e45cf48c2f1
don't display additional owners in metadata, this is confusing
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
155 |
|
0 | 156 |
class MetaDataView(EntityView): |
157 |
"""paragraph view of some metadata""" |
|
158 |
id = 'metadata' |
|
159 |
show_eid = True |
|
1451 | 160 |
|
0 | 161 |
def cell_call(self, row, col): |
162 |
_ = self.req._ |
|
163 |
entity = self.entity(row, col) |
|
164 |
self.w(u'<div class="metadata">') |
|
165 |
if self.show_eid: |
|
166 |
self.w(u'#%s - ' % entity.eid) |
|
167 |
if entity.modification_date != entity.creation_date: |
|
168 |
self.w(u'<span>%s</span> ' % _('latest update on')) |
|
1552 | 169 |
self.w(u'<span class="value">%s</span>, ' |
0 | 170 |
% self.format_date(entity.modification_date)) |
171 |
# entities from external source may not have a creation date (eg ldap) |
|
1451 | 172 |
if entity.creation_date: |
0 | 173 |
self.w(u'<span>%s</span> ' % _('created on')) |
174 |
self.w(u'<span class="value">%s</span>' |
|
175 |
% self.format_date(entity.creation_date)) |
|
176 |
if entity.creator: |
|
1456
998ff29c3390
related entitied must be computed in _preinit_side_related
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
1431
diff
changeset
|
177 |
self.w(u' <span>%s</span> ' % _('by')) |
0 | 178 |
self.w(u'<span class="value">%s</span>' % entity.creator.name()) |
179 |
self.w(u'</div>') |
|
180 |
||
181 |
||
182 |
# new default views for finner control in general views , to use instead of |
|
183 |
# oneline / secondary |
|
184 |
||
185 |
class InContextTextView(TextView): |
|
186 |
id = 'textincontext' |
|
187 |
title = None # not listed as a possible view |
|
188 |
def cell_call(self, row, col): |
|
189 |
entity = self.entity(row, col) |
|
190 |
self.w(entity.dc_title()) |
|
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
191 |
|
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
192 |
|
0 | 193 |
class OutOfContextTextView(InContextTextView): |
194 |
id = 'textoutofcontext' |
|
195 |
||
196 |
def cell_call(self, row, col): |
|
197 |
entity = self.entity(row, col) |
|
198 |
self.w(entity.dc_long_title()) |
|
199 |
||
200 |
||
201 |
class InContextView(EntityView): |
|
202 |
id = 'incontext' |
|
203 |
||
204 |
def cell_call(self, row, col): |
|
205 |
entity = self.entity(row, col) |
|
206 |
desc = cut(entity.dc_description(), 50) |
|
1882 | 207 |
self.w(u'<a href="%s" title="%s">' % ( |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
208 |
xml_escape(entity.absolute_url()), xml_escape(desc))) |
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
209 |
self.w(xml_escape(self.view('textincontext', self.rset, |
1882 | 210 |
row=row, col=col))) |
0 | 211 |
self.w(u'</a>') |
212 |
||
1451 | 213 |
|
0 | 214 |
class OutOfContextView(EntityView): |
215 |
id = 'outofcontext' |
|
216 |
||
217 |
def cell_call(self, row, col): |
|
1882 | 218 |
entity = self.entity(row, col) |
219 |
desc = cut(entity.dc_description(), 50) |
|
220 |
self.w(u'<a href="%s" title="%s">' % ( |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
221 |
xml_escape(entity.absolute_url()), xml_escape(desc))) |
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
222 |
self.w(xml_escape(self.view('textoutofcontext', self.rset, |
1882 | 223 |
row=row, col=col))) |
0 | 224 |
self.w(u'</a>') |
225 |
||
226 |
||
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
227 |
# list views ################################################################## |
0 | 228 |
|
229 |
class ListView(EntityView): |
|
230 |
id = 'list' |
|
231 |
title = _('list') |
|
232 |
item_vid = 'listitem' |
|
1451 | 233 |
|
0 | 234 |
def call(self, klass=None, title=None, subvid=None, listid=None, **kwargs): |
235 |
"""display a list of entities by calling their <item_vid> view |
|
1451 | 236 |
|
0 | 237 |
:param listid: the DOM id to use for the root element |
238 |
""" |
|
239 |
if subvid is None and 'subvid' in self.req.form: |
|
240 |
subvid = self.req.form.pop('subvid') # consume it |
|
241 |
if listid: |
|
242 |
listid = u' id="%s"' % listid |
|
243 |
else: |
|
244 |
listid = u'' |
|
245 |
if title: |
|
246 |
self.w(u'<div%s class="%s"><h4>%s</h4>\n' % (listid, klass or 'section', title)) |
|
247 |
self.w(u'<ul>\n') |
|
248 |
else: |
|
249 |
self.w(u'<ul%s class="%s">\n' % (listid, klass or 'section')) |
|
250 |
for i in xrange(self.rset.rowcount): |
|
251 |
self.cell_call(row=i, col=0, vid=subvid, **kwargs) |
|
252 |
self.w(u'</ul>\n') |
|
253 |
if title: |
|
254 |
self.w(u'</div>\n') |
|
255 |
||
256 |
def cell_call(self, row, col=0, vid=None, **kwargs): |
|
257 |
self.w(u'<li>') |
|
258 |
self.wview(self.item_vid, self.rset, row=row, col=col, vid=vid, **kwargs) |
|
259 |
self.w(u'</li>\n') |
|
260 |
||
261 |
def url(self): |
|
262 |
"""overrides url method so that by default, the view list is called |
|
263 |
with sorted entities |
|
264 |
""" |
|
265 |
coltypes = self.rset.column_types(0) |
|
266 |
# don't want to generate the rql if there is some restriction on |
|
267 |
# something else than the entity type |
|
268 |
if len(coltypes) == 1: |
|
269 |
# XXX norestriction is not correct here. For instance, in cases like |
|
270 |
# Any P,N WHERE P is Project, P name N |
|
271 |
# norestriction should equal True |
|
272 |
restr = self.rset.syntax_tree().children[0].where |
|
273 |
norestriction = (isinstance(restr, nodes.Relation) and |
|
274 |
restr.is_types_restriction()) |
|
275 |
if norestriction: |
|
276 |
etype = iter(coltypes).next() |
|
277 |
return self.build_url(etype.lower(), vid=self.id) |
|
278 |
if len(self.rset) == 1: |
|
279 |
entity = self.rset.get_entity(0, 0) |
|
280 |
return self.build_url(entity.rest_path(), vid=self.id) |
|
281 |
return self.build_url(rql=self.rset.printable_rql(), vid=self.id) |
|
282 |
||
1451 | 283 |
|
0 | 284 |
class ListItemView(EntityView): |
285 |
id = 'listitem' |
|
1451 | 286 |
|
0 | 287 |
@property |
288 |
def redirect_vid(self): |
|
289 |
if self.req.search_state[0] == 'normal': |
|
290 |
return 'outofcontext' |
|
291 |
return 'outofcontext-search' |
|
1451 | 292 |
|
0 | 293 |
def cell_call(self, row, col, vid=None, **kwargs): |
294 |
if not vid: |
|
295 |
vid = self.redirect_vid |
|
296 |
try: |
|
297 |
self.wview(vid, self.rset, row=row, col=col, **kwargs) |
|
298 |
except NoSelectableObject: |
|
299 |
if vid == self.redirect_vid: |
|
300 |
raise |
|
301 |
self.wview(self.redirect_vid, self.rset, row=row, col=col, **kwargs) |
|
302 |
||
303 |
||
304 |
class SimpleListView(ListItemView): |
|
305 |
"""list without bullets""" |
|
306 |
id = 'simplelist' |
|
307 |
redirect_vid = 'incontext' |
|
308 |
||
309 |
||
310 |
class CSVView(SimpleListView): |
|
311 |
id = 'csv' |
|
312 |
redirect_vid = 'incontext' |
|
1451 | 313 |
|
0 | 314 |
def call(self, **kwargs): |
315 |
rset = self.rset |
|
316 |
for i in xrange(len(rset)): |
|
317 |
self.cell_call(i, 0, vid=kwargs.get('vid')) |
|
318 |
if i < rset.rowcount-1: |
|
319 |
self.w(u", ") |
|
320 |
||
321 |
||
322 |
class TreeItemView(ListItemView): |
|
323 |
id = 'treeitem' |
|
324 |
||
325 |
def cell_call(self, row, col): |
|
326 |
self.wview('incontext', self.rset, row=row, col=col) |
|
327 |
||
328 |
class TextSearchResultView(EntityView): |
|
329 |
"""this view is used to display full-text search |
|
330 |
||
331 |
It tries to highlight part of data where the search word appears. |
|
332 |
||
333 |
XXX: finish me (fixed line width, fixed number of lines, CSS, etc.) |
|
334 |
""" |
|
335 |
id = 'tsearch' |
|
336 |
||
337 |
def cell_call(self, row, col, **kwargs): |
|
338 |
entity = self.complete_entity(row, col) |
|
339 |
self.w(entity.view('incontext')) |
|
340 |
searched = self.rset.searched_text() |
|
341 |
if searched is None: |
|
342 |
return |
|
343 |
searched = searched.lower() |
|
344 |
highlighted = '<b>%s</b>' % searched |
|
345 |
for attr in entity.e_schema.indexable_attributes(): |
|
346 |
try: |
|
1680
39860636e184
use xml_escape
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1653
diff
changeset
|
347 |
value = xml_escape(entity.printable_value(attr, format='text/plain').lower()) |
0 | 348 |
except TransformError, ex: |
349 |
continue |
|
350 |
except: |
|
351 |
continue |
|
352 |
if searched in value: |
|
353 |
contexts = [] |
|
354 |
for ctx in value.split(searched): |
|
355 |
if len(ctx) > 30: |
|
356 |
contexts.append(u'...' + ctx[-30:]) |
|
357 |
else: |
|
358 |
contexts.append(ctx) |
|
359 |
value = u'\n' + highlighted.join(contexts) |
|
1451 | 360 |
self.w(value.replace('\n', '<br/>')) |
0 | 361 |
|
362 |
||
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
363 |
class TooltipView(EntityView): |
0 | 364 |
"""A entity view used in a tooltip""" |
365 |
id = 'tooltip' |
|
366 |
def cell_call(self, row, col): |
|
367 |
self.wview('oneline', self.rset, row=row, col=col) |
|
368 |
||
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
369 |
|
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
370 |
# XXX bw compat |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
371 |
|
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
372 |
from logilab.common.deprecation import class_moved |
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
373 |
|
0 | 374 |
try: |
375 |
from cubicweb.web.views.tableview import TableView |
|
376 |
TableView = class_moved(TableView) |
|
377 |
except ImportError: |
|
378 |
pass # gae has no tableview module (yet) |
|
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
379 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
1477
diff
changeset
|
380 |
from cubicweb.web.views import boxes, xmlrss, primary |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
1477
diff
changeset
|
381 |
PrimaryView = class_moved(primary.PrimaryView) |
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
795
diff
changeset
|
382 |
SideBoxView = class_moved(boxes.SideBoxView) |
1653 | 383 |
XmlView = class_moved(xmlrss.XMLView) |
384 |
XmlItemView = class_moved(xmlrss.XMLItemView) |
|
385 |
XmlRsetView = class_moved(xmlrss.XMLRsetView) |
|
386 |
RssView = class_moved(xmlrss.RSSView) |
|
387 |
RssItemView = class_moved(xmlrss.RSSItemView) |
|
1451 | 388 |