示例#1
0
    def heading(self):
        """Return the heading text for the page.

        If the view provides `IEditableContextTitle` then the top heading is
        rendered from the view's `title_edit_widget` and is generally
        editable.

        Otherwise, if the context provides `IRootContext` then we return an
        H1, else an H2.
        """
        # Check the view; is the title editable?
        if IEditableContextTitle.providedBy(self._view):
            return self._view.title_edit_widget()
        # The title is static, but only the context's index view gets an H1.
        if IMajorHeadingView.providedBy(self._view):
            heading = structured('h1')
        else:
            heading = structured('h2')
        # If there is actually no root context, then it's a top-level
        # context-less page so Launchpad.net is shown as the branding.
        if self.root_context is None:
            title = 'Launchpad.net'
        else:
            title = self.root_context.title
        # For non-editable titles, generate the static heading.
        return structured("<%(heading)s>%(title)s</%(heading)s>",
                          heading=heading,
                          title=title).escapedtext
示例#2
0
    def heading(self):
        """Return the heading text for the page.

        If the view provides `IEditableContextTitle` then the top heading is
        rendered from the view's `title_edit_widget` and is generally
        editable.

        Otherwise, if the context provides `IRootContext` then we return an
        H1, else an H2.
        """
        # Check the view; is the title editable?
        if IEditableContextTitle.providedBy(self._view):
            return self._view.title_edit_widget()
        # The title is static, but only the context's index view gets an H1.
        if IMajorHeadingView.providedBy(self._view):
            heading = structured("h1")
        else:
            heading = structured("h2")
        # If there is actually no root context, then it's a top-level
        # context-less page so Launchpad.net is shown as the branding.
        if self.root_context is None:
            title = "Launchpad.net"
        else:
            title = self.root_context.title
        # For non-editable titles, generate the static heading.
        return structured("<%(heading)s>%(title)s</%(heading)s>", heading=heading, title=title).escapedtext
示例#3
0
 def display_breadcrumbs(self):
     """Return whether the breadcrumbs should be displayed."""
     # If there is only one breadcrumb then it does not make sense
     # to display it as it will simply repeat the context.title.
     # If the view is an IMajorHeadingView then we do not want
     # to display breadcrumbs either.
     has_major_heading = IMajorHeadingView.providedBy(
         self._naked_context_view)
     return len(self.items_for_body) > 1 and not has_major_heading
 def display_breadcrumbs(self):
     """Return whether the breadcrumbs should be displayed."""
     # If there is only one breadcrumb then it does not make sense
     # to display it as it will simply repeat the context.title.
     # If the view is an IMajorHeadingView then we do not want
     # to display breadcrumbs either.
     has_major_heading = IMajorHeadingView.providedBy(
         self._naked_context_view)
     return len(self.items) > 1 and not has_major_heading
示例#5
0
    def heading(self):
        """Return the heading markup for the page.

        If the context provides `IMajorHeadingView` then we return an
        H1, else an H2.
        """
        # The title is static, but only the index view gets an H1.
        tag = 'h1' if IMajorHeadingView.providedBy(self.context) else 'h2'
        # If there is actually no root context, then it's a top-level
        # context-less page so Launchpad.net is shown as the branding.
        crumb_markups = []
        for crumb in self.heading_breadcrumbs:
            crumb_markups.append(
                structured('<a href="%s">%s</a>', crumb.url, crumb.detail))
        if not crumb_markups:
            crumb_markups.append(structured('<span>Launchpad.net</span>'))
        content = structured(
            '<br />'.join(['%s'] * len(crumb_markups)), *crumb_markups)
        return structured(
            '<%s id="watermark-heading">%s</%s>',
            tag, content, tag).escapedtext