Skip to content

Commit

Permalink
Merge pull request #1 from saschaludwig/saschaludwig-ci-test-1
Browse files Browse the repository at this point in the history
Migrate Project to FA6 and Django 4
  • Loading branch information
saschaludwig authored Feb 23, 2022
2 parents b4fdd31 + 59aa124 commit c30de9f
Show file tree
Hide file tree
Showing 35 changed files with 13,523 additions and 3,888 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Eslint
run: eslint src
- name: Stylelint
run: stylelint src
run: stylelint "src/**/*.scss"
- name: Build
run: npm run build:production
backend:
Expand All @@ -45,6 +45,6 @@ jobs:
pipenv install --deploy --system
pip install setuptools wheel
- name: Pylint
run: pylint fontawesome_5
run: pylint fontawesome_6
- name: Build
run: python setup.py sdist bdist_wheel
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
uses: actions/upload-artifact@v1
with:
name: js
path: fontawesome_5/static/fontawesome_5/js/django-fontawesome.js
path: fontawesome_6/static/fontawesome_6/js/django-fontawesome.js
- name: Upload css artifact
uses: actions/upload-artifact@v1
with:
name: css
path: fontawesome_5/static/fontawesome_5/css/django-fontawesome.css
path: fontawesome_6/static/fontawesome_6/css/django-fontawesome.css
backend:
name: Backend
needs: frontend
Expand All @@ -49,12 +49,12 @@ jobs:
uses: actions/download-artifact@v1
with:
name: js
path: fontawesome_5/static/fontawesome_5/js/
path: fontawesome_6/static/fontawesome_6/js/
- name: Download css artifact
uses: actions/download-artifact@v1
with:
name: css
path: fontawesome_5/static/fontawesome_5/css/
path: fontawesome_6/static/fontawesome_6/css/
- name: Build and publish
env:
TWINE_USERNAME: __token__
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ dmypy.json

# End of https://www.gitignore.io/api/node,python,visualstudiocode

fontawesome_5/static/fontawesome_5/css/django-fontawesome.css
fontawesome_5/static/fontawesome_5/js/django-fontawesome.js
fontawesome_6/static/fontawesome_6/css/django-fontawesome.css
fontawesome_6/static/fontawesome_6/js/django-fontawesome.js

**/.DS_Store
**/.idea
12 changes: 6 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
include LICENSE
include README.md
include fontawesome_5/icons.json
include fontawesome_5/icons_semantic_ui.json
recursive-include fontawesome_5 *.py
recursive-include fontawesome_5/static *
recursive-include fontawesome_5/templates *
recursive-include fontawesome_5/templatetags *
include fontawesome_6/icons.json
include fontawesome_6/icons_semantic_ui.json
recursive-include fontawesome_6 *.py
recursive-include fontawesome_6/static *
recursive-include fontawesome_6/templates *
recursive-include fontawesome_6/templatetags *
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,37 @@ This is a fork of https://github.com/BenjjinF/django-fontawesome-5 and I made so
I consider renaming this to django-fontawesome-6 in the near future and to provide a new python module.

---
# Not Maintained
I have not worked with Django in a long time & have no need for this project myself any longer. If you wish to take up the responsibility, please email me at [email protected].
# Semi-Maintained
This is a best-effort fork, I try to keep it up-to-date but can't promise any further development.

# django-fontawesome-5
# django-fontawesome-6

A utility for using icons in models, forms, and templates.
Does support Django 3.0, which *django-fontawesome* will not.
A utility for using icons in models, forms, and templates and supports Django 4.0.

![Clip of dropdown](https://github.com/BenjjinF/django-fontawesome/blob/master/docs/images/django-fontawesome-5.gif)
![Clip of dropdown](https://github.com/saschaludwig/django-fontawesome-6/blob/master/docs/images/django-fontawesome-5.gif)

## Migration guide from django-fontawesome

1. Remove all occurences of {% fontawesome_stylesheet %}
1. Replace {% load fontawesome %} with {% load fontawesome_5 %}
1. Replace '{% fontawesome_icon' with '{% fa5_icon'
1. Remove all occurences of {% fontawesome_stylesheet %}
1. Replace {% load fontawesome %} with {% load fontawesome_6 %}
1. Replace '{% fontawesome_icon' with '{% fa6_icon'
1. Replace iconnames, for example "bell" needs to be replaced with "bell fas" and "linedin-square" with "linkedin fab"

## Installation / Usage

pipenv install django-fontawesome-5
pipenv install django-fontawesome-6

Add 'fontawesome_5' to your installed `INSTALLED_APPS`:
Add 'fontawesome_6' to your installed `INSTALLED_APPS`:

INSTALLED_APPS = (
...
'fontawesome_5',
'fontawesome_6',
)


Import and use `IconField`:

from fontawesome_5.fields import IconField
from fontawesome_6.fields import IconField

class Category(models.Model):
...
Expand All @@ -44,24 +43,24 @@ Import and use `IconField`:

Include Static Files

{% load fontawesome_5 %}
{% load fontawesome_6 %}

<head>
{% fontawesome_5_static %}
{% fontawesome_6_static %}
...
</head>

## Settings

You can configure django-fontawesome to use another release/source/cdn by specifying::

FONTAWESOME_5_CSS = URL or None
default: 'fontawesome_5/css/django-fontawesome.css'
FONTAWESOME_5_CSS_ADMIN = URL or path
FONTAWESOME_6_CSS = URL or None
default: 'fontawesome_6/css/django-fontawesome.css'
FONTAWESOME_6_CSS_ADMIN = URL or path
default: None
FONTAWESOME_5_ICON_CLASS = 'default' or 'semantic_ui'
FONTAWESOME_6_ICON_CLASS = 'default' or 'semantic_ui'
default: 'default'
FONTAWESOME_5_PREFIX = 'custom_prefix'
FONTAWESOME_6_PREFIX = 'custom_prefix'
default: 'fa'

## Rendering
Expand All @@ -76,9 +75,9 @@ You can do a simple render in your template like this:

### Default Renderer

Or you can use the `{% fa5_icon %}` template tag.
Or you can use the `{% fa6_icon %}` template tag.

{% fa5_icon 'github' 'fab' %}
{% fa6_icon 'github' 'fab' %}

Positional arguments: `icon` (required), `style_prefix` (default: 'fas')

Expand Down Expand Up @@ -110,9 +109,9 @@ Positional arguments: `icon` (required), `style_prefix` (default: 'fas')

### Semantic UI Renderer

Or you can use the `{% fa5_icon %}` template tag.
Or you can use the `{% fa6_icon %}` template tag.

{% fa5_icon 'check' %}
{% fa6_icon 'check' %}

Required positional arguments: `icon`

Expand Down Expand Up @@ -147,9 +146,11 @@ Required positional arguments: `icon`

## Credit

Credit to https://github.com/redouane for the original ~
Credit to https://github.com/redouane for the original \
Also credit to https://github.com/BenjjinF for the django-fontawesome-5 version

## Changes
- refactored functions and classes
- Updated for use with Font Awesome 6
- Made compatible with Django 4
- forked from https://github.com/BenjjinF/django-fontawesome-5
Expand Down
35 changes: 0 additions & 35 deletions fontawesome_5/app_settings.py

This file was deleted.

1 change: 1 addition & 0 deletions fontawesome_5/__init__.py → fontawesome_6/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

renderer = get_icon_renderer()


class Icon:

def as_html(self, **kwargs):
Expand Down
35 changes: 35 additions & 0 deletions fontawesome_6/app_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from django.conf import settings
from django.templatetags.static import static


def get_prefix():
return getattr(settings, 'FONTAWESOME_6_PREFIX', 'fa')


def get_icon_renderer():
from .renderers import DefaultRenderer, SemanticUIRenderer # pylint: disable=import-outside-toplevel
renderers = {
'default': DefaultRenderer,
'semantic_ui': SemanticUIRenderer
}
return renderers[getattr(settings, 'FONTAWESOME_6_RENDERER', 'default')]


def get_fontawesome_6_css():
return getattr(settings, 'FONTAWESOME_6_CSS', static('fontawesome_6/css/all.min.css'))


def get_css():
css = [static('fontawesome_6/css/django-fontawesome.css'),]
fontawesome_6_css = get_fontawesome_6_css()
if fontawesome_6_css:
css.append(fontawesome_6_css)
return css


def get_css_admin():
css = [static('fontawesome_6/css/django-fontawesome.css'), static('fontawesome_6/css/all.min.css')]
css_admin = getattr(settings, 'FONTAWESOME_6_CSS_ADMIN', None)
if css_admin:
css.append(css_admin)
return css
File renamed without changes.
2 changes: 1 addition & 1 deletion fontawesome_5/forms.py → fontawesome_6/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def widget_attrs(self, widget):

return {
'class': ' '.join(classes),
'data-fontawesome-prefix':fontawesome_prefix
'data-fontawesome-prefix': fontawesome_prefix
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion fontawesome_5/models.py → fontawesome_6/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
try:
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], [
"^fontawesome_5\.fields\.IconField" # pylint: disable=anomalous-backslash-in-string
"^fontawesome_6\.fields\.IconField" # pylint: disable=anomalous-backslash-in-string
])
except ImportError:
pass
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@


@register.simple_tag
def fa5_icon(*args, **kwargs):
def fa6_icon(*args, **kwargs):
return Icon(*args, **kwargs).as_html()


@register.simple_tag
def fontawesome_5_static():
def fontawesome_6_static():
staticfiles = []

for stylesheet in css:
staticfiles.append(format_html(
'<link href="{}" rel="stylesheet" media="all">', stylesheet))

staticfiles.append(format_html(
'<script type="text/javascript" src="{}"></script>', static('fontawesome_5/js/django-fontawesome.js')
'<script type="text/javascript" src="{}"></script>', static('fontawesome_6/js/django-fontawesome.js')
))

return mark_safe(conditional_escape('\n').join(staticfiles))
2 changes: 1 addition & 1 deletion fontawesome_5/utils.py → fontawesome_6/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.conf import settings


renderer = getattr(settings, 'FONTAWESOME_5_RENDERER', 'default')
renderer = getattr(settings, 'FONTAWESOME_6_RENDERER', 'default')
path = 'icons_semantic_ui.json' if renderer == 'semantic_ui' else 'icons.json'


Expand Down
4 changes: 2 additions & 2 deletions fontawesome_5/widgets.py → fontawesome_6/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@


class IconWidget(forms.Select):
template_name = 'fontawesome_5/select.html'
template_name = 'fontawesome_6/select.html'

def __init__(self, attrs=None):
super(IconWidget, self).__init__(attrs, choices=CHOICES)

class Media:

js = (
'fontawesome_5/js/django-fontawesome.js',
'fontawesome_6/js/django-fontawesome.js',
)

css = {
Expand Down
Loading

0 comments on commit c30de9f

Please sign in to comment.