merge
authorLaure Bourgois <Laure.Bourgois@logilab.fr>
Fri, 21 Nov 2008 17:37:27 +0100
changeset 126 80c65c9f7c41
parent 125 979dbe0cade3 (diff)
parent 124 451061423290 (current diff)
child 127 ae611743f5c6
child 142 0425ee84cfa6
merge
doc/book/en/01-intro.en.txt
doc/book/en/01-introduction.en.txt
doc/book/en/02-foundation.en.txt
doc/book/en/02-install.en.txt
doc/book/en/03-create-app.en.txt
doc/book/en/03-definition-schema.en.txt
doc/book/en/03-sect-definition-schema.en.txt
doc/book/en/03-sect-stdlib-schemas.en.txt
doc/book/en/03-setup.en.txt
doc/book/en/04-define-schema.en.txt
doc/book/en/04-develop-views.en.txt
doc/book/en/05-components.en.txt
doc/book/en/05-define-views.en.txt
doc/book/en/06-define-workflows.en.txt
doc/book/en/06-maintemplate.en.txt
doc/book/en/07-data-as-objects.en.txt
doc/book/en/07-rss-xml.en.txt
doc/book/en/08-rql.en.txt
doc/book/en/08-site-config.en.txt
doc/book/en/09-instance-config.en.txt
doc/book/en/09-urlrewrite.en.txt
doc/book/en/10-form-management.en.txt
doc/book/en/10-security.en.txt
doc/book/en/11-ajax-json.en.txt
doc/book/en/11-definition-workflow.en.txt
doc/book/en/11-faq.en.txt
doc/book/en/12-internationalization.en.txt
doc/book/en/12-reference.en.txt
doc/book/en/12-ui-components.en.txt
doc/book/en/13-security.en.txt
doc/book/en/14-hooks.en.txt
doc/book/en/15-notifications.en.txt
doc/book/en/16-rql.en.txt
doc/book/en/17-migration.en.txt
doc/book/en/18-tests.en.txt
doc/book/en/19-i18n.en.txt
doc/book/en/20-gae.en.txt
doc/book/en/21-02-querier.en.txt
doc/book/en/21-appendix.en.txt
doc/book/en/22-faq.en.txt
doc/book/fr/01-intro.fr.txt
doc/book/fr/02-install.fr.txt
doc/book/fr/03-create-app.fr.txt
doc/book/fr/04-develop-views.fr.txt
doc/book/fr/05-components.fr.txt
doc/book/fr/06-maintemplate.fr.txt
doc/book/fr/07-rss-xml.fr.txt
doc/book/fr/08-rql.fr.txt
doc/book/fr/09-urlrewrite.fr.txt
doc/book/fr/10-security.fr.txt
doc/book/fr/20-gae.fr.txt
--- a/entities/__init__.py	Fri Nov 21 12:09:27 2008 +0100
+++ b/entities/__init__.py	Fri Nov 21 17:37:27 2008 +0100
@@ -16,7 +16,8 @@
 from cubicweb.common.entity import Entity
 from cubicweb.schema import FormatConstraint
 
-from cubicweb.interfaces import IBreadCrumbs
+from cubicweb.interfaces import IBreadCrumbs, IFeed
+
 
 class AnyEntity(Entity):
     """an entity instance has e_schema automagically set on the class and
@@ -52,7 +53,7 @@
         ('comments',           '*', 'object')  : ('generated', 'link'),
         }
 
-    __implements__ = (IBreadCrumbs,)
+    __implements__ = (IBreadCrumbs, IFeed)
     
     @classmethod
     def selected(cls, etype):
@@ -197,6 +198,10 @@
                 path.append( self.req._(view.title) )
         return path
 
+    ## IFeed interface ########################################################
+
+    def rss_feed_url(self):
+        return self.absolute_url(vid='rss')
     # abstractions making the whole things (well, some at least) working ######
     
     @classmethod
--- a/interfaces.py	Fri Nov 21 12:09:27 2008 +0100
+++ b/interfaces.py	Fri Nov 21 17:37:27 2008 +0100
@@ -232,3 +232,9 @@
         (returns None for default)
         """
         
+class IFeed(Interface):
+    """interface for entities with rss flux"""
+    
+    def rss_feed_url(self):
+        """return an url which layout sub-entities item
+        """
--- a/web/views/boxes.py	Fri Nov 21 12:09:27 2008 +0100
+++ b/web/views/boxes.py	Fri Nov 21 17:37:27 2008 +0100
@@ -17,7 +17,7 @@
 
 from logilab.mtconverter import html_escape
 
-from cubicweb.common.selectors import rset_selector, nfentity_selector
+from cubicweb.common.selectors import rset_selector, nfentity_selector, onelinerset_selector
 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem
 from cubicweb.web.box import BoxTemplate, ExtResourcesBoxTemplate
 
@@ -194,16 +194,22 @@
     visible = False
     
     def call(self, **kwargs):
-        eid = self
-        if len(self.rset)==1:
-            eid = self.rset[0][0]
-            rql = 'Any E WHERE E is BlogEntry, E entry_of X, X eid %s' % eid
-        else:
-            rql = self.limited_rql()
-        url = html_escape(self.build_url(rql=rql, vid='rss'))
+        url = html_escape(self.build_url(rql=self.limited_rql(), vid='rss'))
         rss = self.req.external_resource('RSS_LOGO')
         self.w(u'<a href="%s"><img src="%s" border="0" /></a>\n' % (url, rss))
 
+class EntityRSSIconBox(RSSIconBox):
+    """just display the RSS icon on uniform result set for a single entity"""
+    __selectors__ = RSSIconBox.__selectors__ + (onelinerset_selector,)
+
+    def call(self, **kwargs):
+        entity = self.entity(0, 0)
+        url = entity.rss_feed_url()
+        eid = entity.eid
+        rss = self.req.external_resource('RSS_LOGO')
+        self.w(u'<a href="%s"><img src="%s" border="0" /></a>\n' %
+               (html_escape(url), rss))
+
 ## warning("schemabox ne marche plus pour le moment")
 ## class SchemaBox(BoxTemplate):
 ##     """display a box containing link to list of entities by type"""
@@ -221,7 +227,6 @@
 ##         if not box.is_empty():
 ##             box.render(self.w)
 
-
 class StartupViewsBox(BoxTemplate):
     """display a box containing links to all startup views"""
     id = 'startup_views_box'