web/views/timeline.py
branchstable
changeset 2312 af4d8f75c5db
parent 1977 606923dff11b
child 3377 dd9d292b6a6d
child 4212 ab6573088b4a
equal deleted inserted replaced
2311:f178182b1305 2312:af4d8f75c5db
     9 """
     9 """
    10 __docformat__ = "restructuredtext en"
    10 __docformat__ = "restructuredtext en"
    11 
    11 
    12 import simplejson
    12 import simplejson
    13 
    13 
    14 from logilab.mtconverter import html_escape
    14 from logilab.mtconverter import xml_escape
    15 
    15 
    16 from cubicweb.interfaces import ICalendarable
    16 from cubicweb.interfaces import ICalendarable
    17 from cubicweb.selectors import implements
    17 from cubicweb.selectors import implements
    18 from cubicweb.view import EntityView, StartupView
    18 from cubicweb.view import EntityView, StartupView
    19 
    19 
    66         stop = entity.stop
    66         stop = entity.stop
    67         start = start or stop
    67         start = start or stop
    68         if start is None and stop is None:
    68         if start is None and stop is None:
    69             return None
    69             return None
    70         event_data = {'start': start.strftime(self.date_fmt),
    70         event_data = {'start': start.strftime(self.date_fmt),
    71                       'title': html_escape(entity.dc_title()),
    71                       'title': xml_escape(entity.dc_title()),
    72                       'description': entity.dc_description(format='text/html'),
    72                       'description': entity.dc_description(format='text/html'),
    73                       'link': entity.absolute_url(),
    73                       'link': entity.absolute_url(),
    74                       }
    74                       }
    75         onclick = self.onclick(entity)
    75         onclick = self.onclick(entity)
    76         if onclick:
    76         if onclick:
    93             additional = u' cubicweb:tlunit="%s"' % tlunit
    93             additional = u' cubicweb:tlunit="%s"' % tlunit
    94         else:
    94         else:
    95             additional = u''
    95             additional = u''
    96         self.w(u'<div class="widget" cubicweb:wdgtype="%s" '
    96         self.w(u'<div class="widget" cubicweb:wdgtype="%s" '
    97                u'cubicweb:loadtype="auto" cubicweb:loadurl="%s" %s >' %
    97                u'cubicweb:loadtype="auto" cubicweb:loadurl="%s" %s >' %
    98                (self.widget_class, html_escape(loadurl),
    98                (self.widget_class, xml_escape(loadurl),
    99                 additional))
    99                 additional))
   100         self.w(u'</div>')
   100         self.w(u'</div>')
   101 
   101 
   102 
   102 
   103 class TimelineView(TimelineViewMixIn, EntityView):
   103 class TimelineView(TimelineViewMixIn, EntityView):