From d71ee5b0ccaa358a194c7526003935b205e4b171 Mon Sep 17 00:00:00 2001 From: ZuluPro Date: Thu, 21 Apr 2016 18:19:51 -0400 Subject: [PATCH] Added frontend part --- .../management/commands/generate_favicon.py | 20 +++++++++++++- favicon/templates/favicon/favicon.html | 27 +++++++++++++++++++ favicon/templates/favicon/ieconfig.xml | 13 +++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 favicon/templates/favicon/favicon.html create mode 100644 favicon/templates/favicon/ieconfig.xml diff --git a/favicon/management/commands/generate_favicon.py b/favicon/management/commands/generate_favicon.py index 4fe6901..6f25dc8 100644 --- a/favicon/management/commands/generate_favicon.py +++ b/favicon/management/commands/generate_favicon.py @@ -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): @@ -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) diff --git a/favicon/templates/favicon/favicon.html b/favicon/templates/favicon/favicon.html new file mode 100644 index 0000000..399c329 --- /dev/null +++ b/favicon/templates/favicon/favicon.html @@ -0,0 +1,27 @@ +{% load static %} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/favicon/templates/favicon/ieconfig.xml b/favicon/templates/favicon/ieconfig.xml new file mode 100644 index 0000000..b0b10e4 --- /dev/null +++ b/favicon/templates/favicon/ieconfig.xml @@ -0,0 +1,13 @@ +{% load static %} + + + + + + + + + #{{ tile_color }} + + +