Skip to content
Snippets Groups Projects
Commit a4f8db0c authored by Yannik Ammann's avatar Yannik Ammann
Browse files

no message

parent 49e387f3
No related branches found
No related tags found
No related merge requests found
......@@ -54,3 +54,5 @@ highest resolution for ipad retina 144x144.png precomposed(=iOS won’t add any
Android versions 1.5 and 1.6 will read the second tag (with "-precomposed"), and versions 2.1 and newer will read the first tag.
Google's specifications say that you should use 48x48 pixel PNGs, but you can use a large image (128x128), like Google does for its own apps.
https://mathiasbynens.be/notes/touch-icons
......@@ -14,9 +14,11 @@ sizes = [16,32,57,72,86,96,114,120,128,144,152,195,228]
sizes = getattr(settings, 'FAVICON_SIZES', sizes)
config = {
'shortcut icon': [16,32,48,128],
'apple-touch-icon': [57, 72, 114, 144],
'apple-touch-icon-precomposed': [57, 72, 114, 144],
'shortcut icon': [16 ,32 ,48 ,128, 192],
'touch-icon': [196],
'icon': [196],
'apple-touch-icon': [57, 72, 114, 144, 180],
'apple-touch-icon-precomposed': [57, 72, 76, 114, 120, 144, 152,180],
}
......@@ -84,6 +86,8 @@ class Favicon(models.Model):
'''
def get_default_favicon(self):
def __str__(self):
return self.faviconImage.name
......
......@@ -12,8 +12,8 @@ register = template.Library()
media_url = getattr(settings, 'MEDIA_URL', False)
@register.simple_tag
def placeFavicon():
@register.simple_tag(takes_context=True)
def placeFavicon(context):
"""
Gets Favicon-URL for the Model.
......@@ -34,8 +34,22 @@ def placeFavicon():
favs = fav.get_favicons()
html = ''
request = context['request']
html = '<link rel="shortcut icon" href="http://%s/favicon.ico"/>' % (request.get_host(),)
'''
for rel in config:
for size in sorted(config[rel],reverse=True):
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 rel in config:
for size in sorted(config[rel],reverse=True)[:-1]:
n = fav.get_favicon(size=size,rel=rel)
......@@ -43,7 +57,7 @@ def placeFavicon():
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)
......
......@@ -4,6 +4,6 @@ from django.conf.urls.defaults import *
urlpatterns = patterns('favicon.views',
url(r'^$',
view='favicon',
name='favicon_index'
name='favicon',
),
)
......@@ -10,11 +10,23 @@ from django.conf import settings
def favicon(request, template_name='favicon/index.html'):
fav = get_object_or_404(Favicon, isFavicon=True)
link = settings.MEDIA_URL
link += fav.faviconImage.name
return redirect(link)
pass
raise Http404
if 'favicon' in request.path:
fav = get_object_or_404(Favicon, isFavicon=True)
link = settings.MEDIA_URL
link += fav.faviconImage.name
return redirect(link)
if 'apple-touch-icon' in request.path:
fav = get_object_or_404(Favicon, isFavicon=True)
favicon = fav.get_favicon(57,'apple-touch-icon')
link = settings.MEDIA_URL
link += favicon.faviconImage.name
return redirect(link)
raise Http404
def favicon_apple(request):
fav = get_object_or_404(Favicon, isFavicon=True)
favicon = fav.get_favicon(57,'apple-touch-icon')
link = settings.MEDIA_URL
link += favicon.faviconImage.name
return redirect(link)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment