-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3997 All bases now use a common favicon template
- Loading branch information
Showing
6 changed files
with
32 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django import template | ||
|
||
from core.files import file_path_mime | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter | ||
def get_mime(file_field): | ||
""" | ||
Template tag to retrieve the MIME type of an ImageField or FileField. | ||
If the field has no path attribute application/octet-stream is returned | ||
as the default. | ||
Usage: {{ request.press.favicon|get_mime }} | ||
""" | ||
if file_field and hasattr(file_field, 'path'): | ||
return file_path_mime(file_field.path) | ||
return 'application/octet-stream' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% load mimetype %} | ||
|
||
{% if request.journal and request.journal.favicon %} | ||
<link rel="icon" href="{{ request.journal.favicon.url }}" type="{{ request.journal.favicon|get_mime }}"/> | ||
{% elif request.repository and request.repository.favicon %} | ||
<link rel="icon" href="{{ request.repository.favicon.url }}" type="{{ request.repository.favicon|get_mime }}"/> | ||
{% elif request.press and request.press.favicon %} | ||
<link rel="icon" href="{{ request.press.favicon.url }}" type="{{ request.press.favicon|get_mime }}"/> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters