Skip to content
ActivityPub object

mkdocs_fedi_comments.link_maker

Creates links to pages

Parameters:

Name Type Description Default
base_url str
required
site_url str
required
Source code in mkdocs_fedi_comments/link_maker.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@dataclass
class LinkMaker:
    """Creates links to pages"""

    base_url: str
    site_url: str

    def ap_object(self, page_url: str):
        """Creates a link to the page object

        ```python
        >>> link_maker = LinkMaker("http://comments.example/", "http://site.example")
        >>> link_maker.ap_object("page.md")
        'http://comments.example/pages/aHR0cDovL3NpdGUuZXhhbXBsZS9wYWdlLm1k'

        ```
        """

        return self.base_url + "pages/" + encode_page(self.site_url, page_url)

    def comments(self, page_url: str):
        """Creates a link to the comments API call

        ```python
        >>> link_maker = LinkMaker("http://comments.example/", "http://site.example")
        >>> link_maker.comments("page.md")
        'http://comments.example/comments/aHR0cDovL3NpdGUuZXhhbXBsZS9wYWdlLm1k'

        ```
        """
        return self.base_url + "comments/" + encode_page(self.site_url, page_url)

    def fedi_actor(self):
        """Creates a link to the fedi_actor

        ```python
        >>> link_maker = LinkMaker("http://comments.example/", "http://site.example/path/")
        >>> link_maker.fedi_actor()
        'http://site.example/path/fedi-actor.json'

        ```
        """
        return urljoin(self.site_url, "fedi-actor.json")
ap_object(page_url: str)

Creates a link to the page object

>>> link_maker = LinkMaker("http://comments.example/", "http://site.example")
>>> link_maker.ap_object("page.md")
'http://comments.example/pages/aHR0cDovL3NpdGUuZXhhbXBsZS9wYWdlLm1k'
Source code in mkdocs_fedi_comments/link_maker.py
19
20
21
22
23
24
25
26
27
28
29
30
def ap_object(self, page_url: str):
    """Creates a link to the page object

    ```python
    >>> link_maker = LinkMaker("http://comments.example/", "http://site.example")
    >>> link_maker.ap_object("page.md")
    'http://comments.example/pages/aHR0cDovL3NpdGUuZXhhbXBsZS9wYWdlLm1k'

    ```
    """

    return self.base_url + "pages/" + encode_page(self.site_url, page_url)
comments(page_url: str)

Creates a link to the comments API call

>>> link_maker = LinkMaker("http://comments.example/", "http://site.example")
>>> link_maker.comments("page.md")
'http://comments.example/comments/aHR0cDovL3NpdGUuZXhhbXBsZS9wYWdlLm1k'
Source code in mkdocs_fedi_comments/link_maker.py
32
33
34
35
36
37
38
39
40
41
42
def comments(self, page_url: str):
    """Creates a link to the comments API call

    ```python
    >>> link_maker = LinkMaker("http://comments.example/", "http://site.example")
    >>> link_maker.comments("page.md")
    'http://comments.example/comments/aHR0cDovL3NpdGUuZXhhbXBsZS9wYWdlLm1k'

    ```
    """
    return self.base_url + "comments/" + encode_page(self.site_url, page_url)
fedi_actor()

Creates a link to the fedi_actor

>>> link_maker = LinkMaker("http://comments.example/", "http://site.example/path/")
>>> link_maker.fedi_actor()
'http://site.example/path/fedi-actor.json'
Source code in mkdocs_fedi_comments/link_maker.py
44
45
46
47
48
49
50
51
52
53
54
def fedi_actor(self):
    """Creates a link to the fedi_actor

    ```python
    >>> link_maker = LinkMaker("http://comments.example/", "http://site.example/path/")
    >>> link_maker.fedi_actor()
    'http://site.example/path/fedi-actor.json'

    ```
    """
    return urljoin(self.site_url, "fedi-actor.json")

Comments