Beispiel #1
0
 def RSS10(self, howmany=10, REQUEST=None):
     """ return a RSS feed """
     def u2s(ustr):
         return cgi.escape(ustr).encode('ascii','xmlcharrefreplace')
     
     feed = Feed(self.absolute_url()+'/rss.xml',
                 title=u2s(self.getRoot().getTitle()),
                 description='',
                 language='sv',
                 webmaster='')
                 
     for bust in self.getBusts(howmany=int(howmany), sort='getCreateDate', reverse=1):
         title = u2s(bust.getTitle())
         description = u2s(bust.getDescription())
         thumbnail = bust.getThumbnail()
         ahref = '<a href="%s">%s</a>' % (bust.absolute_url(),
                                          thumbnail.tag())
         description = ahref + ' ' + description
         
         feed.append(Item(title,
                          bust.absolute_url(),
                          description,
                          date=bust.getCreateDate().strftime('%Y-%m-%dT%H:%M')
                          )
                     )
         
     if REQUEST is not None:
         REQUEST.RESPONSE.setHeader('Content-Type', 'text/xml')
             
     return feed.out().strip()
Beispiel #2
0
    def RSS(self, filter_publish_date=1, howmany=20, REQUEST=None):
        """ return a XML RSS feed item """

        feed = RSSFeed(self.absolute_url()+'/rss.xml',
                       items=[], 
                       title=self.getRoot().getTitle(),
                       webmaster=self.getWebmasterEmail(),
                       abouturl=self.getRoot().absolute_url())

        count = 0
        for n in self.getNewsItems(filter_publish_date=filter_publish_date,
                                   sort='publish_date'):
            description = n.getAbstract() or n.getBody()
            feed.append(RSSItem(n.getTitle(),
                           n.absolute_url(),
                           description,
                           date=n.getPublishDate(),
                           subject='News')
                           )
            count += 1
            if count >= int(howmany):
                break
            
    
        if REQUEST is not None:
            REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
            
        return str(feed).strip()
Beispiel #3
0
    def RSS(self, filter_publish_date=1, howmany=20, REQUEST=None):
        """
        Return a XML RSS feed item
        """

        feed = RSSFeed(
            self.absolute_url() + "/rss.xml",
            items=[],
            title=self.getRoot().getTitle(),
            webmaster=self.getWebmasterEmail(),
            abouturl=self.getRoot().absolute_url(),
        )

        count = 0
        items = self.getItems(filter_publish_date=filter_publish_date, sort="publish_date")
        for item in items:
            if hasattr(self, "abstract"):
                description = item.getAbstract()
            else:
                description = item.getBody()
            feed.append(
                RSSItem(
                    item.getTitle(),
                    item.absolute_url(),
                    description,
                    date=item.getPublishDate(),
                    subject=self.getTitle(),
                )
            )
            count += 1
            if count >= int(howmany):
                break

        if REQUEST is not None:
            REQUEST.RESPONSE.setHeader("Content-Type", "text/xml")

        return str(feed).strip()