kopia lustrzana https://github.com/OpenDroneMap/WebODM
SCSS theme file online compilation
rodzic
c4484ef317
commit
026d93cb79
|
@ -56,7 +56,7 @@ class ThemeModelForm(forms.ModelForm):
|
|||
|
||||
|
||||
class ThemeAdmin(admin.ModelAdmin):
|
||||
#list_display = ('id', 'description_en', 'description_ua', 'description_ru')
|
||||
form = ThemeModelForm
|
||||
|
||||
|
||||
admin.site.register(Theme, ThemeAdmin)
|
|
@ -1,5 +1,18 @@
|
|||
import logging
|
||||
|
||||
from app.models import Setting
|
||||
|
||||
logger = logging.getLogger('app.logger')
|
||||
|
||||
# Make the SETTINGS object available to all templates
|
||||
def load(request):
|
||||
return {'SETTINGS': Setting.objects.first()}
|
||||
def load(request=None):
|
||||
return {'SETTINGS': Setting.objects.first()}
|
||||
|
||||
# Helper function for libsass
|
||||
# Return a theme color from the currently selected theme
|
||||
def theme(color):
|
||||
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..
|
|
@ -1,8 +1,12 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from django.db.models import signals
|
||||
from django.db import models
|
||||
from django.dispatch import receiver
|
||||
from imagekit.models import ImageSpecField
|
||||
from imagekit.processors import ResizeToFit
|
||||
from pathlib import Path
|
||||
|
||||
from .theme import Theme
|
||||
|
||||
|
@ -27,4 +31,19 @@ class Setting(models.Model):
|
|||
help_text="Active theme")
|
||||
|
||||
def __str__(self):
|
||||
return "Application"
|
||||
return "Application"
|
||||
|
||||
|
||||
@receiver(signals.post_save, sender=Setting, dispatch_uid="setting_post_save")
|
||||
def setting_post_save(sender, instance, created, **kwargs):
|
||||
"""
|
||||
Touch theme.scss to invalidate its cache and force
|
||||
compressor to regenerate it
|
||||
"""
|
||||
theme_file = os.path.join('app', 'static', 'app', 'css', 'theme.scss')
|
||||
try:
|
||||
Path(theme_file).touch()
|
||||
logger.info("Touched {}".format(theme_file))
|
||||
except:
|
||||
logger.warning("Failed to touch {}".format(theme_file))
|
||||
|
||||
|
|
|
@ -36,4 +36,3 @@ class Theme(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
*{
|
||||
color: theme("primary");
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{% load i18n static settings %}
|
||||
{% load i18n static settings compress %}
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
@ -24,7 +24,10 @@
|
|||
|
||||
<title>{{title|default:"Login"}} - {{ SETTINGS.app_name }}</title>
|
||||
|
||||
{% include "theme.html" %}
|
||||
{% compress css %}
|
||||
<link rel="stylesheet" type="text/x-scss" href="{% static 'app/css/theme.scss' %}" />
|
||||
{% endcompress %}
|
||||
|
||||
<style type="text/css">
|
||||
{{ SETTINGS.theme.css|safe }}
|
||||
</style>
|
||||
|
|
|
@ -1,22 +1,7 @@
|
|||
{% extends "app/base.html" %}
|
||||
{% load i18n static %}
|
||||
|
||||
<!--{% if request.user.is_authenticated %}
|
||||
{% if user.is_superuser %}
|
||||
<li>
|
||||
<a class="page-scroll" href="/admin/">Admin Panel</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<a class="page-scroll" href="/logout/">Logout</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<a class="page-scroll" href="/login/">Login</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
-->
|
||||
|
||||
{% block navbar-top-links %}
|
||||
<ul class="nav navbar-top-links navbar-right">
|
||||
<!--<li class="dropdown">
|
||||
|
@ -271,9 +256,6 @@
|
|||
<li>
|
||||
<a href="/admin/"><i class="fa fa-gears fa-fw"></i> {% trans 'Administration' %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'admin:app_setting_change' SETTINGS.id %}"><i class="fa fa-paint-brush"></i> {% trans 'Customization' %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="/api/"><i class="fa fa-book fa-fw"></i> {% trans 'API' %}</a>
|
||||
|
@ -281,6 +263,20 @@
|
|||
<li>
|
||||
<a href="http://docs.webodm.org" target="_blank"><i class="fa fa-life-saver fa-fw"></i> {% trans 'Documentation' %}</a>
|
||||
</li>
|
||||
|
||||
{% if user.is_staff %}
|
||||
<li>
|
||||
<a href="#"><i class="fa fa-magic fa-fw"></i> {% trans 'Customize' %}<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li>
|
||||
<a href="{% url 'admin:app_setting_change' SETTINGS.id %}"><i class="fa fa-hand-o-right"></i> {% trans 'Brand' %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{% url 'admin:app_theme_change' SETTINGS.theme.id %}"><i class="fa fa-paint-brush"></i> {% trans 'Theme' %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /.sidebar-collapse -->
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<style type="text/css">
|
||||
*{
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
|
@ -6,11 +6,13 @@ Django==1.11.1
|
|||
django-appconf==1.0.2
|
||||
django-codemirror2==0.2
|
||||
django-colorfield==0.1.14
|
||||
django-compressor==2.2
|
||||
django-cors-headers==2.0.2
|
||||
django-debug-toolbar==1.6
|
||||
django-filter==1.0.4
|
||||
django-guardian==1.4.6
|
||||
django-imagekit==4.0.1
|
||||
django-libsass==0.7
|
||||
django-webpack-loader==0.3.3
|
||||
djangorestframework==3.6.3
|
||||
djangorestframework-jwt==1.9.0
|
||||
|
@ -19,6 +21,7 @@ funcsigs==1.0.2
|
|||
futures==3.0.5
|
||||
gunicorn==19.7.1
|
||||
itypes==1.1.0
|
||||
libsass==0.13.3
|
||||
Markdown==2.6.7
|
||||
openapi-codec==1.1.7
|
||||
packaging==16.8
|
||||
|
@ -29,8 +32,10 @@ psycopg2==2.6.2
|
|||
PyJWT==1.4.2
|
||||
pyparsing==2.1.10
|
||||
pytz==2017.2
|
||||
rcssmin==1.0.6
|
||||
requests==2.11.1
|
||||
rfc3987==1.3.7
|
||||
rjsmin==1.0.12
|
||||
simplejson==3.10.0
|
||||
six==1.10.0
|
||||
sqlparse==0.2.2
|
||||
|
|
|
@ -72,6 +72,7 @@ INSTALLED_APPS = [
|
|||
'colorfield',
|
||||
'imagekit',
|
||||
'codemirror2',
|
||||
'compressor',
|
||||
# 'debug_toolbar',
|
||||
'app',
|
||||
'nodeodm',
|
||||
|
@ -172,6 +173,11 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'build', 'static')
|
|||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'app', 'static'),
|
||||
]
|
||||
STATICFILES_FINDERS = [
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
'compressor.finders.CompressorFinder',
|
||||
]
|
||||
|
||||
# File Uploads
|
||||
FILE_UPLOAD_MAX_MEMORY_SIZE = 4718592 # 4.5 MB
|
||||
|
@ -274,6 +280,18 @@ JWT_AUTH = {
|
|||
'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=6),
|
||||
}
|
||||
|
||||
# Compressor
|
||||
COMPRESS_PRECOMPILERS = (
|
||||
('text/x-scss', 'django_libsass.SassCompiler'),
|
||||
)
|
||||
|
||||
# Sass
|
||||
def theme(color):
|
||||
from app.contexts.settings import theme as settings_theme
|
||||
return settings_theme(color)
|
||||
|
||||
LIBSASS_CUSTOM_FUNCTIONS = {'theme': theme}
|
||||
|
||||
if TESTING:
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'app', 'media_test')
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue