예제 #1
0
    def _navigation_feed(self, library, annotator, url_for=None):
        """Generate an OPDS feed for navigating the COPPA age gate."""
        url_for = url_for or cdn_url_for
        base_url = url_for("index", library_short_name=library.short_name)

        # An entry for grown-ups.
        feed = OPDSFeed(title=library.name, url=base_url)
        opds = feed.feed

        yes_url = url_for(
            "acquisition_groups",
            library_short_name=library.short_name,
            lane_identifier=self.yes_lane_id,
        )
        opds.append(self.navigation_entry(yes_url, self.YES_TITLE, self.YES_CONTENT))

        # An entry for children.
        no_url = url_for(
            "acquisition_groups",
            library_short_name=library.short_name,
            lane_identifier=self.no_lane_id,
        )
        opds.append(self.navigation_entry(no_url, self.NO_TITLE, self.NO_CONTENT))

        # The gate tag is the thing that the SimplyE client actually uses.
        opds.append(self.gate_tag(self.URI, yes_url, no_url))

        # Add any other links associated with this library, notably
        # the link to its authentication document.
        if annotator:
            annotator.annotate_feed(feed, None)

        now = utc_now()
        opds.append(OPDSFeed.E.updated(OPDSFeed._strftime(now)))
        return feed
예제 #2
0
 def navigation_entry(cls, href, title, content):
     """Create an <entry> that serves as navigation."""
     E = OPDSFeed.E
     content_tag = E.content(type="text")
     content_tag.text = unicode(content)
     now = datetime.datetime.utcnow()
     entry = E.entry(E.id(href), E.title(unicode(title)), content_tag,
                     E.updated(OPDSFeed._strftime(now)))
     OPDSFeed.add_link_to_entry(entry,
                                href=href,
                                rel="subsection",
                                type=OPDSFeed.ACQUISITION_FEED_TYPE)
     return entry
예제 #3
0
 def navigation_entry(cls, href, title, content):
     """Create an <entry> that serves as navigation."""
     E = OPDSFeed.E
     content_tag = E.content(type="text")
     content_tag.text = unicode(content)
     now = datetime.datetime.utcnow()
     entry = E.entry(
         E.id(href),
         E.title(unicode(title)),
         content_tag,
         E.updated(OPDSFeed._strftime(now))
     )
     OPDSFeed.add_link_to_entry(
         entry, href=href, rel="subsection",
         type=OPDSFeed.ACQUISITION_FEED_TYPE
     )
     return entry
예제 #4
0
    def _navigation_feed(self, library, annotator, url_for=None):
        """Generate an OPDS feed for navigating the COPPA age gate."""
        url_for = url_for or cdn_url_for
        base_url = url_for('index', library_short_name=library.short_name)

        # An entry for grown-ups.
        feed = OPDSFeed(title=library.name, url=base_url)
        opds = feed.feed

        yes_url = url_for(
            'acquisition_groups',
            library_short_name=library.short_name,
            lane_identifier=self.yes_lane_id
        )
        opds.append(
            self.navigation_entry(yes_url, self.YES_TITLE, self.YES_CONTENT)
        )

        # An entry for children.
        no_url = url_for(
            'acquisition_groups',
            library_short_name=library.short_name,
            lane_identifier=self.no_lane_id
        )
        opds.append(
            self.navigation_entry(no_url, self.NO_TITLE, self.NO_CONTENT)
        )

        # The gate tag is the thing that the SimplyE client actually uses.
        opds.append(self.gate_tag(self.URI, yes_url, no_url))

        # Add any other links associated with this library, notably
        # the link to its authentication document.
        if annotator:
            annotator.annotate_feed(feed, None)

        now = datetime.datetime.utcnow()
        opds.append(OPDSFeed.E.updated(OPDSFeed._strftime(now)))
        return feed