コード例 #1
0
ファイル: journal.py プロジェクト: elfixit/rhodecode
    def public_journal_rss(self):
        """
        Produce an rss2 feed via feedgenerator module
        """
        c.following = self.sa.query(UserFollowing)\
            .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\
            .options(joinedload(UserFollowing.follows_repository))\
            .all()

        journal = self._get_journal_data(c.following)

        feed = Rss201rev2Feed(title=self.title % 'rss',
                         link=url('public_journal_rss', qualified=True),
                         description=_('Public journal'),
                         language=self.language,
                         ttl=self.ttl)

        for entry in journal[:self.feed_nr]:
            #tmpl = h.action_parser(entry)[0]
            action, action_extra = h.action_parser(entry, feed=True)
            title = "%s - %s %s" % (entry.user.short_contact, action,
                                 entry.repository.repo_name)
            desc = action_extra()
            feed.add_item(title=title,
                          pubdate=entry.action_date,
                          link=url('', qualified=True),
                          author_email=entry.user.email,
                          author_name=entry.user.full_contact,
                          description=desc)

        response.content_type = feed.mime_type
        return feed.writeString('utf-8')
コード例 #2
0
ファイル: journal.py プロジェクト: jeffjirsa/rhodecode
    def _rss_feed(self, repos, public=True):
        journal = self._get_journal_data(repos)
        if public:
            _link = url('public_journal_atom', qualified=True)
            _desc = '%s %s %s' % (c.rhodecode_name, _('public journal'),
                                  'rss feed')
        else:
            _link = url('journal_atom', qualified=True)
            _desc = '%s %s %s' % (c.rhodecode_name, _('journal'), 'rss feed')

        feed = Rss201rev2Feed(title=_desc,
                         link=_link,
                         description=_desc,
                         language=self.language,
                         ttl=self.ttl)

        for entry in journal[:self.feed_nr]:
            user = entry.user
            if user is None:
                #fix deleted users
                user = AttributeDict({'short_contact': entry.username,
                                      'email': '',
                                      'full_contact': ''})
            action, action_extra, ico = h.action_parser(entry, feed=True)
            title = "%s - %s %s" % (user.short_contact, action(),
                                    entry.repository.repo_name)
            desc = action_extra()
            _url = None
            if entry.repository is not None:
                _url = url('changelog_home',
                           repo_name=entry.repository.repo_name,
                           qualified=True)

            feed.add_item(title=title,
                          pubdate=entry.action_date,
                          link=_url or url('', qualified=True),
                          author_email=user.email,
                          author_name=user.full_contact,
                          description=desc)

        response.content_type = feed.mime_type
        return feed.writeString('utf-8')