def createFeedEntry(self, content_view): """Create the FeedEntry for the specified view.""" revision = content_view.context id = revision_feed_id(revision) content = content_view.render() content_data = FeedTypedData(content=content, content_type="html", root_url=self.root_url) title = FeedTypedData(content_view.title) if revision.revision_author.person is None: authors = [RevisionPerson(revision.revision_author, self.rootsite)] else: authors = [ FeedPerson(revision.revision_author.person, self.rootsite) ] entry = FeedEntry(title=title, link_alternate=None, date_created=revision.revision_date, date_updated=revision.revision_date, date_published=revision.date_created, authors=authors, id_=id, content=content_data) return entry
def itemToFeedEntry(self, bug): """Convert the items to FeedEntries.""" title = FeedTypedData('[%s] %s' % (bug.id, bug.title)) url = canonical_url(bug, rootsite=self.rootsite) content_view = BugFeedContentView(bug, self.request, self) entry = FeedEntry(title=title, link_alternate=url, date_created=bug.datecreated, date_updated=bug.date_last_updated, date_published=bug.datecreated, authors=[FeedPerson(bug.owner, self.rootsite)], content=FeedTypedData(content_view.render(), content_type="html")) return entry
def itemToFeedEntry(self, branch): """See `IFeed`.""" title = FeedTypedData(branch.displayname) url = canonical_url(branch, rootsite=self.rootsite) content_view = BranchFeedContentView(branch, self.request, self) content = content_view.render() content_data = FeedTypedData(content=content, content_type="html", root_url=self.root_url) entry = BranchFeedEntry( title=title, link_alternate=url, date_created=branch.date_created, date_updated=branch.date_last_modified, date_published=branch.date_created, # XXX bac 2008-01-10: if author and owner are # different perhaps we should use them both? authors=[FeedPerson(branch.owner, self.rootsite)], content=content_data) return entry
def itemToFeedEntry(self, rev): """See `IFeed`.""" title = FeedTypedData("Revision %d" % rev.sequence) url = self.context.getCodebrowseUrl('revision', str(rev.sequence)) content_view = BranchFeedContentView(rev, self.request, self, 'templates/branch-revision.pt') content = FeedTypedData(content=content_view.render(), content_type="html", root_url=self.root_url) entry = BranchFeedEntry(title=title, link_alternate=url, date_created=rev.revision.date_created, date_updated=rev.revision.revision_date, date_published=None, authors=[ RevisionPerson( rev.revision.revision_author, self.rootsite) ], content=content) return entry
def itemToFeedEntry(self, announcement): """See `IFeed`.""" # Given an instance of an announcement, create a FeedEntry out of it # and return. # The title for the FeedEntry is an IFeedTypedData instance and may be # plain text or html. title = self._entryTitle(announcement) # The link_alternate for the entry is the human-readable alternate URL # for the entry. For example: # http://launchpad.net/ubuntu/+announcment/12 entry_link_alternate = "%s%s" % (canonical_url( announcement.target, rootsite=self.rootsite), "/+announcement/%d" % announcement.id) # The content of the entry is the text displayed as the body in the # feed reader. For announcements it is plain text but it must be # escaped to account for any special characters the user may have # entered, such as '&' and '<' because it will be embedded in the XML # document. formatted_summary = FormattersAPI(announcement.summary).text_to_html() content = FeedTypedData(formatted_summary, content_type="html", root_url=self.root_url) # The entry for an announcement has distinct dates for created, # updated, and published. For some data, the created and published # dates will be the same. The announcements also only have a singe # author. entry_id = 'tag:launchpad.net,%s:/+announcement/%d' % ( announcement.date_created.date().isoformat(), announcement.id) entry = FeedEntry( title=title, link_alternate=entry_link_alternate, date_created=announcement.date_created, date_updated=announcement.date_updated, date_published=announcement.date_announced, authors=[FeedPerson(announcement.registrant, rootsite="mainsite")], content=content, id_=entry_id) return entry
def _entryTitle(self, announcement): return FeedTypedData(announcement.title)
def _entryTitle(self, announcement): """Return an `IFeedTypedData` instance for the feed title.""" return FeedTypedData('[%s] %s' % (announcement.target.name, announcement.title))