djangocms-icon


Namedjangocms-icon JSON
Version 2.1.0 PyPI version JSON
download
home_pagehttps://github.com/django-cms/djangocms-icon
SummaryAdds icon plugin to django CMS.
upload_time2023-12-06 10:44:24
maintainerDjango CMS Association and contributors
docs_urlNone
authorDivio AG
requires_python
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ===============
django CMS Icon
===============

|pypi| |coverage| |python| |django| |djangocms| |djangocms4|

**django CMS Icon** is a plugin for `django CMS <http://django-cms.org>`_
that allows you to insert an icon (font or svg) into your project.

.. note::

        This project is endorsed by the `django CMS Association <https://www.django-cms.org/en/about-us/>`_.
        That means that it is officially accepted by the dCA as being in line with our roadmap vision and development/plugin policy.
        Join us on `Slack <https://www.django-cms.org/slack/>`_.

.. image:: preview.gif


*******************************************
Contribute to this project and win rewards
*******************************************

Because this is a an open-source project, we welcome everyone to
`get involved in the project <https://www.django-cms.org/en/contribute/>`_ and
`receive a reward <https://www.django-cms.org/en/bounty-program/>`_ for their contribution.
Become part of a fantastic community and help us make django CMS the best CMS in the world.

We'll be delighted to receive your
feedback in the form of issues and pull requests. Before submitting your
pull request, please review our `contribution guidelines
<http://docs.django-cms.org/en/latest/contributing/index.html>`_.

We're grateful to all contributors who have helped create and maintain this package.
Contributors are listed at the `contributors <https://github.com/django-cms/djangocms-icon/graphs/contributors>`_
section.


Installation
------------

For a manual install:

* run ``pip install djangocms-icon``
* add ``djangocms_icon`` to your ``INSTALLED_APPS``
* run ``python manage.py migrate djangocms_icon``


**A note about django CMS Text CKEditor**

There are additional steps required for the icon plugin to display correctly
inside CKEditor.

1. You need to make sure your icon CSS is passed via CKEditors ``contentsCss``
`parameter <https://github.com/divio/djangocms-text-ckeditor/blob/175a1a444de8ca1ba4742196cb83150d45b5c505/aldryn_config.py#L36>`_.
On Divio Cloud this can be done through the Addons configuration.

2. CKEditor automatically removes empty tags, you can prevent this by adding
a `javascript configuration file <https://github.com/divio/djangocms-boilerplate-webpack/blob/master/static/js/addons/ckeditor.wysiwyg.js#L68>`_
to ``style_set``.

django CMS Icon does not add the styles or javascript files to your frontend, these need to be added at your discretion.


Configuration
-------------

This addon provides a ``default`` template for all instances. You can provide
additional template choices by adding a ``DJANGOCMS_ICON_TEMPLATES``
setting::

    DJANGOCMS_ICON_TEMPLATES = [
        ('svg', 'SVG template'),
    ]

Web Font Icons
##############

The django CMS Icon plugin ships with **Font Awesome 5 as default**. This can
be changed by overriding the following setting::

    DJANGOCMS_ICON_SETS = [
        ('fontawesome5regular', 'far', 'Font Awesome 5 Regular', 'lastest'),
        ('fontawesome5solid', 'fas', 'Font Awesome 5 Solid', 'lastest'),
        ('fontawesome5brands', 'fab', 'Font Awesome 5 Brands', 'lastest'),
    ]


In addition **you need to load** the resources for your fonts in
``/admin/djangocms_icon/includes/assets.html``. Add this file to your project
in order for the icon picker to pick up your custom icons in the admin.

The icon picker supports `numerous font libraries <http://victor-valencia.github.io/bootstrap-iconpicker/>`_
out of the box. You can also add multiple font sets like this::

    DJANGOCMS_ICON_SETS = [
        ('elusiveicon', 'el', 'Elusive Icons'),
        ('flagicon', 'flag-icon', 'Flag Icons'),
        ('fontawesome5regular', 'far', 'Font Awesome 5 Regular'),
        ('fontawesome5solid', 'fas', 'Font Awesome 5 Solid'),
        ('fontawesome5brands', 'fab', 'Font Awesome 5 Brands'),
        ('fontawesome5light', 'fal', 'Font Awesome 5 Light', '5.3.1_pro'),
        ('glyphicon', 'glyphicon', 'Glyphicons'),
        ('ionicon', 'ion', 'Ionicons Icons'),
        ('mapicon', 'map-icon', 'Map Icons'),
        ('materialdesign', 'zmdi', 'Material Design'),
        ('octicon', 'octicon', 'Octicons'),
        ('typicon', 'typcn', 'Typicons'),
        ('weathericon', 'wi', 'Weather Icons'),
    ]

You can also add the version number as a fourth parameter.
If no parameter is given the latest version of the bootstrap-iconpicker icon set is used.::

    DJANGOCMS_ICON_SETS = [
        ('fontawesome4', 'fa', 'Font Awesome 4', '4.0.0'),
        ('fontawesome5light', 'fal', 'Font Awesome 5 Light', '5.3.1_pro'),
    ]

Just don't forget to include both libraries in the ``assets.html`` file.
This is only necessary for the plugin rendering while selecting the icon.
You still need to implement the font libraries into your frontend stack.

Custom Web Font Icons
#####################

You can also add your own custom web fonts, for this you need to tell the
icon picker where to find the necessary files::

    DJANGOCMS_ICON_SETS = [
        (ICONSET, 'icon', 'Custom web font'),
    ]

In this example, we add our own font icon set on top of it. Please mind
that the second parameter needs to be the icon prefix. ``ICONSET`` is an
external reference to a JSON file at the root of your project setting up
your custom font icons, add this before::

    with open('iconset.json') as fh:
        ICONSET = fh.read()

Here an example of its content::

    {
        "iconClass": "icon",
        "icons": [
            "icon-icon1",
            "icon-icon2",
            "..."
        ]
    }

The ``iconClass`` refers to the second parameter in the settings file for the
icon prefix. Make sure both of them are the same. Instead of using an external
file you can also write the settings directly to the ``DJANGOCMS_ICON_SETS``
setting.

`djangocms-boilerplate-webpack <https://github.com/divio/djangocms-boilerplate-webpack/blob/master/tools/tasks/icons/json.js>`_
can generate the ``iconset.json`` automatically for you through ``gulp icons``.

Make sure the icons names contain the iconset prefix as shown in the example,
the widget will determine the iconset based on that. They can be omitted if only
one iconset is used.

Don't forget to also add your custom fonts to
``/admin/djangocms_icon/includes/assets.html`` into your project.

SVG Icons
#########

django CMS Icon also supports SVG icons. Follow the instructions from
`Custom Web Font Icons`_ and then adapt the JSON file a bit::

    {
        "svg": true,
        "spritePath": "sprites/icons.svg",
        "iconClass": "icon",
        "icons": [
            "icon-icon1",
            "icon-icon2",
            "..."
        ]
    }

``svg`` and ``spritePath`` are the only required additional properties. You
also need to add an icon template to your project to render it correctly,
for example::

    <span class="{{ instance.icon }} {{ instance.attributes.class }}">
        <svg role="presentation">
            <use xlink:href="{% static 'sprites/icons.svg' %}#{{ instance.icon }}"></use>
        </svg>
    </span>


Running Tests
-------------

You can run tests by executing::

    virtualenv env
    source env/bin/activate
    pip install -r tests/requirements.txt
    python setup.py test


.. |pypi| image:: https://badge.fury.io/py/djangocms-icon.svg
    :target: http://badge.fury.io/py/djangocms-icon
.. |coverage| image:: https://codecov.io/gh/django-cms/djangocms-icon/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/django-cms/djangocms-icon

.. |python| image:: https://img.shields.io/badge/python-3.8+-blue.svg
    :target: https://pypi.org/project/djangocms-icon/
.. |django| image:: https://img.shields.io/badge/django-3.2,%204.0-blue.svg
    :target: https://www.djangoproject.com/
.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.9%2B-blue.svg
    :target: https://www.django-cms.org/
.. |djangocms4| image:: https://img.shields.io/badge/django%20CMS-4-blue.svg
   :target: https://www.django-cms.org/en/preview-django-cms-40/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/django-cms/djangocms-icon",
    "name": "djangocms-icon",
    "maintainer": "Django CMS Association and contributors",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "info@django-cms.org",
    "keywords": "",
    "author": "Divio AG",
    "author_email": "info@divio.com",
    "download_url": "https://files.pythonhosted.org/packages/e1/0a/9acf8cdd473da05a672008962edc1bf2a82bddbf222704b50f06049cc8db/djangocms-icon-2.1.0.tar.gz",
    "platform": null,
    "description": "===============\ndjango CMS Icon\n===============\n\n|pypi| |coverage| |python| |django| |djangocms| |djangocms4|\n\n**django CMS Icon** is a plugin for `django CMS <http://django-cms.org>`_\nthat allows you to insert an icon (font or svg) into your project.\n\n.. note::\n\n        This project is endorsed by the `django CMS Association <https://www.django-cms.org/en/about-us/>`_.\n        That means that it is officially accepted by the dCA as being in line with our roadmap vision and development/plugin policy.\n        Join us on `Slack <https://www.django-cms.org/slack/>`_.\n\n.. image:: preview.gif\n\n\n*******************************************\nContribute to this project and win rewards\n*******************************************\n\nBecause this is a an open-source project, we welcome everyone to\n`get involved in the project <https://www.django-cms.org/en/contribute/>`_ and\n`receive a reward <https://www.django-cms.org/en/bounty-program/>`_ for their contribution.\nBecome part of a fantastic community and help us make django CMS the best CMS in the world.\n\nWe'll be delighted to receive your\nfeedback in the form of issues and pull requests. Before submitting your\npull request, please review our `contribution guidelines\n<http://docs.django-cms.org/en/latest/contributing/index.html>`_.\n\nWe're grateful to all contributors who have helped create and maintain this package.\nContributors are listed at the `contributors <https://github.com/django-cms/djangocms-icon/graphs/contributors>`_\nsection.\n\n\nInstallation\n------------\n\nFor a manual install:\n\n* run ``pip install djangocms-icon``\n* add ``djangocms_icon`` to your ``INSTALLED_APPS``\n* run ``python manage.py migrate djangocms_icon``\n\n\n**A note about django CMS Text CKEditor**\n\nThere are additional steps required for the icon plugin to display correctly\ninside CKEditor.\n\n1. You need to make sure your icon CSS is passed via CKEditors ``contentsCss``\n`parameter <https://github.com/divio/djangocms-text-ckeditor/blob/175a1a444de8ca1ba4742196cb83150d45b5c505/aldryn_config.py#L36>`_.\nOn Divio Cloud this can be done through the Addons configuration.\n\n2. CKEditor automatically removes empty tags, you can prevent this by adding\na `javascript configuration file <https://github.com/divio/djangocms-boilerplate-webpack/blob/master/static/js/addons/ckeditor.wysiwyg.js#L68>`_\nto ``style_set``.\n\ndjango CMS Icon does not add the styles or javascript files to your frontend, these need to be added at your discretion.\n\n\nConfiguration\n-------------\n\nThis addon provides a ``default`` template for all instances. You can provide\nadditional template choices by adding a ``DJANGOCMS_ICON_TEMPLATES``\nsetting::\n\n    DJANGOCMS_ICON_TEMPLATES = [\n        ('svg', 'SVG template'),\n    ]\n\nWeb Font Icons\n##############\n\nThe django CMS Icon plugin ships with **Font Awesome 5 as default**. This can\nbe changed by overriding the following setting::\n\n    DJANGOCMS_ICON_SETS = [\n        ('fontawesome5regular', 'far', 'Font Awesome 5 Regular', 'lastest'),\n        ('fontawesome5solid', 'fas', 'Font Awesome 5 Solid', 'lastest'),\n        ('fontawesome5brands', 'fab', 'Font Awesome 5 Brands', 'lastest'),\n    ]\n\n\nIn addition **you need to load** the resources for your fonts in\n``/admin/djangocms_icon/includes/assets.html``. Add this file to your project\nin order for the icon picker to pick up your custom icons in the admin.\n\nThe icon picker supports `numerous font libraries <http://victor-valencia.github.io/bootstrap-iconpicker/>`_\nout of the box. You can also add multiple font sets like this::\n\n    DJANGOCMS_ICON_SETS = [\n        ('elusiveicon', 'el', 'Elusive Icons'),\n        ('flagicon', 'flag-icon', 'Flag Icons'),\n        ('fontawesome5regular', 'far', 'Font Awesome 5 Regular'),\n        ('fontawesome5solid', 'fas', 'Font Awesome 5 Solid'),\n        ('fontawesome5brands', 'fab', 'Font Awesome 5 Brands'),\n        ('fontawesome5light', 'fal', 'Font Awesome 5 Light', '5.3.1_pro'),\n        ('glyphicon', 'glyphicon', 'Glyphicons'),\n        ('ionicon', 'ion', 'Ionicons Icons'),\n        ('mapicon', 'map-icon', 'Map Icons'),\n        ('materialdesign', 'zmdi', 'Material Design'),\n        ('octicon', 'octicon', 'Octicons'),\n        ('typicon', 'typcn', 'Typicons'),\n        ('weathericon', 'wi', 'Weather Icons'),\n    ]\n\nYou can also add the version number as a fourth parameter.\nIf no parameter is given the latest version of the bootstrap-iconpicker icon set is used.::\n\n    DJANGOCMS_ICON_SETS = [\n        ('fontawesome4', 'fa', 'Font Awesome 4', '4.0.0'),\n        ('fontawesome5light', 'fal', 'Font Awesome 5 Light', '5.3.1_pro'),\n    ]\n\nJust don't forget to include both libraries in the ``assets.html`` file.\nThis is only necessary for the plugin rendering while selecting the icon.\nYou still need to implement the font libraries into your frontend stack.\n\nCustom Web Font Icons\n#####################\n\nYou can also add your own custom web fonts, for this you need to tell the\nicon picker where to find the necessary files::\n\n    DJANGOCMS_ICON_SETS = [\n        (ICONSET, 'icon', 'Custom web font'),\n    ]\n\nIn this example, we add our own font icon set on top of it. Please mind\nthat the second parameter needs to be the icon prefix. ``ICONSET`` is an\nexternal reference to a JSON file at the root of your project setting up\nyour custom font icons, add this before::\n\n    with open('iconset.json') as fh:\n        ICONSET = fh.read()\n\nHere an example of its content::\n\n    {\n        \"iconClass\": \"icon\",\n        \"icons\": [\n            \"icon-icon1\",\n            \"icon-icon2\",\n            \"...\"\n        ]\n    }\n\nThe ``iconClass`` refers to the second parameter in the settings file for the\nicon prefix. Make sure both of them are the same. Instead of using an external\nfile you can also write the settings directly to the ``DJANGOCMS_ICON_SETS``\nsetting.\n\n`djangocms-boilerplate-webpack <https://github.com/divio/djangocms-boilerplate-webpack/blob/master/tools/tasks/icons/json.js>`_\ncan generate the ``iconset.json`` automatically for you through ``gulp icons``.\n\nMake sure the icons names contain the iconset prefix as shown in the example,\nthe widget will determine the iconset based on that. They can be omitted if only\none iconset is used.\n\nDon't forget to also add your custom fonts to\n``/admin/djangocms_icon/includes/assets.html`` into your project.\n\nSVG Icons\n#########\n\ndjango CMS Icon also supports SVG icons. Follow the instructions from\n`Custom Web Font Icons`_ and then adapt the JSON file a bit::\n\n    {\n        \"svg\": true,\n        \"spritePath\": \"sprites/icons.svg\",\n        \"iconClass\": \"icon\",\n        \"icons\": [\n            \"icon-icon1\",\n            \"icon-icon2\",\n            \"...\"\n        ]\n    }\n\n``svg`` and ``spritePath`` are the only required additional properties. You\nalso need to add an icon template to your project to render it correctly,\nfor example::\n\n    <span class=\"{{ instance.icon }} {{ instance.attributes.class }}\">\n        <svg role=\"presentation\">\n            <use xlink:href=\"{% static 'sprites/icons.svg' %}#{{ instance.icon }}\"></use>\n        </svg>\n    </span>\n\n\nRunning Tests\n-------------\n\nYou can run tests by executing::\n\n    virtualenv env\n    source env/bin/activate\n    pip install -r tests/requirements.txt\n    python setup.py test\n\n\n.. |pypi| image:: https://badge.fury.io/py/djangocms-icon.svg\n    :target: http://badge.fury.io/py/djangocms-icon\n.. |coverage| image:: https://codecov.io/gh/django-cms/djangocms-icon/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/django-cms/djangocms-icon\n\n.. |python| image:: https://img.shields.io/badge/python-3.8+-blue.svg\n    :target: https://pypi.org/project/djangocms-icon/\n.. |django| image:: https://img.shields.io/badge/django-3.2,%204.0-blue.svg\n    :target: https://www.djangoproject.com/\n.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.9%2B-blue.svg\n    :target: https://www.django-cms.org/\n.. |djangocms4| image:: https://img.shields.io/badge/django%20CMS-4-blue.svg\n   :target: https://www.django-cms.org/en/preview-django-cms-40/\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Adds icon plugin to django CMS.",
    "version": "2.1.0",
    "project_urls": {
        "Homepage": "https://github.com/django-cms/djangocms-icon"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dafb2fc689ed4b17570f6d2ded37c04f6bda5116930f6882927209398cca4bf1",
                "md5": "2c5f01756f9cb1409d22b26746450aac",
                "sha256": "be145e28c1f458fed5d96120a3147ff9373ea12540621e2ecf61a261b3b2af64"
            },
            "downloads": -1,
            "filename": "djangocms_icon-2.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2c5f01756f9cb1409d22b26746450aac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 164224,
            "upload_time": "2023-12-06T10:44:23",
            "upload_time_iso_8601": "2023-12-06T10:44:23.307143Z",
            "url": "https://files.pythonhosted.org/packages/da/fb/2fc689ed4b17570f6d2ded37c04f6bda5116930f6882927209398cca4bf1/djangocms_icon-2.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e10a9acf8cdd473da05a672008962edc1bf2a82bddbf222704b50f06049cc8db",
                "md5": "32f366347c3831eaa8b0a2003783962d",
                "sha256": "1a356c07e4fd89c31919f440300f9f3d80a951491a41545285fe5cf22e59d62d"
            },
            "downloads": -1,
            "filename": "djangocms-icon-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "32f366347c3831eaa8b0a2003783962d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 146329,
            "upload_time": "2023-12-06T10:44:24",
            "upload_time_iso_8601": "2023-12-06T10:44:24.795952Z",
            "url": "https://files.pythonhosted.org/packages/e1/0a/9acf8cdd473da05a672008962edc1bf2a82bddbf222704b50f06049cc8db/djangocms-icon-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-06 10:44:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "django-cms",
    "github_project": "djangocms-icon",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "djangocms-icon"
}
        
Elapsed time: 0.14770s