Exemplo n.º 1
0
    def render_rootURL(self, ctx, data):
        """
        Add the WebSite's root URL as a child of the given tag.

        The root URL is the location of the resource beneath which all standard
        Mantissa resources (such as the private application and static content)
        is available.  This can be important if a page is to be served at a
        location which is different from the root URL in order to make links in
        static XHTML templates resolve correctly (for example, by adding this
        value as the href of a <base> tag).
        """
        site = ISiteURLGenerator(self._siteStore())
        return ctx.tag[site.rootURL(IRequest(ctx))]
Exemplo n.º 2
0
    def render_rootURL(self, ctx, data):
        """
        Add the WebSite's root URL as a child of the given tag.

        The root URL is the location of the resource beneath which all standard
        Mantissa resources (such as the private application and static content)
        is available.  This can be important if a page is to be served at a
        location which is different from the root URL in order to make links in
        static XHTML templates resolve correctly (for example, by adding this
        value as the href of a <base> tag).
        """
        site = ISiteURLGenerator(self._siteStore())
        return ctx.tag[site.rootURL(IRequest(ctx))]
Exemplo n.º 3
0
    def test_stylesheetLocation(self):
        """
        L{XHTMLDirectoryTheme.head} returns a link tag which gives the location
        of the stylesheet given by I{stylesheetLocation} if there is one.
        """
        siteStore = Store(filesdir=self.mktemp())
        Mantissa().installSite(siteStore, u"example.com", u"", False)
        site = ISiteURLGenerator(siteStore)

        self.theme.stylesheetLocation = ['foo', 'bar']
        request = FakeRequest()
        link = self.theme.head(request, site)
        self.assertEqual(link.tagName, 'link')
        self.assertEqual(link.attributes['rel'], 'stylesheet')
        self.assertEqual(link.attributes['type'], 'text/css')
        self.assertEqual(
            site.rootURL(request).child('foo').child('bar'),
            link.attributes['href'])
Exemplo n.º 4
0
    def test_stylesheetLocation(self):
        """
        L{XHTMLDirectoryTheme.head} returns a link tag which gives the location
        of the stylesheet given by I{stylesheetLocation} if there is one.
        """
        siteStore = Store(filesdir=self.mktemp())
        Mantissa().installSite(siteStore, u"example.com", u"", False)
        site = ISiteURLGenerator(siteStore)

        self.theme.stylesheetLocation = ['foo', 'bar']
        request = FakeRequest()
        link = self.theme.head(request, site)
        self.assertEqual(link.tagName, 'link')
        self.assertEqual(link.attributes['rel'], 'stylesheet')
        self.assertEqual(link.attributes['type'], 'text/css')
        self.assertEqual(
            site.rootURL(request).child('foo').child('bar'),
            link.attributes['href'])
Exemplo n.º 5
0
    def rootURL(self, request):
        """
        Simple utility function to provide a root URL for this website which is
        appropriate to use in links generated in response to the given request.

        @type request: L{twisted.web.http.Request}
        @param request: The request which is being responded to.

        @rtype: L{URL}
        @return: The location at which the root of the resource hierarchy for
            this website is available.
        """
        warnings.warn(
            "Use ISiteURLGenerator.rootURL instead of WebSite.rootURL.",
            category=DeprecationWarning,
            stacklevel=2)
        if self.store.parent is not None:
            generator = ISiteURLGenerator(self.store.parent)
        else:
            generator = ISiteURLGenerator(self.store)
        return generator.rootURL(request)
Exemplo n.º 6
0
    def rootURL(self, request):
        """
        Simple utility function to provide a root URL for this website which is
        appropriate to use in links generated in response to the given request.

        @type request: L{twisted.web.http.Request}
        @param request: The request which is being responded to.

        @rtype: L{URL}
        @return: The location at which the root of the resource hierarchy for
            this website is available.
        """
        warnings.warn(
            "Use ISiteURLGenerator.rootURL instead of WebSite.rootURL.",
            category=DeprecationWarning,
            stacklevel=2)
        if self.store.parent is not None:
            generator = ISiteURLGenerator(self.store.parent)
        else:
            generator = ISiteURLGenerator(self.store)
        return generator.rootURL(request)