wagtail-links


Namewagtail-links JSON
Version 2.6.0 PyPI version JSON
download
home_pagehttps://gitlab.com/thelabnyc/wagtail-links
SummaryWagtail links provides a consistent way to refer to links in a wagtail page.
upload_time2023-10-11 16:19:45
maintainer
docs_urlNone
authorthelabnyc
requires_python
licenseISC
keywords django wagtail
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =============
Wagtail Links
=============

Purpose
=======

Wagtail links has two goals:

- Provide a consistent way to refer to links, which may be of different types, so as to reduce decision fatigue
- Minimize broken links as much as possible.



Install
=======

Install wagtail-links via Pip.

.. code:: bash

    pip install wagtail-links

Add ``wagtail_links`` to your Django project's INSTALLED_APPS setting.

Run database migrations.

.. code:: bash

    python manage.py migrate



Usage
=====

Add a foreign key to the page you wish to add links to.

.. code:: python

    my_link = models.ForeignKey(
        'wagtail_links.Link',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

Neat:

.. image:: admin.png

You may use it like:

.. code:: html

    <a href="{{ self.link.url }}">Link here</a>


From a template, you can also load a link by its name:

.. code:: html

    {% load get_wagtail_link_url from wagtail_links %}

    <a href="{% get_wagtail_link_url 'my-link' %}">Link here</a>

This is useful for global page links, navigation, etc.



Validation and logging
======================

The Link model will validate that one and only one field is set.
It will also disallow invalid Django reverse view names.

If a URL cannot be determined, we'll log the issue as a warning. We won't throw an exception as that would be bad for users. You are responsible for capturing this log warning, perhaps using Sentry.

For example - let's say you make a Django view name called admin:index. This would typically give you `/admin/`. Later the admin application is removed from the program, now this link fails. It will now display "" and generate a warning in your server logs.

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/thelabnyc/wagtail-links",
    "name": "wagtail-links",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django wagtail",
    "author": "thelabnyc",
    "author_email": "thelabdev@thelabnyc.com",
    "download_url": "https://files.pythonhosted.org/packages/86/43/00e3b5a37333482004941e31a9035483fa06d41c1b8304a03d139bc723c5/wagtail-links-2.6.0.tar.gz",
    "platform": null,
    "description": "=============\nWagtail Links\n=============\n\nPurpose\n=======\n\nWagtail links has two goals:\n\n- Provide a consistent way to refer to links, which may be of different types, so as to reduce decision fatigue\n- Minimize broken links as much as possible.\n\n\n\nInstall\n=======\n\nInstall wagtail-links via Pip.\n\n.. code:: bash\n\n    pip install wagtail-links\n\nAdd ``wagtail_links`` to your Django project's INSTALLED_APPS setting.\n\nRun database migrations.\n\n.. code:: bash\n\n    python manage.py migrate\n\n\n\nUsage\n=====\n\nAdd a foreign key to the page you wish to add links to.\n\n.. code:: python\n\n    my_link = models.ForeignKey(\n        'wagtail_links.Link',\n        null=True,\n        blank=True,\n        on_delete=models.SET_NULL,\n        related_name='+'\n    )\n\nNeat:\n\n.. image:: admin.png\n\nYou may use it like:\n\n.. code:: html\n\n    <a href=\"{{ self.link.url }}\">Link here</a>\n\n\nFrom a template, you can also load a link by its name:\n\n.. code:: html\n\n    {% load get_wagtail_link_url from wagtail_links %}\n\n    <a href=\"{% get_wagtail_link_url 'my-link' %}\">Link here</a>\n\nThis is useful for global page links, navigation, etc.\n\n\n\nValidation and logging\n======================\n\nThe Link model will validate that one and only one field is set.\nIt will also disallow invalid Django reverse view names.\n\nIf a URL cannot be determined, we'll log the issue as a warning. We won't throw an exception as that would be bad for users. You are responsible for capturing this log warning, perhaps using Sentry.\n\nFor example - let's say you make a Django view name called admin:index. This would typically give you `/admin/`. Later the admin application is removed from the program, now this link fails. It will now display \"\" and generate a warning in your server logs.\n",
    "bugtrack_url": null,
    "license": "ISC",
    "summary": "Wagtail links provides a consistent way to refer to links in a wagtail page.",
    "version": "2.6.0",
    "project_urls": {
        "Homepage": "https://gitlab.com/thelabnyc/wagtail-links"
    },
    "split_keywords": [
        "django",
        "wagtail"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7817e4169af8bdd5831665b17e477c6ca3ef2141ee73add5d7a7b262330ee776",
                "md5": "8e3d191120d8f09d14f39ee3540a42ff",
                "sha256": "ad21bba7387b745e4fb632b6d3249a51654b7520bc7b02a1d70a11c6f7343aa9"
            },
            "downloads": -1,
            "filename": "wagtail_links-2.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8e3d191120d8f09d14f39ee3540a42ff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14084,
            "upload_time": "2023-10-11T16:19:43",
            "upload_time_iso_8601": "2023-10-11T16:19:43.590066Z",
            "url": "https://files.pythonhosted.org/packages/78/17/e4169af8bdd5831665b17e477c6ca3ef2141ee73add5d7a7b262330ee776/wagtail_links-2.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "864300e3b5a37333482004941e31a9035483fa06d41c1b8304a03d139bc723c5",
                "md5": "55eead33b5dc86ae6587c2223fbb4037",
                "sha256": "d819e911dc7e4cb5deafbd9fc755eb729577481a7e8af50d2895e8d78412971d"
            },
            "downloads": -1,
            "filename": "wagtail-links-2.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "55eead33b5dc86ae6587c2223fbb4037",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9828,
            "upload_time": "2023-10-11T16:19:45",
            "upload_time_iso_8601": "2023-10-11T16:19:45.275004Z",
            "url": "https://files.pythonhosted.org/packages/86/43/00e3b5a37333482004941e31a9035483fa06d41c1b8304a03d139bc723c5/wagtail-links-2.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-11 16:19:45",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "thelabnyc",
    "gitlab_project": "wagtail-links",
    "lcname": "wagtail-links"
}
        
Elapsed time: 0.13406s