Skip to content
Snippets Groups Projects
Commit 2e5420f4 authored by Elke Kreim's avatar Elke Kreim
Browse files

Add event on_modified to watchassets, execute changes for js-, css-, scss-files

parent cd10e53f
Branches
Tags v2.2.1
No related merge requests found
......@@ -13,6 +13,22 @@ from watchdog.observers import Observer
class AssetsHandler(events.FileSystemEventHandler):
def on_modified(self, event):
app_name = utils.get_appname_from_assets_path(event.src_path)
if not event.is_directory:
logger.info("Notice modification on file {}.".format(os.path.basename(event.src_path)))
file_extension = utils.get_file_extension(event.src_path)
if file_extension == 'css':
utils.copy_and_compile_assets_css_to_static(app_name)
elif file_extension == 'js':
utils.copy_and_compile_assets_js_to_static(app_name)
elif file_extension == 'scss':
utils.build_app_css_from_scss(app_name)
else:
logger.debug("Notice modification on file {} but do nothing.".format(os.path.basename(event.src_path)))
else:
logger.debug("Notice modification on directory {} but for now I do nothing. Maybe it will be implement in future.".format(os.path.basename(event.src_path)))
def on_created(self, event):
app_name = utils.get_appname_from_assets_path(event.src_path)
if not event.is_directory:
......
......@@ -9,7 +9,7 @@
{% block meta %}{% endblock %}
{% block extrahead %}
<link rel="icon" href="{% static 'hshassets/img/favicon.ico' %}">
<link rel="shortcut icon" href="{% static 'hshassets/img/favicon.ico' %}">
{% endblock %}
{% block pre-style %}{% endblock %}
......
......@@ -7,7 +7,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
setup(
name='django-hshassets',
version='2.2.0',
version='2.2.1',
packages=find_packages(),
include_package_data=True,
license='MIT License',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment