web/views/baseviews.py
changeset 8130 85ade620056c
parent 7940 ac8052334e0d
child 8190 2a3c1b787688
equal deleted inserted replaced
8129:2dedcc15208d 8130:85ade620056c
   155 
   155 
   156 class InContextView(EntityView):
   156 class InContextView(EntityView):
   157     """:__regid__: *incontext*
   157     """:__regid__: *incontext*
   158 
   158 
   159     This view is used whenthe entity should be considered as displayed in its
   159     This view is used whenthe entity should be considered as displayed in its
   160     context. By default it produces the result of `textincontext` wrapped in a
   160     context. By default it produces the result of ``entity.dc_title()`` wrapped in a
   161     link leading to the primary view of the entity.
   161     link leading to the primary view of the entity.
   162     """
   162     """
   163     __regid__ = 'incontext'
   163     __regid__ = 'incontext'
   164 
   164 
   165     def cell_call(self, row, col):
   165     def cell_call(self, row, col):
   166         entity = self.cw_rset.get_entity(row, col)
   166         entity = self.cw_rset.get_entity(row, col)
   167         desc = cut(entity.dc_description(), 50)
   167         desc = cut(entity.dc_description(), 50)
   168         self.w(u'<a href="%s" title="%s">' % (
   168         self.w(u'<a href="%s" title="%s">%s</a>' % (
   169             xml_escape(entity.absolute_url()), xml_escape(desc)))
   169             xml_escape(entity.absolute_url()), xml_escape(desc),
   170         self.w(xml_escape(self._cw.view('textincontext', self.cw_rset,
   170             xml_escape(entity.dc_title())))
   171                                         row=row, col=col)))
       
   172         self.w(u'</a>')
       
   173 
       
   174 
   171 
   175 class OutOfContextView(EntityView):
   172 class OutOfContextView(EntityView):
   176     """:__regid__: *outofcontext*
   173     """:__regid__: *outofcontext*
   177 
   174 
   178     This view is used whenthe entity should be considered as displayed out of
   175     This view is used whenthe entity should be considered as displayed out of
   179     its context. By default it produces the result of `textoutofcontext` wrapped
   176     its context. By default it produces the result of ``entity.dc_long_title()`` wrapped
   180     in a link leading to the primary view of the entity.
   177     in a link leading to the primary view of the entity.
   181     """
   178     """
   182     __regid__ = 'outofcontext'
   179     __regid__ = 'outofcontext'
   183 
   180 
   184     def cell_call(self, row, col):
   181     def cell_call(self, row, col):
   185         entity = self.cw_rset.get_entity(row, col)
   182         entity = self.cw_rset.get_entity(row, col)
   186         desc = cut(entity.dc_description(), 50)
   183         desc = cut(entity.dc_description(), 50)
   187         self.w(u'<a href="%s" title="%s">' % (
   184         self.w(u'<a href="%s" title="%s">%s</a>' % (
   188             xml_escape(entity.absolute_url()), xml_escape(desc)))
   185             xml_escape(entity.absolute_url()), xml_escape(desc),
   189         self.w(xml_escape(self._cw.view('textoutofcontext', self.cw_rset,
   186             xml_escape(entity.dc_long_title())))
   190                                         row=row, col=col)))
       
   191         self.w(u'</a>')
       
   192 
   187 
   193 
   188 
   194 class OneLineView(EntityView):
   189 class OneLineView(EntityView):
   195     """:__regid__: *oneline*
   190     """:__regid__: *oneline*
   196 
   191 
   203 
   198 
   204     def cell_call(self, row, col, **kwargs):
   199     def cell_call(self, row, col, **kwargs):
   205         """the one line view for an entity: linked text view
   200         """the one line view for an entity: linked text view
   206         """
   201         """
   207         entity = self.cw_rset.get_entity(row, col)
   202         entity = self.cw_rset.get_entity(row, col)
   208         self.w(u'<a href="%s">' % xml_escape(entity.absolute_url()))
   203         desc = cut(entity.dc_description(), 50)
   209         self.w(xml_escape(self._cw.view('text', self.cw_rset, row=row, col=col)))
   204         title = cut(entity.dc_title(),
   210         self.w(u'</a>')
   205                     self._cw.property_value('navigation.short-line-size'))
       
   206         self.w(u'<a href="%s" title="%s">%s</a>' % (
       
   207                 xml_escape(entity.absolute_url()), xml_escape(desc),
       
   208                 xml_escape(title)))
   211 
   209 
   212 
   210 
   213 # text views ###################################################################
   211 # text views ###################################################################
   214 
   212 
   215 class TextView(EntityView):
   213 class TextView(EntityView):