Add FontAwesome icons to StreamField.
Project description
Wagtail FontAwesome
====================
Add `FontAwesome <https://github.com/FortAwesome/Font-Awesome>`_ icons to StreamField.
.. image:: https://github.com/alexgleason/wagtailfontawesome/raw/master/screenshot.png
:alt: Screenshot
Install
-------
.. code-block:: shell
pip install wagtailfontawesome
Then add `wagtailfontawesome` to your installed apps.
Usage
-----
StreamField
~~~~~~~~~~~
Add FontAwesome icons to StreamField `the regular way <http://docs.wagtail.io/en/latest/topics/streamfield.html#basic-block-types>`_, just set `icon="fa-something"`. Reference `the full list <http://fontawesome.io/icons/>`_.
wagtailmodeladmin
~~~~~~~~~~~~~~~~~
`wagtailmodeladmin <https://github.com/rkhleics/wagtailmodeladmin>`_ is supported if you're using Wagtail 1.4 or above. Similar to StreamField, just set `icon="fa-something"` on your menu item.
Hallo plugins
~~~~~~~~~~~~~
You can use FontAwesome icons on custom Hallo buttons by setting the `icon` option to `icon icon-fa-something`.
.. code-block:: javascript
button.hallobutton({
label: "Blockquote",
icon: 'icon icon-fa-quote-left',
});
Other parts of the admin
~~~~~~~~~~~~~~~~~~~~~~~~
You can include icons anywhere in the admin with:
```html+django
<i class="icon icon-fa-something"></i>
.. code-block:: None
In Wagtail 1.3.x and below you can only use icons on the page editor screen.
### On the front-end
You can also include the CSS on the front end, and follow FontAwesome's documentation.
html+django
{% load wagtailfontawesome %}
{% fontawesome_css %}
.. code-block:: None
This will generate equivalent markup to:
html+django
<link rel="stylesheet" href="{% static 'wagtailfontawesome/css/fontawesome.css' %}">
.. code-block:: None
Then include icons anywhere on the front-end with:
html+django
<i class="fa fa-something"></i>
.. code-block:: None
### Using wagtailfontawesome as an optional dependency
If you want to distribute a Wagtail plugin with FontAwesome icons, you can use this package as an optional dependency by checking if it's installed in Django, and falling back otherwise.
python
from django.apps import apps
try:
from wagtail.core.blocks import StructBlock
except ImportError: # fallback for Wagtail <2.0
from wagtail.wagtailcore.blocks import StructBlock
class BlockquoteBlock(StructBlock):
quote = TextBlock()
author = TextBlock()
class Meta:
if apps.is_installed('wagtailfontawesome'):
icon = 'fa-quote-left'
```
(in this case, the fallback is to do nothing)
====================
Add `FontAwesome <https://github.com/FortAwesome/Font-Awesome>`_ icons to StreamField.
.. image:: https://github.com/alexgleason/wagtailfontawesome/raw/master/screenshot.png
:alt: Screenshot
Install
-------
.. code-block:: shell
pip install wagtailfontawesome
Then add `wagtailfontawesome` to your installed apps.
Usage
-----
StreamField
~~~~~~~~~~~
Add FontAwesome icons to StreamField `the regular way <http://docs.wagtail.io/en/latest/topics/streamfield.html#basic-block-types>`_, just set `icon="fa-something"`. Reference `the full list <http://fontawesome.io/icons/>`_.
wagtailmodeladmin
~~~~~~~~~~~~~~~~~
`wagtailmodeladmin <https://github.com/rkhleics/wagtailmodeladmin>`_ is supported if you're using Wagtail 1.4 or above. Similar to StreamField, just set `icon="fa-something"` on your menu item.
Hallo plugins
~~~~~~~~~~~~~
You can use FontAwesome icons on custom Hallo buttons by setting the `icon` option to `icon icon-fa-something`.
.. code-block:: javascript
button.hallobutton({
label: "Blockquote",
icon: 'icon icon-fa-quote-left',
});
Other parts of the admin
~~~~~~~~~~~~~~~~~~~~~~~~
You can include icons anywhere in the admin with:
```html+django
<i class="icon icon-fa-something"></i>
.. code-block:: None
In Wagtail 1.3.x and below you can only use icons on the page editor screen.
### On the front-end
You can also include the CSS on the front end, and follow FontAwesome's documentation.
html+django
{% load wagtailfontawesome %}
{% fontawesome_css %}
.. code-block:: None
This will generate equivalent markup to:
html+django
<link rel="stylesheet" href="{% static 'wagtailfontawesome/css/fontawesome.css' %}">
.. code-block:: None
Then include icons anywhere on the front-end with:
html+django
<i class="fa fa-something"></i>
.. code-block:: None
### Using wagtailfontawesome as an optional dependency
If you want to distribute a Wagtail plugin with FontAwesome icons, you can use this package as an optional dependency by checking if it's installed in Django, and falling back otherwise.
python
from django.apps import apps
try:
from wagtail.core.blocks import StructBlock
except ImportError: # fallback for Wagtail <2.0
from wagtail.wagtailcore.blocks import StructBlock
class BlockquoteBlock(StructBlock):
quote = TextBlock()
author = TextBlock()
class Meta:
if apps.is_installed('wagtailfontawesome'):
icon = 'fa-quote-left'
```
(in this case, the fallback is to do nothing)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wagtailfontawesome-1.1.2.tar.gz
(650.3 kB
view details)
Built Distribution
File details
Details for the file wagtailfontawesome-1.1.2.tar.gz
.
File metadata
- Download URL: wagtailfontawesome-1.1.2.tar.gz
- Upload date:
- Size: 650.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67ac2d01340ba27094de8290d42c24416afb5775ff7d1f9a0e32fa37311b59c3 |
|
MD5 | 3b12451cce93ffd72ce9df7470e2ae43 |
|
BLAKE2b-256 | de853657b2debbd65702d1863c1475d04d8f10294939d3605abe14fb815d830b |
File details
Details for the file wagtailfontawesome-1.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: wagtailfontawesome-1.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 654.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9baa547e086252ee4e33c731901633f3451072b5a8cd0f99de69411bed789f9e |
|
MD5 | 15cc22af109585877c5c96ac4ee15bc0 |
|
BLAKE2b-256 | 46f702b3bf810569b69116e2af7e12d1b0b68e98b36487fca084363ba0411a92 |