Skip to content

Commit

Permalink
Added frontend part
Browse files Browse the repository at this point in the history
  • Loading branch information
ZuluPro committed Apr 21, 2016
1 parent e64a1fe commit d71ee5b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
20 changes: 19 additions & 1 deletion favicon/management/commands/generate_favicon.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import os
from django.core.management.base import BaseCommand, CommandError
from django.template.loader import get_template
from PIL import Image
from favicon import settings

PNG_SIZE = (32, 57, 76, 96, 120, 128, 144, 152, 180, 195, 196, 228, 270, 558)
PNG_SIZE = (32, 57, 76, 96, 120, 128, 144, 152, 180, 195, 196)
WINDOWS_PNG_SIZE = (
([128, 128], 'smalltile.png'),
([270, 270], 'mediumtile.png'),
([558, 270], 'widetile.png'),
([558, 558], 'largetile.png'),
)


class Command(BaseCommand):
Expand All @@ -25,3 +32,14 @@ def handle(self, *args, **options):
output = os.path.join(settings.STATIC_DIR, 'favicon-%s.png' % size)
img.thumbnail(size=(size, size), resample=Image.ANTIALIAS)
img.save(output)
for size, filename in PNG_SIZE:
img = Image.open(filename)
output = os.path.join(settings.STATIC_DIR, 'filename')
img.thumbnail(size=size, resample=Image.ANTIALIAS)
img.save(output)
# Create ieconfig.xml
output = os.path.join(settings.STATIC_DIR, 'ieconfig.xml')
with open(output, 'w') as output_file:
template = get_template('favicon/ieconfig.xml')
output_content = template.render({'tile_color': 'FFFFFF'})
output_file.write(output_content)
27 changes: 27 additions & 0 deletions favicon/templates/favicon/favicon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% load static %}
<link rel="apple-touch-icon-precomposed" href="{% static_url "favicon-152.png" %}">

<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="{% static_url "favicon-144.png" %}">

<meta name="application-name" content="Name">
<meta name="msapplication-tooltip" content="Tooltip">
<meta name="msapplication-config" content="{% static_url "ieconfig.xml" %}">

<link rel="icon" href="{% static_url "favicon-32.png" sizes="32x32" %}">
<link rel="icon" href="{% static_url "favicon-57.png" sizes="57x57" %}">
<link rel="icon" href="{% static_url "favicon-76.png" sizes="76x76" %}">
<link rel="icon" href="{% static_url "favicon-96.png" sizes="96x96" %}">
<link rel="icon" href="{% static_url "favicon-120.png" sizes="120x120" %}">
<link rel="icon" href="{% static_url "favicon-128.png" sizes="128x128" %}">
<link rel="icon" href="{% static_url "favicon-144.png" sizes="144x144" %}">
<link rel="icon" href="{% static_url "favicon-152.png" sizes="152x152" %}">
<link rel="icon" href="{% static_url "favicon-180.png" sizes="180x180" %}">
<link rel="icon" href="{% static_url "favicon-195.png" sizes="195x195" %}">
<link rel="icon" href="{% static_url "favicon-228.png" sizes="228x228" %}">
<link rel="icon" href="{% static_url "smalltile.png" sizes="128x128" %}">
<link rel="icon" href="{% static_url "mediumtile.png" sizes="270x270" %}">
<link rel="icon" href="{% static_url "widetile.png" sizes="558x270" %}">
<link rel="icon" href="{% static_url "largetile.png" sizes="558x558" %}">
<link rel="shortcut icon" sizes="196x196" href="{% static_url "favicon-196.png" %}">
<!--[if IE]><link rel="shortcut icon" type="image/x-icon" href="{% static_url "favicon.ico" %}" /><![endif]-->
13 changes: 13 additions & 0 deletions favicon/templates/favicon/ieconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% load static %}
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="{% static_url "smalltile.png" %}"/>
<square150x150logo src="{% static_url "mediumtile.png" %}"/>
<wide310x150logo src="{% static_url "widetile.png" %}"/>
<square310x310logo src="{% static_url "largetile.png" %}"/>
<TileColor>#{{ tile_color }}</TileColor>
</tile>
</msapplication>
</browserconfig>

0 comments on commit d71ee5b

Please sign in to comment.