add favicon support
This commit is contained in:
parent
2587f5f8ba
commit
a006d8a9ec
6 changed files with 49 additions and 18 deletions
|
@ -1,7 +1,12 @@
|
|||
from django.conf import settings
|
||||
import os
|
||||
|
||||
from c3nav.site.finders import logo_paths
|
||||
|
||||
logos_result = {
|
||||
prefix: os.path.join(prefix, os.path.basename(path)) if path else None
|
||||
for prefix, path in logo_paths.items()
|
||||
}
|
||||
|
||||
|
||||
def header_logo(request):
|
||||
return {
|
||||
'header_logo': settings.HEADER_LOGO_NAME
|
||||
}
|
||||
def logos(request):
|
||||
return logos_result
|
||||
|
|
|
@ -4,17 +4,33 @@ from django.conf import settings
|
|||
from django.contrib.staticfiles.finders import BaseFinder
|
||||
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):
|
||||
if path == settings.HEADER_LOGO_NAME:
|
||||
return [settings.HEADER_LOGO] if all else settings.HEADER_LOGO
|
||||
return []
|
||||
result = logofinder_results.get(path)
|
||||
if not result:
|
||||
return []
|
||||
if all:
|
||||
return [result]
|
||||
return result
|
||||
|
||||
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)]
|
||||
result = []
|
||||
for prefix, path in logo_paths.items():
|
||||
if not path:
|
||||
continue
|
||||
basedir, filename = os.path.split(path)
|
||||
storage = FileSystemStorage(location=basedir)
|
||||
storage.prefix = prefix
|
||||
result.append((filename, storage))
|
||||
return result
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||
<title>{% block title %}c3nav{% endblock %}</title>
|
||||
{% if favicon %}
|
||||
<link href="{% static favicon %}" rel="icon">
|
||||
{% endif %}
|
||||
{% compress css %}
|
||||
<link href="{% static 'fonts/fonts.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'normalize/normalize.css' %}" rel="stylesheet">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue