add favicon support
This commit is contained in:
parent
2587f5f8ba
commit
a006d8a9ec
6 changed files with 49 additions and 18 deletions
|
@ -9,6 +9,9 @@
|
||||||
{% block meta %}
|
{% block meta %}
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="robots" content="NONE,NOARCHIVE" />
|
<meta name="robots" content="NONE,NOARCHIVE" />
|
||||||
|
{% if favicon %}
|
||||||
|
<link href="{% static favicon %}" rel="icon">
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block style %}
|
{% block style %}
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||||
<title>{% trans 'c3nav map editor' %}</title>
|
<title>{% trans 'c3nav map editor' %}</title>
|
||||||
|
{% if favicon %}
|
||||||
|
<link href="{% static favicon %}" rel="icon">
|
||||||
|
{% endif %}
|
||||||
{% compress css %}
|
{% compress css %}
|
||||||
<link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet">
|
<link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet">
|
||||||
<link href="{% static 'leaflet/leaflet.css' %}" rel="stylesheet">
|
<link href="{% static 'leaflet/leaflet.css' %}" rel="stylesheet">
|
||||||
|
|
|
@ -280,7 +280,7 @@ TEMPLATES = [
|
||||||
'django.template.context_processors.request',
|
'django.template.context_processors.request',
|
||||||
'django.contrib.auth.context_processors.auth',
|
'django.contrib.auth.context_processors.auth',
|
||||||
'django.contrib.messages.context_processors.messages',
|
'django.contrib.messages.context_processors.messages',
|
||||||
'c3nav.site.context_processors.header_logo',
|
'c3nav.site.context_processors.logos',
|
||||||
],
|
],
|
||||||
'loaders': template_loaders
|
'loaders': template_loaders
|
||||||
},
|
},
|
||||||
|
@ -292,7 +292,7 @@ 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',
|
'compressor.finders.CompressorFinder',
|
||||||
'c3nav.site.finders.HeaderLogoFinder',
|
'c3nav.site.finders.LogoFinder',
|
||||||
)
|
)
|
||||||
|
|
||||||
BOOTSTRAP3 = {
|
BOOTSTRAP3 = {
|
||||||
|
@ -315,7 +315,8 @@ COMPRESS_CSS_FILTERS = (
|
||||||
)
|
)
|
||||||
|
|
||||||
HEADER_LOGO = config.get('c3nav', 'header_logo', fallback=None)
|
HEADER_LOGO = config.get('c3nav', 'header_logo', fallback=None)
|
||||||
HEADER_LOGO_NAME = ('logo/'+os.path.basename(HEADER_LOGO)) if HEADER_LOGO else None
|
FAVICON = config.get('c3nav', 'favicon', fallback=None)
|
||||||
|
|
||||||
PRIMARY_COLOR = config.get('c3nav', 'primary_color', fallback='')
|
PRIMARY_COLOR = config.get('c3nav', 'primary_color', fallback='')
|
||||||
HEADER_BACKGROUND_COLOR = config.get('c3nav', 'header_background_color', fallback='')
|
HEADER_BACKGROUND_COLOR = config.get('c3nav', 'header_background_color', fallback='')
|
||||||
HEADER_TEXT_COLOR = config.get('c3nav', 'header_text_color', fallback='')
|
HEADER_TEXT_COLOR = config.get('c3nav', 'header_text_color', fallback='')
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
from django.conf import settings
|
import os
|
||||||
|
|
||||||
|
from c3nav.site.finders import logo_paths
|
||||||
|
|
||||||
def header_logo(request):
|
logos_result = {
|
||||||
return {
|
prefix: os.path.join(prefix, os.path.basename(path)) if path else None
|
||||||
'header_logo': settings.HEADER_LOGO_NAME
|
for prefix, path in logo_paths.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def logos(request):
|
||||||
|
return logos_result
|
||||||
|
|
|
@ -4,17 +4,33 @@ from django.conf import settings
|
||||||
from django.contrib.staticfiles.finders import BaseFinder
|
from django.contrib.staticfiles.finders import BaseFinder
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
|
|
||||||
|
logo_paths = {
|
||||||
|
'header_logo': settings.HEADER_LOGO,
|
||||||
|
'favicon': settings.FAVICON,
|
||||||
|
}
|
||||||
|
|
||||||
class HeaderLogoFinder(BaseFinder):
|
logofinder_results = {
|
||||||
|
os.path.join(prefix, os.path.basename(path)): path
|
||||||
|
for prefix, path in logo_paths.items()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class LogoFinder(BaseFinder):
|
||||||
def find(self, path, all=False):
|
def find(self, path, all=False):
|
||||||
if path == settings.HEADER_LOGO_NAME:
|
result = logofinder_results.get(path)
|
||||||
return [settings.HEADER_LOGO] if all else settings.HEADER_LOGO
|
if not result:
|
||||||
return []
|
return []
|
||||||
|
if all:
|
||||||
|
return [result]
|
||||||
|
return result
|
||||||
|
|
||||||
def list(self, ignore_patterns):
|
def list(self, ignore_patterns):
|
||||||
if not settings.HEADER_LOGO:
|
result = []
|
||||||
return []
|
for prefix, path in logo_paths.items():
|
||||||
basedir, filename = os.path.split(settings.HEADER_LOGO)
|
if not path:
|
||||||
|
continue
|
||||||
|
basedir, filename = os.path.split(path)
|
||||||
storage = FileSystemStorage(location=basedir)
|
storage = FileSystemStorage(location=basedir)
|
||||||
storage.prefix = 'logo'
|
storage.prefix = prefix
|
||||||
return [(filename, storage)]
|
result.append((filename, storage))
|
||||||
|
return result
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||||
<title>{% block title %}c3nav{% endblock %}</title>
|
<title>{% block title %}c3nav{% endblock %}</title>
|
||||||
|
{% if favicon %}
|
||||||
|
<link href="{% static favicon %}" rel="icon">
|
||||||
|
{% endif %}
|
||||||
{% compress css %}
|
{% compress css %}
|
||||||
<link href="{% static 'fonts/fonts.css' %}" rel="stylesheet">
|
<link href="{% static 'fonts/fonts.css' %}" rel="stylesheet">
|
||||||
<link href="{% static 'normalize/normalize.css' %}" rel="stylesheet">
|
<link href="{% static 'normalize/normalize.css' %}" rel="stylesheet">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue