kopia lustrzana https://github.com/OpenDroneMap/WebODM
Remove django-compressor
rodzic
be8bd6e7ee
commit
f227bdb08b
|
@ -7,77 +7,3 @@ logger = logging.getLogger('app.logger')
|
||||||
# Make the SETTINGS object available to all templates
|
# Make the SETTINGS object available to all templates
|
||||||
def load(request=None):
|
def load(request=None):
|
||||||
return {'SETTINGS': Setting.objects.first()}
|
return {'SETTINGS': Setting.objects.first()}
|
||||||
|
|
||||||
# Helper functions for libsass
|
|
||||||
|
|
||||||
def theme(color):
|
|
||||||
"""Return a theme color from the currently selected theme"""
|
|
||||||
try:
|
|
||||||
return getattr(load()['SETTINGS'].theme, color)
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning("Cannot load configuration from theme(): " + e.message)
|
|
||||||
return "blue" # dah buh dih ah buh daa..
|
|
||||||
|
|
||||||
|
|
||||||
def complementary(hexcolor):
|
|
||||||
"""Returns complementary RGB color
|
|
||||||
Example: complementaryColor('#FFFFFF') --> '#000000'
|
|
||||||
"""
|
|
||||||
if hexcolor[0] == '#':
|
|
||||||
hexcolor = hexcolor[1:]
|
|
||||||
rgb = (hexcolor[0:2], hexcolor[2:4], hexcolor[4:6])
|
|
||||||
comp = ['%02X' % (255 - int(a, 16)) for a in rgb]
|
|
||||||
return '#' + ''.join(comp)
|
|
||||||
|
|
||||||
|
|
||||||
def scaleby(hexcolor, scalefactor, ignore_value = False):
|
|
||||||
"""
|
|
||||||
Scales a hex string by ``scalefactor``, but is color dependent, unless ignore_value is True
|
|
||||||
scalefactor is now always between 0 and 1. A value of 0.8
|
|
||||||
will cause bright colors to become darker and
|
|
||||||
dark colors to become brigther by 20%
|
|
||||||
"""
|
|
||||||
|
|
||||||
def calculate(hexcolor, scalefactor):
|
|
||||||
"""
|
|
||||||
Scales a hex string by ``scalefactor``. Returns scaled hex string.
|
|
||||||
To darken the color, use a float value between 0 and 1.
|
|
||||||
To brighten the color, use a float value greater than 1.
|
|
||||||
|
|
||||||
>>> colorscale("#DF3C3C", .5)
|
|
||||||
#6F1E1E
|
|
||||||
>>> colorscale("#52D24F", 1.6)
|
|
||||||
#83FF7E
|
|
||||||
>>> colorscale("#4F75D2", 1)
|
|
||||||
#4F75D2
|
|
||||||
"""
|
|
||||||
|
|
||||||
def clamp(val, minimum=0, maximum=255):
|
|
||||||
if val < minimum:
|
|
||||||
return minimum
|
|
||||||
if val > maximum:
|
|
||||||
return maximum
|
|
||||||
return int(val)
|
|
||||||
|
|
||||||
hexcolor = hexcolor.strip('#')
|
|
||||||
|
|
||||||
if scalefactor < 0 or len(hexcolor) != 6:
|
|
||||||
return hexcolor
|
|
||||||
|
|
||||||
r, g, b = int(hexcolor[:2], 16), int(hexcolor[2:4], 16), int(hexcolor[4:], 16)
|
|
||||||
|
|
||||||
r = clamp(r * scalefactor)
|
|
||||||
g = clamp(g * scalefactor)
|
|
||||||
b = clamp(b * scalefactor)
|
|
||||||
|
|
||||||
return "#%02x%02x%02x" % (r, g, b)
|
|
||||||
|
|
||||||
|
|
||||||
hexcolor = hexcolor.strip('#')
|
|
||||||
scalefactor = abs(float(scalefactor.value))
|
|
||||||
scalefactor = min(1.0, max(0, scalefactor))
|
|
||||||
|
|
||||||
r, g, b = int(hexcolor[:2], 16), int(hexcolor[2:4], 16), int(hexcolor[4:], 16)
|
|
||||||
value = max(r, g, b)
|
|
||||||
|
|
||||||
return calculate(hexcolor, scalefactor if ignore_value or value >= 127 else 2 - scalefactor)
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ from django.db import models
|
||||||
from colorfield.fields import ColorField
|
from colorfield.fields import ColorField
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.core.cache import cache
|
||||||
|
from django.core.cache.utils import make_template_fragment_key
|
||||||
|
|
||||||
from webodm import settings
|
from webodm import settings
|
||||||
|
|
||||||
|
@ -54,14 +56,5 @@ def theme_post_save(sender, instance, created, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def update_theme_css():
|
def update_theme_css():
|
||||||
"""
|
key = make_template_fragment_key("theme_css")
|
||||||
Touch theme.scss to invalidate its cache and force
|
cache.delete(key)
|
||||||
compressor to regenerate it
|
|
||||||
"""
|
|
||||||
|
|
||||||
theme_file = os.path.join('app', 'static', 'app', 'css', 'theme.scss')
|
|
||||||
try:
|
|
||||||
Path(theme_file).touch()
|
|
||||||
logger.info("Regenerate cache for {}".format(theme_file))
|
|
||||||
except:
|
|
||||||
logger.warning("Failed to touch {}".format(theme_file))
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
{% load i18n static settings compress plugins %}
|
{% load i18n cache static settings plugins %}
|
||||||
<!--
|
<!--
|
||||||
WebODM - User-friendly, commercial grade software for processing aerial imagery.
|
WebODM - User-friendly, commercial grade software for processing aerial imagery.
|
||||||
Copyright (C) 2020 WebODM Authors
|
Copyright (C) 2020 WebODM Authors
|
||||||
|
@ -51,9 +51,11 @@
|
||||||
|
|
||||||
<title>{{title|default:"Login"}} - {{ SETTINGS.app_name }}</title>
|
<title>{{title|default:"Login"}} - {{ SETTINGS.app_name }}</title>
|
||||||
|
|
||||||
{% compress css inline %}
|
{% cache 3600 theme_css %}
|
||||||
<link rel="stylesheet" type="text/x-scss" href="{% static 'app/css/theme.scss' %}" />
|
<style type="text/css">
|
||||||
{% endcompress %}
|
{% include "theme.css" %}
|
||||||
|
</style>
|
||||||
|
{% endcache %}
|
||||||
|
|
||||||
{% is_desktop_mode as desktop_mode %}
|
{% is_desktop_mode as desktop_mode %}
|
||||||
{% if desktop_mode %}
|
{% if desktop_mode %}
|
||||||
|
|
|
@ -0,0 +1,308 @@
|
||||||
|
{% load settings %}
|
||||||
|
{% theme "primary" as theme_primary %}
|
||||||
|
{% theme "secondary" as theme_secondary %}
|
||||||
|
{% theme "tertiary" as theme_tertiary %}
|
||||||
|
{% theme "button_primary" as theme_button_primary %}
|
||||||
|
{% theme "button_default" as theme_button_default %}
|
||||||
|
{% theme "button_danger" as theme_button_danger %}
|
||||||
|
{% theme "header_background" as theme_header_background %}
|
||||||
|
{% theme "header_primary" as theme_header_primary %}
|
||||||
|
{% theme "border" as theme_border %}
|
||||||
|
{% theme "highlight" as theme_highlight %}
|
||||||
|
{% theme "dialog_warning" as theme_dialog_warning %}
|
||||||
|
{% theme "success" as theme_success %}
|
||||||
|
{% theme "failed" as theme_failed %}
|
||||||
|
|
||||||
|
/* Primary */
|
||||||
|
body,
|
||||||
|
ul#side-menu.nav a,
|
||||||
|
.console,
|
||||||
|
.alert,
|
||||||
|
.form-control,
|
||||||
|
.dropdown-menu > li > a,
|
||||||
|
.theme-color-primary,
|
||||||
|
{
|
||||||
|
color: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
.theme-border-primary{
|
||||||
|
border-color: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
.tooltip{
|
||||||
|
.tooltip-inner{
|
||||||
|
background-color: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tooltip.left .tooltip-arrow{ border-left-color: {{ theme_primary }}; }
|
||||||
|
.tooltip.top .tooltip-arrow{ border-top-color: {{ theme_primary }}; }
|
||||||
|
.tooltip.bottom .tooltip-arrow{ border-bottom-color: {{ theme_primary }}; }
|
||||||
|
.tooltip.right .tooltip-arrow{ border-right-color: {{ theme_primary }}; }
|
||||||
|
|
||||||
|
.theme-fill-primary{
|
||||||
|
fill: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
.theme-stroke-primary{
|
||||||
|
stroke: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Secondary */
|
||||||
|
body,
|
||||||
|
.navbar-default,
|
||||||
|
.console,
|
||||||
|
.alert,
|
||||||
|
.modal-content,
|
||||||
|
.form-control,
|
||||||
|
.dropdown-menu,
|
||||||
|
.theme-secondary
|
||||||
|
{
|
||||||
|
background-color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.tooltip > .tooltip-inner{
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert.close:hover{
|
||||||
|
color: {% complementary theme_secondary %};
|
||||||
|
}
|
||||||
|
.alert.close:focus{
|
||||||
|
color: {% complementary theme_secondary %};
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination li > a,
|
||||||
|
.pagination .disabled > a,
|
||||||
|
.pagination .disabled > a:hover, .pagination .disabled > a:focus{
|
||||||
|
color: {% scaleby theme_primary 0.7 %};
|
||||||
|
background-color: {{ theme_secondary }};
|
||||||
|
border-color: {% scaleby theme_secondary 0.7 %};
|
||||||
|
}
|
||||||
|
.pagination li > a{
|
||||||
|
color: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
.theme-border-secondary-07{
|
||||||
|
border-color: {% scaleby theme_secondary 0.7 %} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary, .btn-secondary:active, .open>.dropdown-toggle.btn-secondary{
|
||||||
|
background-color: {{ theme_secondary }};
|
||||||
|
border-color: {{ theme_secondary }};
|
||||||
|
color: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover, .open>.dropdown-toggle.btn-secondary:hover,
|
||||||
|
.btn-secondary:active, .open>.dropdown-toggle.btn-secondary:active,
|
||||||
|
.btn-secondary:focus, .open>.dropdown-toggle.btn-secondary:focus{
|
||||||
|
background-color: {% scalebyiv theme_secondary 0.90 %};
|
||||||
|
border-color: {% scalebyiv theme_secondary 0.90 %};
|
||||||
|
color: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Tertiary */
|
||||||
|
a, a:hover, a:focus{
|
||||||
|
color: {{ theme_tertiary }};
|
||||||
|
}
|
||||||
|
.progress-bar-success{
|
||||||
|
background-color: {{ theme_tertiary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Button primary */
|
||||||
|
#navbar-top .navbar-top-links a:hover,
|
||||||
|
#navbar-top .navbar-top-links a:focus,
|
||||||
|
#navbar-top .navbar-top-links .open > a{
|
||||||
|
background-color: {{ theme_button_primary }};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
#navbar-top ul#side-menu a:focus{
|
||||||
|
background-color: inherit;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navbar-top ul#side-menu a:hover, #navbar-top ul#side-menu a.active:hover{
|
||||||
|
background-color: {{ theme_button_primary }};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary, .btn-primary:active, .btn-primary.active, .open>.dropdown-toggle.btn-primary{
|
||||||
|
background-color: {{ theme_button_primary }};
|
||||||
|
border-color: {{ theme_button_primary }};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover, .btn-primary.active:hover, .open>.dropdown-toggle.btn-primary:hover,
|
||||||
|
.btn-primary:active, .btn-primary.active:active, .open>.dropdown-toggle.btn-primary:active,
|
||||||
|
.btn-primary:focus, .btn-primary.active:focus, .open>.dropdown-toggle.btn-primary:focus,
|
||||||
|
.btn-primary[disabled]:hover, .btn-primary.active[disabled]:hover, .open>.dropdown-toggle.btn-primary[disabled]:hover,
|
||||||
|
.btn-primary[disabled]:focus, .btn-primary.active[disabled]:focus, .open>.dropdown-toggle.btn-primary[disabled]:focus,
|
||||||
|
.btn-primary[disabled]:active, .btn-primary.active[disabled]:active, .open>.dropdown-toggle.btn-primary[disabled]:active,
|
||||||
|
background-color: {% scalebyiv theme_button_primary 0.90 %};
|
||||||
|
border-color: {% scalebyiv theme_button_primary 0.90 %};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Button default */
|
||||||
|
.btn-default, .btn-default:active, .open>.dropdown-toggle.btn-default{
|
||||||
|
background-color: {{ theme_button_default }};
|
||||||
|
border-color: {{ theme_button_default }};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
|
||||||
|
}
|
||||||
|
.btn-default:hover, .open>.dropdown-toggle.btn-default:hover,
|
||||||
|
.btn-default:active, .open>.dropdown-toggle.btn-default:active,
|
||||||
|
.btn-default:focus, .open>.dropdown-toggle.btn-default:focus,
|
||||||
|
.btn-default[disabled]:hover, .open>.dropdown-toggle.btn-default[disabled]:hover,
|
||||||
|
.btn-default[disabled]:focus, .open>.dropdown-toggle.btn-default[disabled]:focus,
|
||||||
|
.btn-default[disabled]:active, .open>.dropdown-toggle.btn-default[disabled]:active{
|
||||||
|
background-color: {% scalebyiv theme_button_default 0.90 %};
|
||||||
|
border-color: {% scalebyiv theme_button_default 0.90 %};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination>.active>a, .pagination>.active>span, .pagination>.active>a:hover, .pagination>.active>span:hover, .pagination>.active>a:focus, .pagination>.active>span:focus,
|
||||||
|
.pagination .active > a:hover, .pagination .active > a:focus,
|
||||||
|
.pagination li > a:hover, .pagination li > a:focus{
|
||||||
|
background-color: {{ theme_button_default }};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Button danger */
|
||||||
|
.btn-danger, .btn-danger:active, .open>.dropdown-toggle.btn-danger{
|
||||||
|
background-color: {{ theme_button_danger }};
|
||||||
|
border-color: {{ theme_button_danger }};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
.btn-danger:hover, .open>.dropdown-toggle.btn-danger:hover,
|
||||||
|
.btn-danger:active, .open>.dropdown-toggle.btn-danger:active,
|
||||||
|
.btn-danger:focus, .open>.dropdown-toggle.btn-danger:focus,
|
||||||
|
.btn-danger[disabled]:hover, .open>.dropdown-toggle.btn-danger[disabled]:hover,
|
||||||
|
.btn-danger[disabled]:active, .open>.dropdown-toggle.btn-danger[disabled]:active,
|
||||||
|
.btn-danger[disabled]:focus, .open>.dropdown-toggle.btn-danger[disabled]:focus{
|
||||||
|
background-color: {% scalebyiv theme_button_danger 0.90 %};
|
||||||
|
border-color: {% scalebyiv theme_button_danger 0.90 %};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-color-button-danger{
|
||||||
|
color: {{ theme_button_danger }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-color-button-primary{
|
||||||
|
color: {{ theme_button_primary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header background */
|
||||||
|
#navbar-top{
|
||||||
|
background-color: {{ theme_header_background }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header primary */
|
||||||
|
.navbar-default .navbar-link,
|
||||||
|
#navbar-top .navbar-top-links a.dropdown-toggle,
|
||||||
|
#navbar-top .navbar-text{
|
||||||
|
color: {{ theme_header_primary }};
|
||||||
|
}
|
||||||
|
.navbar-default .navbar-link:hover,
|
||||||
|
#navbar-top .navbar-top-links a.dropdown-toggle:hover{
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Border */
|
||||||
|
.sidebar ul li,
|
||||||
|
.project-list-item,
|
||||||
|
#page-wrapper,
|
||||||
|
table-bordered>thead>tr>th, .table-bordered>thead>tr>th, table-bordered>tbody>tr>th, .table-bordered>tbody>tr>th, table-bordered>tfoot>tr>th, .table-bordered>tfoot>tr>th, table-bordered>thead>tr>td, .table-bordered>thead>tr>td, table-bordered>tbody>tr>td, .table-bordered>tbody>tr>td, table-bordered>tfoot>tr>td, .table-bordered>tfoot>tr>td,
|
||||||
|
footer,
|
||||||
|
.modal-content,
|
||||||
|
.modal-header,
|
||||||
|
.modal-footer,
|
||||||
|
.dropdown-menu
|
||||||
|
{
|
||||||
|
border-color: {{ theme_border }};
|
||||||
|
}
|
||||||
|
.dropdown-menu .divider{
|
||||||
|
background-color: {{ theme_border }};
|
||||||
|
}
|
||||||
|
.popover-title{
|
||||||
|
border-bottom-color: {{ theme_border }};
|
||||||
|
}
|
||||||
|
.theme-border{
|
||||||
|
border-color: {{ theme_border }} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Highlight */
|
||||||
|
.task-list-item:nth-child(odd),
|
||||||
|
.table-striped>tbody>tr:nth-of-type(odd),
|
||||||
|
select.form-control option[disabled],
|
||||||
|
.theme-background-highlight{
|
||||||
|
background-color: {{ theme_highlight }};
|
||||||
|
}
|
||||||
|
.dropdown-menu > li > a:hover,
|
||||||
|
.dropdown-menu > li > a:focus{
|
||||||
|
background-color: {{ theme_highlight }};
|
||||||
|
color: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
pre.prettyprint,
|
||||||
|
.form-control{
|
||||||
|
border-color: {{ theme_highlight }};
|
||||||
|
}
|
||||||
|
pre.prettyprint:focus,
|
||||||
|
.form-control:focus
|
||||||
|
border-color: {% scalebyiv theme_highlight 0.7 %};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dialog warning */
|
||||||
|
.alert-warning{
|
||||||
|
border-color: {{ theme_dialog_warning }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Success */
|
||||||
|
.task-list-item .status-label.done, .theme-background-success{
|
||||||
|
background-color: {{ theme_success }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Failed */
|
||||||
|
.task-list-item .status-label.error, .theme-background-failed{
|
||||||
|
background-color: {{ theme_failed }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ModelView.jsx specific */
|
||||||
|
.model-view #potree_sidebar_container .dropdown-menu > li > a{
|
||||||
|
color: {{ theme_primary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* MapView.jsx specific */
|
||||||
|
.leaflet-bar a, .leaflet-control > a{
|
||||||
|
background-color: {{ theme_secondary }} !important;
|
||||||
|
border-color: {{ theme_secondary }} !important;
|
||||||
|
color: {{ theme_primary }} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-bar a:hover, .leaflet-control > a:hover{
|
||||||
|
background-color: {% scalebyiv theme_secondary 0.90 %} !important;
|
||||||
|
border-color: {% scalebyiv theme_secondary 0.90 %} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-popup-content-wrapper{
|
||||||
|
background-color: {{ theme_secondary }} !important;
|
||||||
|
color: {{ theme_primary }} !important;
|
||||||
|
}
|
||||||
|
.leaflet-popup-content-wrapper a{
|
||||||
|
color: {{ theme_tertiary }} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leaflet-container a.leaflet-popup-close-button{
|
||||||
|
color: {{ theme_primary }} !important;
|
||||||
|
}
|
||||||
|
.leaflet-container a.leaflet-popup-close-button:hover{
|
||||||
|
color: {% complementary theme_secondary %} !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-badge{
|
||||||
|
background-color: {{ theme_button_default }};
|
||||||
|
border-color: {{ theme_button_default }};
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag-badge a, .tag-badge a:hover{
|
||||||
|
color: {{ theme_secondary }};
|
||||||
|
}
|
|
@ -112,3 +112,80 @@ def get_footer(context):
|
||||||
return "<footer>" + \
|
return "<footer>" + \
|
||||||
footer + \
|
footer + \
|
||||||
"</footer>"
|
"</footer>"
|
||||||
|
|
||||||
|
@register.simple_tag(takes_context=True)
|
||||||
|
def theme(context, color):
|
||||||
|
"""Return a theme color from the currently selected theme"""
|
||||||
|
try:
|
||||||
|
return getattr(context['SETTINGS'].theme, color)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning("Cannot load configuration from theme(): " + str(e))
|
||||||
|
return "blue" # dah buh dih ah buh daa..
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def complementary(hexcolor):
|
||||||
|
"""Returns complementary RGB color
|
||||||
|
Example: complementaryColor('#FFFFFF') --> '#000000'
|
||||||
|
"""
|
||||||
|
if hexcolor[0] == '#':
|
||||||
|
hexcolor = hexcolor[1:]
|
||||||
|
rgb = (hexcolor[0:2], hexcolor[2:4], hexcolor[4:6])
|
||||||
|
comp = ['%02X' % (255 - int(a, 16)) for a in rgb]
|
||||||
|
return '#' + ''.join(comp)
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def scaleby(hexcolor, scalefactor, ignore_value = False):
|
||||||
|
"""
|
||||||
|
Scales a hex string by ``scalefactor``, but is color dependent, unless ignore_value is True
|
||||||
|
scalefactor is now always between 0 and 1. A value of 0.8
|
||||||
|
will cause bright colors to become darker and
|
||||||
|
dark colors to become brigther by 20%
|
||||||
|
"""
|
||||||
|
|
||||||
|
def calculate(hexcolor, scalefactor):
|
||||||
|
"""
|
||||||
|
Scales a hex string by ``scalefactor``. Returns scaled hex string.
|
||||||
|
To darken the color, use a float value between 0 and 1.
|
||||||
|
To brighten the color, use a float value greater than 1.
|
||||||
|
|
||||||
|
>>> colorscale("#DF3C3C", .5)
|
||||||
|
#6F1E1E
|
||||||
|
>>> colorscale("#52D24F", 1.6)
|
||||||
|
#83FF7E
|
||||||
|
>>> colorscale("#4F75D2", 1)
|
||||||
|
#4F75D2
|
||||||
|
"""
|
||||||
|
|
||||||
|
def clamp(val, minimum=0, maximum=255):
|
||||||
|
if val < minimum:
|
||||||
|
return minimum
|
||||||
|
if val > maximum:
|
||||||
|
return maximum
|
||||||
|
return int(val)
|
||||||
|
|
||||||
|
hexcolor = hexcolor.strip('#')
|
||||||
|
|
||||||
|
if scalefactor < 0 or len(hexcolor) != 6:
|
||||||
|
return hexcolor
|
||||||
|
|
||||||
|
r, g, b = int(hexcolor[:2], 16), int(hexcolor[2:4], 16), int(hexcolor[4:], 16)
|
||||||
|
|
||||||
|
r = clamp(r * scalefactor)
|
||||||
|
g = clamp(g * scalefactor)
|
||||||
|
b = clamp(b * scalefactor)
|
||||||
|
|
||||||
|
return "#%02x%02x%02x" % (r, g, b)
|
||||||
|
|
||||||
|
|
||||||
|
hexcolor = hexcolor.strip('#')
|
||||||
|
scalefactor = abs(float(scalefactor))
|
||||||
|
scalefactor = min(1.0, max(0, scalefactor))
|
||||||
|
|
||||||
|
r, g, b = int(hexcolor[:2], 16), int(hexcolor[2:4], 16), int(hexcolor[4:], 16)
|
||||||
|
value = max(r, g, b)
|
||||||
|
|
||||||
|
return calculate(hexcolor, scalefactor if ignore_value or value >= 127 else 2 - scalefactor)
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def scalebyiv(hexcolor, scalefactor):
|
||||||
|
return scaleby(hexcolor, scalefactor, True)
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "WebODM",
|
"name": "WebODM",
|
||||||
"version": "2.4.0",
|
"version": "2.4.1",
|
||||||
"description": "User-friendly, extendable application and API for processing aerial imagery.",
|
"description": "User-friendly, extendable application and API for processing aerial imagery.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -8,7 +8,6 @@ Django==2.2.27
|
||||||
django-appconf==1.0.2
|
django-appconf==1.0.2
|
||||||
django-codemirror2==0.2
|
django-codemirror2==0.2
|
||||||
django-colorfield==0.1.15
|
django-colorfield==0.1.15
|
||||||
django-compressor==2.2
|
|
||||||
django-cors-headers==3.0.2
|
django-cors-headers==3.0.2
|
||||||
django-filter==2.4.0
|
django-filter==2.4.0
|
||||||
django-guardian==1.4.9
|
django-guardian==1.4.9
|
||||||
|
|
|
@ -114,7 +114,6 @@ INSTALLED_APPS = [
|
||||||
'colorfield',
|
'colorfield',
|
||||||
'imagekit',
|
'imagekit',
|
||||||
'codemirror2',
|
'codemirror2',
|
||||||
'compressor',
|
|
||||||
'app',
|
'app',
|
||||||
'nodeodm',
|
'nodeodm',
|
||||||
]
|
]
|
||||||
|
@ -199,7 +198,6 @@ STATICFILES_DIRS = [
|
||||||
STATICFILES_FINDERS = [
|
STATICFILES_FINDERS = [
|
||||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||||
'compressor.finders.CompressorFinder',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# File Uploads
|
# File Uploads
|
||||||
|
@ -334,41 +332,6 @@ JWT_AUTH = {
|
||||||
'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=6),
|
'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=6),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Compressor
|
|
||||||
COMPRESS_PRECOMPILERS = (
|
|
||||||
('text/x-scss', 'django_libsass.SassCompiler'),
|
|
||||||
)
|
|
||||||
COMPRESS_ENABLED = True
|
|
||||||
COMPRESS_MTIME_DELAY = 0
|
|
||||||
|
|
||||||
# Sass
|
|
||||||
def theme(color):
|
|
||||||
from app.contexts.settings import theme as f
|
|
||||||
return f(color)
|
|
||||||
|
|
||||||
|
|
||||||
def complementary(color):
|
|
||||||
from app.contexts.settings import complementary as f
|
|
||||||
return f(color)
|
|
||||||
|
|
||||||
|
|
||||||
def scaleby(color, n):
|
|
||||||
from app.contexts.settings import scaleby as f
|
|
||||||
return f(color, n)
|
|
||||||
|
|
||||||
|
|
||||||
def scalebyiv(color, n):
|
|
||||||
from app.contexts.settings import scaleby as f
|
|
||||||
return f(color, n, True)
|
|
||||||
|
|
||||||
|
|
||||||
LIBSASS_CUSTOM_FUNCTIONS = {
|
|
||||||
'theme': theme,
|
|
||||||
'complementary': complementary,
|
|
||||||
'scaleby': scaleby,
|
|
||||||
'scalebyiv': scalebyiv
|
|
||||||
}
|
|
||||||
|
|
||||||
# Celery
|
# Celery
|
||||||
CELERY_BROKER_URL = os.environ.get('WO_BROKER', 'redis://localhost')
|
CELERY_BROKER_URL = os.environ.get('WO_BROKER', 'redis://localhost')
|
||||||
CELERY_RESULT_BACKEND = os.environ.get('WO_BROKER', 'redis://localhost')
|
CELERY_RESULT_BACKEND = os.environ.get('WO_BROKER', 'redis://localhost')
|
||||||
|
@ -389,6 +352,12 @@ CACHES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if DEBUG:
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Number of minutes a processing node hasn't been seen
|
# Number of minutes a processing node hasn't been seen
|
||||||
# before it should be considered offline
|
# before it should be considered offline
|
||||||
|
|
Ładowanie…
Reference in New Issue