From 6c91aee9c3a0978a7019f3fdf52f4209977b5f0b Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Wed, 13 Apr 2016 12:00:36 -0400 Subject: [feature] make branding-logo: patches pixelated app logo and replaces it with bitmask-logo.svg - Releases: 0.9.2 --- pkg/branding/bitmask-logo.svg | 19 ++++++++++++++ pkg/branding/branding.mk | 2 ++ pkg/branding/patch_pixel_logo.py | 57 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 pkg/branding/bitmask-logo.svg create mode 100644 pkg/branding/branding.mk create mode 100644 pkg/branding/patch_pixel_logo.py (limited to 'pkg') diff --git a/pkg/branding/bitmask-logo.svg b/pkg/branding/bitmask-logo.svg new file mode 100644 index 00000000..0eccc057 --- /dev/null +++ b/pkg/branding/bitmask-logo.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pkg/branding/branding.mk b/pkg/branding/branding.mk new file mode 100644 index 00000000..6b98d40d --- /dev/null +++ b/pkg/branding/branding.mk @@ -0,0 +1,2 @@ +branding-logo: + python pkg/branding/patch_pixel_logo.py diff --git a/pkg/branding/patch_pixel_logo.py b/pkg/branding/patch_pixel_logo.py new file mode 100644 index 00000000..464bb729 --- /dev/null +++ b/pkg/branding/patch_pixel_logo.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# patch_pixelated_logo.py +# Copyright (C) 2016 LEAP Encryption Acess Project +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +""" +Patch the Pixelated Logo in the index.html, replacing it with a rebranded +Bitmask Logo. To be used in the pixelated_www assets distributed with the +Bitmask bundles. +""" +__author__ = 'Kali Kaneko ' + +import os +import sys + +from BeautifulSoup import BeautifulSoup + + +def patch_logo(orig_path, replacement_path): + + with open(orig_path, 'r') as of: + orig = BeautifulSoup(of.read()) + + with open(replacement_path, 'r') as rf: + new = BeautifulSoup(rf.read()) + + new_svg = new.find('svg') + old_svg = orig.find('svg') + old_svg.replaceWith(new_svg) + + with open(orig_path, 'w') as f: + f.write(str(orig)) + + +if __name__ == "__main__": + here = os.path.dirname(os.path.realpath(__file__)) + if len(sys.argv) > 1: + orig_path = sys.argv[1] + else: + import pixelated_www + orig_path = os.path.join(pixelated_www.__path__[0], + 'index.html') + assert os.path.isfile(orig_path) + new_path = os.path.join(here, 'bitmask-logo.svg') + print('>>> patching file %s with logo in %s' % (orig_path, new_path)) + patch_logo(orig_path, new_path) -- cgit v1.2.3