Skip to content

Comment

load(self, page_url=None, page_indentifier=None)

Load comment component resources.

Examples:

from flask import Flask
from flask_comment import Comment

app = Flask(__name__)
comment = Comment(app)

Parameters:

Name Type Description Default
page_url Optional[str]

The page url for Disqus, # noqa: B950 default to flask.request.base_url.

None
page_indentifier Optional[str]

The page indentifier for Disqus, # noqa: B950 default to flask.request.path.

None
Source code in flask_comment/__init__.py
def load(
    self,
    page_url: t.Optional[str] = None,
    page_indentifier: t.Optional[str] = None,
) -> t.Optional[Markup]:
    """
    Load comment component resources.

    Examples:

    ```py
    from flask import Flask
    from flask_comment import Comment

    app = Flask(__name__)
    comment = Comment(app)
    ```

    Arguments:
        page_url: The [page url](https://help.disqus.com/en/articles/1717084-javascript-configuration-variables) for Disqus, # noqa: B950
            default to [`flask.request.base_url`](https://flask.palletsprojects.com/en/latest/api/?highlight=base_url#flask.Request.base_url).

        page_indentifier: The [page indentifier](https://help.disqus.com/en/articles/1717084-javascript-configuration-variables) for Disqus, # noqa: B950
            default to [`flask.request.path`](https://flask.palletsprojects.com/en/latest/api/?highlight=request%20path#flask.Request.path).
    """
    if current_app.config['COMMENT_PLATFORM'] == DISQUS:
        return self._load_disqus(page_url, page_indentifier)
    if current_app.config['COMMENT_PLATFORM'] == CUSDIS:
        return self._load_cusdis()
    if current_app.config['COMMENT_PLATFORM'] == VALINE:
        return self._load_valine()
    if current_app.config['COMMENT_PLATFORM'] == UTTERANCES:
        return self._load_utterances()
    if current_app.config['COMMENT_PLATFORM'] == GITALK:
        return self._load_gitalk()
    return None  # pragma: no cover