header logo

This commit is contained in:
Laura Klünder 2017-12-18 23:13:47 +01:00
parent ae4652529a
commit 4402ff9f54
6 changed files with 52 additions and 4 deletions

View file

@ -2,7 +2,7 @@
{% load i18n %}
{% block title %}{% trans 'c3nav control panel' %}{% endblock %}
{% block header_title %}{% trans 'c3nav control panel' %}{% endblock %}
{% block header_title %}{% trans 'control panel' %}{% endblock %}
{% block header_title_url %}{% url 'control.index' %}{% endblock %}
{% block content %}

View file

@ -280,6 +280,7 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'c3nav.site.context_processors.header_logo',
],
'loaders': template_loaders
},
@ -291,15 +292,16 @@ STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'compressor.finders.CompressorFinder',
'c3nav.site.finders.HeaderLogoFinder',
)
BOOTSTRAP3 = {
'success_css_class': '',
}
STATICFILES_DIRS = (
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'c3nav/static'),
)
]
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'django_libsass.SassCompiler'),
@ -312,6 +314,8 @@ COMPRESS_CSS_FILTERS = (
'compressor.filters.cssmin.CSSCompressorFilter',
)
HEADER_LOGO = config.get('c3nav', 'header_logo', fallback=None)
HEADER_LOGO_NAME = ('logo/'+os.path.basename(HEADER_LOGO)) if HEADER_LOGO else None
PRIMARY_COLOR = config.get('c3nav', 'primary_color', fallback='')
HEADER_BACKGROUND_COLOR = config.get('c3nav', 'header_background_color', fallback='')
HEADER_TEXT_COLOR = config.get('c3nav', 'header_text_color', fallback='')

View file

@ -0,0 +1,7 @@
from django.conf import settings
def header_logo(request):
return {
'header_logo': settings.HEADER_LOGO_NAME
}

20
src/c3nav/site/finders.py Normal file
View file

@ -0,0 +1,20 @@
import os
from django.conf import settings
from django.contrib.staticfiles.finders import BaseFinder
from django.core.files.storage import FileSystemStorage
class HeaderLogoFinder(BaseFinder):
def find(self, path, all=False):
if path == settings.HEADER_LOGO_NAME:
return [settings.HEADER_LOGO] if all else settings.HEADER_LOGO
return []
def list(self, ignore_patterns):
if not settings.HEADER_LOGO:
return []
basedir, filename = os.path.split(settings.HEADER_LOGO)
storage = FileSystemStorage(location=basedir)
storage.prefix = 'logo'
return [(filename, storage)]

View file

@ -47,6 +47,15 @@ header h1 {
}
header h1 a, header h1 a:hover {
color: $color-header-primary;
line-height: 50px;
display: block;
height: 50px;
}
header h1 img {
height: 50px;
vertical-align: top;
margin-left: -10px;
max-width: none;
}
header #user {
text-align: right;

View file

@ -18,7 +18,15 @@
<body>
{% if not embed %}
<header>
<h1><a href="{% block header_title_url %}/{% endblock %}">{% block header_title %}c3nav{% endblock %}</a></h1>
<h1><a href="{% block header_title_url %}/{% endblock %}">
{% spaceless %}
{% if header_logo %}
<img src="{% static header_logo %}">
{% else %}
c3nav
{% endif %}
{% endspaceless %}{% block header_title %}{% endblock %}
</a></h1>
<a href="/account/" id="user">
<span>{{ request.user_data.title }}</span>
<small>{% if request.user_data.subtitle %}{{ request.user_data.subtitle }}{% endif %}</small>