Add support for icon shadows

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-07-05 21:26:45 -04:00
parent b405896a44
commit a0331e0236
9 changed files with 167 additions and 38 deletions

View File

@@ -1,3 +1,7 @@
3.3 (2019-XX-XX)
================
* Add support for icon shadows.
3.2.5 (2019-07-05)
==================
* Don't error out if the EXTRA_APPS or the DISABLED_APPS settings

101
docs/releases/3.3.rst Normal file
View File

@@ -0,0 +1,101 @@
Version 3.3
===========
Released: XX XX, 2019
Changes
-------
- Add support for icon shadows.
Removals
--------
- None
Upgrading from a previous version
---------------------------------
If installed via Python's PIP
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Remove deprecated requirements::
$ curl https://gitlab.com/mayan-edms/mayan-edms/raw/master/removals.txt | pip uninstall -r /dev/stdin
Type in the console::
$ pip install mayan-edms==3.3
the requirements will also be updated automatically.
Using Git
^^^^^^^^^
If you installed Mayan EDMS by cloning the Git repository issue the commands::
$ git reset --hard HEAD
$ git pull
otherwise download the compressed archived and uncompress it overriding the
existing installation.
Remove deprecated requirements::
$ pip uninstall -y -r removals.txt
Next upgrade/add the new requirements::
$ pip install --upgrade -r requirements.txt
Common steps
^^^^^^^^^^^^
Perform these steps after updating the code from either step above.
Make a backup of your supervisord file::
sudo cp /etc/supervisor/conf.d/mayan.conf /etc/supervisor/conf.d/mayan.conf.bck
Update the supervisord configuration file. Replace the environment
variables values show here with your respective settings. This step will refresh
the supervisord configuration file with the new queues and the latest
recommended layout::
sudo MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=mayan \
MAYAN_DATABASE_PASSWORD=mayanuserpass MAYAN_DATABASE_USER=mayan \
MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=/opt/mayan-edms/media \
/opt/mayan-edms/bin/mayan-edms.py platformtemplate supervisord > /etc/supervisor/conf.d/mayan.conf
Edit the supervisord configuration file and update any setting the template
generator missed::
sudo vi /etc/supervisor/conf.d/mayan.conf
Migrate existing database schema with::
$ mayan-edms.py performupgrade
Add new static media::
$ mayan-edms.py preparestatic --noinput
The upgrade procedure is now complete.
Backward incompatible changes
-----------------------------
- None
Bugs fixed or issues closed
---------------------------
- :gitlab-issue:`XX`
.. _PyPI: https://pypi.python.org/pypi/mayan-edms/

View File

@@ -20,6 +20,7 @@ versions of the documentation contain the release notes for any later releases.
.. toctree::
:maxdepth: 1
3.3
3.2.5
3.2.4
3.2.3

View File

@@ -4,6 +4,7 @@ from django.template.loader import get_template
class IconDriver(object):
context = {}
_registry = {}
@classmethod
@@ -14,6 +15,17 @@ class IconDriver(object):
def register(cls, driver_class):
cls._registry[driver_class.name] = driver_class
def get_context(self):
return self.context
def render(self, extra_context=None):
context = self.get_context()
if extra_context:
context.update(extra_context)
return get_template(template_name=self.template_name).render(
context=context
)
class FontAwesomeDriver(IconDriver):
name = 'fontawesome'
@@ -22,10 +34,8 @@ class FontAwesomeDriver(IconDriver):
def __init__(self, symbol):
self.symbol = symbol
def render(self):
return get_template(template_name=self.template_name).render(
context={'symbol': self.symbol}
)
def get_context(self):
return {'symbol': self.symbol}
class FontAwesomeDualDriver(IconDriver):
@@ -36,23 +46,21 @@ class FontAwesomeDualDriver(IconDriver):
self.primary_symbol = primary_symbol
self.secondary_symbol = secondary_symbol
def render(self):
return get_template(template_name=self.template_name).render(
context={
'data': (
{
'class': 'fas fa-circle',
'transform': 'down-3 right-10',
'mask': 'fas fa-{}'.format(self.primary_symbol)
},
{'class': 'far fa-circle', 'transform': 'down-3 right-10'},
{
'class': 'fas fa-{}'.format(self.secondary_symbol),
'transform': 'shrink-4 down-3 right-10'
},
)
}
)
def get_context(self):
return {
'data': (
{
'class': 'fas fa-circle',
'transform': 'down-3 right-10',
'mask': 'fas fa-{}'.format(self.primary_symbol)
},
{'class': 'far fa-circle', 'transform': 'down-3 right-10'},
{
'class': 'fas fa-{}'.format(self.secondary_symbol),
'transform': 'shrink-4 down-3 right-10'
},
)
}
class FontAwesomeCSSDriver(IconDriver):
@@ -62,10 +70,8 @@ class FontAwesomeCSSDriver(IconDriver):
def __init__(self, css_classes):
self.css_classes = css_classes
def render(self):
return get_template(template_name=self.template_name).render(
context={'css_classes': self.css_classes}
)
def get_context(self):
return {'css_classes': self.css_classes}
class FontAwesomeMasksDriver(IconDriver):
@@ -75,23 +81,23 @@ class FontAwesomeMasksDriver(IconDriver):
def __init__(self, data):
self.data = data
def render(self):
return get_template(template_name=self.template_name).render(
context={'data': self.data}
)
def get_context(self):
return {'data': self.data}
class FontAwesomeLayersDriver(IconDriver):
name = 'fontawesome-layers'
template_name = 'appearance/icons/font_awesome_layers.html'
def __init__(self, data):
def __init__(self, data, shadow_class=None):
self.data = data
self.shadow_class = shadow_class
def render(self):
return get_template(template_name=self.template_name).render(
context={'data': self.data}
)
def get_context(self):
return {
'data': self.data,
'shadow_class': self.shadow_class,
}
class Icon(object):

View File

@@ -1,4 +1,7 @@
<span class="fa-layers fa-fw" style="margin-right: 7px;">
{% if enable_shadow %}
<i class="{{ shadow_class }}" data-fa-transform="right-1 down-2" style="color:rgba(0, 0, 0, 0.3); stroke: rgba(255, 255, 255, 0.3); stroke-width: 20;"></i>
{% endif %}
{% for entry in data %}
<i class="{{ entry.class }}" data-fa-transform="{{ entry.transform }}" data-fa-mask="{{ entry.mask }}"></i>
{% endfor %}

View File

@@ -1 +1,8 @@
<i class="fa fa-{{ symbol }}" style="padding-right: 5px; width: auto;"></i>
{% if enable_shadow %}
<span class="fa-layers fa-fw" >
<i class="fa fa-{{ symbol }}" data-fa-transform="right-1 down-2" style="color:rgba(0, 0, 0, 0.3);stroke: rgba(255, 255, 255, 0.3); stroke-width: 20;"></i>
<i class="fa fa-{{ symbol }}"></i>
</span>
{% else %}
<i class="fa fa-{{ symbol }}" style="padding-right: 5px; width: auto;"></i>
{% endif %}

View File

@@ -7,6 +7,11 @@ from django.utils.translation import ugettext_lazy as _
register = Library()
@register.simple_tag
def appearance_icon_render(icon_class, enable_shadow=False):
return icon_class.render(extra_context={'enable_shadow': enable_shadow})
@register.filter
def get_choice_value(field):
try:

View File

@@ -7,7 +7,7 @@ icon_document_type = Icon(
driver_name='fontawesome-layers', data=[
{'class': 'fas fa-circle', 'transform': 'shrink-12 up-2'},
{'class': 'fas fa-cog', 'transform': 'shrink-6 up-2', 'mask': 'fas fa-torah'}
]
], shadow_class='fas fa-torah'
)
icon_menu_documents = Icon(driver_name='fontawesome', symbol='book')

View File

@@ -1,6 +1,8 @@
{% load appearance_tags %}
<div class="{% if div_class %}{{ div_class }}{% else %}col-xs-12 col-sm-6 col-md-4 col-lg-3{% endif %}">
<a class="btn btn-default btn-lg btn-block {% if 'new_window' in link.tags %}new_window{% endif %}" href="{{ link.url }}">
{% if link.icon_class %}<span style="font-size: 200%;">{{ link.icon_class.render }}</span>{% endif %}
<a class="btn btn-primary btn-lg btn-block {% if 'new_window' in link.tags %}new_window{% endif %}" href="{{ link.url }}" style="">
{% if link.icon_class %}<span style="font-size: 200%;">{% appearance_icon_render link.icon_class enable_shadow=True %}</span>{% endif %}
<br>
{{ link.text }}
</a>