Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Django Favicon Plus Reloaded
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
Django Favicon Plus Reloaded
Commits
1a7e3b8f
Commit
1a7e3b8f
authored
9 years ago
by
Basil Shubin
Browse files
Options
Downloads
Patches
Plain Diff
Update favtags.py
parent
03af98c1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
favicon/templatetags/favtags.py
+5
-11
5 additions, 11 deletions
favicon/templatetags/favtags.py
with
5 additions
and
11 deletions
favicon/templatetags/favtags.py
+
5
−
11
View file @
1a7e3b8f
from
django
import
template
from
django
import
template
from
favicon.models
import
Favicon
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
...
@@ -8,8 +7,6 @@ from favicon.models import config
...
@@ -8,8 +7,6 @@ from favicon.models import config
register
=
template
.
Library
()
register
=
template
.
Library
()
media_url
=
getattr
(
settings
,
'
MEDIA_URL
'
,
False
)
@register.simple_tag
(
takes_context
=
True
)
@register.simple_tag
(
takes_context
=
True
)
def
placeFavicon
(
context
):
def
placeFavicon
(
context
):
...
@@ -19,11 +16,8 @@ def placeFavicon(context):
...
@@ -19,11 +16,8 @@ def placeFavicon(context):
Template Syntax:
Template Syntax:
{% placeFavicon %}
{% placeFavicon %}
"""
if
not
media_url
:
raise
ImproperlyConfigured
(
'
MEDIA_URL not found in settings
'
)
"""
fav
=
Favicon
.
objects
.
filter
(
isFavicon
=
True
)
fav
=
Favicon
.
objects
.
filter
(
isFavicon
=
True
)
if
not
fav
:
if
not
fav
:
return
'
<!-- no favicon -->
'
return
'
<!-- no favicon -->
'
...
@@ -56,11 +50,11 @@ def placeFavicon(context):
...
@@ -56,11 +50,11 @@ def placeFavicon(context):
for
rel
in
config
:
for
rel
in
config
:
for
size
in
sorted
(
config
[
rel
],
reverse
=
True
):
for
size
in
sorted
(
config
[
rel
],
reverse
=
True
):
n
=
fav
.
get_favicon
(
size
=
size
,
rel
=
rel
)
n
=
fav
.
get_favicon
(
size
=
size
,
rel
=
rel
)
html
+=
'
<link rel=
"
%s
"
size =
"
%sx%s
"
href=
"
%s
%s
"
/>
'
%
(
html
+=
'
<link rel=
"
%s
"
size =
"
%sx%s
"
href=
"
%s
"
/>
'
%
(
n
.
rel
,
n
.
size
,
n
.
size
,
media_url
,
n
.
faviconImage
.
name
)
n
.
rel
,
n
.
size
,
n
.
size
,
n
.
faviconImage
.
url
)
default_fav
=
fav
.
get_favicon
(
size
=
32
,
rel
=
'
shortcut icon
'
)
default_fav
=
fav
.
get_favicon
(
size
=
32
,
rel
=
'
shortcut icon
'
)
html
+=
'
<link rel=
"
%s
"
size =
"
%sx%s
"
href=
"
%s
%s
"
/>
'
%
(
html
+=
'
<link rel=
"
%s
"
size =
"
%sx%s
"
href=
"
%s
"
/>
'
%
(
default_fav
.
rel
,
default_fav
.
size
,
default_fav
.
size
,
media_url
,
default_fav
.
faviconImage
.
name
)
default_fav
.
rel
,
default_fav
.
size
,
default_fav
.
size
,
default_fav
.
faviconImage
.
url
)
return
html
return
html
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment