Esempio n. 1
0
    def test_canonify_media_img(self):
        img = '<img src="/relative/link/image.png"/>'
        string = "{{ img|canonify_media('https://www.example.org') }}"
        text = Renderer.render_from_string(string, {"img": img})
        expected = '<img src="https://www.example.org/relative/link/image.png"/>'

        assert text == expected
Esempio n. 2
0
    def test_canonify_media_vid(self):
        vid = '<video src="/relative/link/video.webm"></video>'
        string = "{{ vid|canonify_media('https://www.example.org') }}"
        text = Renderer.render_from_string(string, {"vid": vid})
        expected = (
            '<video src="https://www.example.org/relative/link/video.webm"></video>'
        )

        assert text == expected
Esempio n. 3
0
    def url(self):
        """Return the page URL.

        Page URLs can be overridden in the site config by specifying a
        URL override template for the section.

        """

        if self.section.override:
            template = self.section.override
        else:
            template = "{{ page.section.rel }}/{{ page|slug }}"

        args = {"page": self}
        return Renderer.render_from_string(template, args)
Esempio n. 4
0
    def url(self):
        """Return the category item URL."""

        template = "{{ item.category.name }}/{{ item.value }}"
        args = {"item": self}
        return Renderer.render_from_string(template, args)
Esempio n. 5
0
    def url(self):
        """Return the category URL."""

        template = "{{ category.name }}/index.html"
        args = {"category": self}
        return Renderer.render_from_string(template, args)
Esempio n. 6
0
    def test_render_from_string(self, page):
        string = "{{ page.name }}"
        text = Renderer.render_from_string(string, args={"page": page})

        assert text == "top_level_page"
Esempio n. 7
0
    def test_canonify_already_canonical(self):
        url = "https://www.website.com/relative/link/image.png"
        string = "{{ url|canonify('https://www.example.org') }}"
        text = Renderer.render_from_string(string, {"url": url})

        assert text == url
Esempio n. 8
0
    def test_canonify(self):
        url = "/relative/link/image.png"
        string = "{{ url|canonify('https://www.example.org') }}"
        text = Renderer.render_from_string(string, {"url": url})

        assert text == "https://www.example.org/relative/link/image.png"
Esempio n. 9
0
    def test_date(self, page):
        string = "{{ page|date('%Y--%m--%d') }}"
        text = Renderer.render_from_string(string, {"page": page})

        assert text == "2013--04--15"
Esempio n. 10
0
    def test_slug(self, page):
        string = "{{ page|slug }}"
        text = Renderer.render_from_string(string, {"page": page})

        assert text == "top"
Esempio n. 11
0
    def test_isoformat(self):
        string = "{{ '2010/01/01'|datetime|isoformat }}"
        text = Renderer.render_from_string(string)

        assert text == "2010-01-01T00:00:00"
Esempio n. 12
0
    def test_datetime(self):
        string = "{{ '2010/01/01'|datetime }}"
        text = Renderer.render_from_string(string)

        assert text == "2010-01-01 00:00:00"