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
7e1574ff
Commit
7e1574ff
authored
8 years ago
by
Philippe O. Wagner
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #15 from arthru/master
Simplify tag code
parents
02bd59c3
6b4837b1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
favicon/templatetags/favtags.py
+4
-31
4 additions, 31 deletions
favicon/templatetags/favtags.py
with
5 additions
and
32 deletions
README.md
+
1
−
1
View file @
7e1574ff
...
...
@@ -37,7 +37,7 @@ use the templatetag in your base.html
```
html+django
{% load favtags %}
{%
autoescape off %}{% placeFavicon %}{% endautoescape
%}
{%
placeFavicon
%}
```
this will create:
```
html
...
...
This diff is collapsed.
Click to expand it.
favicon/templatetags/favtags.py
+
4
−
31
View file @
7e1574ff
from
django
import
template
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.utils.safestring
import
mark_safe
from
favicon.models
import
Favicon
from
favicon.models
import
config
from
favicon.models
import
Favicon
,
config
register
=
template
.
Library
()
...
...
@@ -18,35 +16,10 @@ def placeFavicon(context):
{% placeFavicon %}
"""
fav
=
Favicon
.
objects
.
filter
(
isFavicon
=
True
)
fav
=
Favicon
.
objects
.
filter
(
isFavicon
=
True
)
.
first
()
if
not
fav
:
return
'
<!-- no favicon -->
'
for
n
in
fav
[
1
:]:
n
.
isFavicon
=
False
fav
=
fav
[
0
]
'''
if a:
fav = a[0]
else:
return
'
<!-- %s -->
'
% (
'
no favicon found
'
,)
'''
favs
=
fav
.
get_favicons
()
request
=
context
[
'
request
'
]
html
=
''
#html += '<link rel="shortcut icon" href="http://%s/favicon.ico"/>' % (request.get_host(),)
#html += '<link rel="shortcut icon" href="http://%s/favicon.ico"/>'
'''
for rel in config:
for size in sorted(config[rel], reverse=True)[:-1]:
n = fav.get_favicon(size=size, rel=rel)
html +=
'
<link rel=
"
%s
"
size =
"
%sx%s
"
href=
"
%s%s
"
/>
'
% (
n.rel, n.size, n.size, media_url, n.faviconImage.name)
for size in sorted(config[rel], reverse=True)[-1:]:
n = fav.get_favicon(size=size, rel=rel)
html +=
'
<link rel=
"
%s
"
size =
"
any
"
href=
"
%s%s
"
/>
'
% (
n.rel, media_url, n.faviconImage.name)
'''
for
rel
in
config
:
for
size
in
sorted
(
config
[
rel
],
reverse
=
True
):
n
=
fav
.
get_favicon
(
size
=
size
,
rel
=
rel
)
...
...
@@ -57,4 +30,4 @@ def placeFavicon(context):
html
+=
'
<link rel=
"
%s
"
size =
"
%sx%s
"
href=
"
%s
"
/>
'
%
(
default_fav
.
rel
,
default_fav
.
size
,
default_fav
.
size
,
default_fav
.
faviconImage
.
url
)
return
html
return
mark_safe
(
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