diff --git a/web_favicon/README.rst b/web_favicon/README.rst new file mode 100644 index 00000000..ff1ffa99 --- /dev/null +++ b/web_favicon/README.rst @@ -0,0 +1,82 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================== +Custom shortcut icon (favicon) +============================== + +This module was written to allow you to customize your Odoo instance's shortcut +icon (aka favicon). This is useful for branding purposes, but also for +integrators who have many different Odoo instances running and need to see at a +glance which browser tab does what. + +More info about favicon: https://en.wikipedia.org/wiki/Favicon + +Configuration +============= + +Upload your favicon (16x16, 32x32, 64x64 or "as big as possible") on the +company form. The file format would be ico, gif or png with 16x16, 32x32 or +64x64 pixels and 16 colors. Highers resolutions or colors support depends on +the used browser, but most modern browsers do. + +Note that most browsers cache favicons basically forever, so if you want your +icon to show up, you'll most probably have to delete you browser cache. +Some browsers can refresh the favicon, accessing the URL +/web_favicon/favicon. + +You have a sample SVG that can be used as template for generating your icon +in /static/src/img/master_original_favicon.svg. You can also search for some +favicon generators across the web. + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/162/9.0 + +Known issues / Roadmap +====================== + +* Allow to upload some big icon (preferrably SVG or the like) and generate + all the icons from it +* Generate icons suitable for mobile devices and web apps (see /static/src/img/ + folder inside the module for a sample of the possible current formats. +* Put the icon definition at system level, not at company level. It doesn't + make sense (as the icon is cached) to have a different icon per company. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + +Contributors +------------ + +* Holger Brunn +* Pedro M. Baeza + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/web_favicon/__init__.py b/web_favicon/__init__.py new file mode 100644 index 00000000..a2666d4d --- /dev/null +++ b/web_favicon/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models +from . import controllers diff --git a/web_favicon/__openerp__.py b/web_favicon/__openerp__.py new file mode 100644 index 00000000..e18e739f --- /dev/null +++ b/web_favicon/__openerp__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# © 2015 Therp BV +# © 2016 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Custom shortcut icon", + "version": "9.0.1.0.0", + "author": "Therp BV, " + "Tecnativa, " + "Odoo Community Association (OCA)", + "license": "AGPL-3", + "category": "Website", + "summary": "Allows to set a custom shortcut icon (aka favicon)", + "depends": [ + 'web', + ], + "data": [ + "views/res_company.xml", + 'views/templates.xml', + ], + "installable": True, +} diff --git a/web_favicon/controllers/__init__.py b/web_favicon/controllers/__init__.py new file mode 100644 index 00000000..7c3fa3f8 --- /dev/null +++ b/web_favicon/controllers/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import web_favicon diff --git a/web_favicon/controllers/web_favicon.py b/web_favicon/controllers/web_favicon.py new file mode 100644 index 00000000..f0b92aa0 --- /dev/null +++ b/web_favicon/controllers/web_favicon.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# © 2015 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import StringIO +import base64 +from openerp import http +from openerp.tools.misc import file_open + + +class WebFavicon(http.Controller): + + @http.route('/web_favicon/favicon', type='http', auth="none") + def icon(self): + request = http.request + if 'uid' in request.env.context: + user = request.env['res.users'].browse(request.env.context['uid']) + company = user.sudo(user.id).company_id + else: + company = request.env['res.company'].search([], limit=1) + favicon = company.favicon_backend + favicon_mimetype = company.favicon_backend_mimetype + if not favicon: + favicon = file_open('web/static/src/img/favicon.ico') + favicon_mimetype = 'image/x-icon' + else: + favicon = StringIO.StringIO(base64.b64decode(favicon)) + return request.make_response( + favicon.read(), [('Content-Type', favicon_mimetype)]) diff --git a/web_favicon/models/__init__.py b/web_favicon/models/__init__.py new file mode 100644 index 00000000..54d77ccf --- /dev/null +++ b/web_favicon/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import res_company diff --git a/web_favicon/models/res_company.py b/web_favicon/models/res_company.py new file mode 100644 index 00000000..e30c1b2a --- /dev/null +++ b/web_favicon/models/res_company.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# © 2015 Therp BV +# © 2016 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields + + +class ResCompany(models.Model): + _inherit = 'res.company' + + favicon_backend = fields.Binary() + favicon_backend_mimetype = fields.Selection( + selection=[('image/x-icon', 'image/x-icon'), + ('image/gif', 'image/gif'), + ('image/png', 'image/png')], + help='Set the mimetype of your file.') diff --git a/web_favicon/static/description/icon.png b/web_favicon/static/description/icon.png new file mode 100644 index 00000000..bc0090b3 Binary files /dev/null and b/web_favicon/static/description/icon.png differ diff --git a/web_favicon/static/src/img/android-chrome-144x144.png b/web_favicon/static/src/img/android-chrome-144x144.png new file mode 100644 index 00000000..47cbf21a Binary files /dev/null and b/web_favicon/static/src/img/android-chrome-144x144.png differ diff --git a/web_favicon/static/src/img/android-chrome-192x192.png b/web_favicon/static/src/img/android-chrome-192x192.png new file mode 100644 index 00000000..95dd0dfc Binary files /dev/null and b/web_favicon/static/src/img/android-chrome-192x192.png differ diff --git a/web_favicon/static/src/img/android-chrome-36x36.png b/web_favicon/static/src/img/android-chrome-36x36.png new file mode 100644 index 00000000..046b7266 Binary files /dev/null and b/web_favicon/static/src/img/android-chrome-36x36.png differ diff --git a/web_favicon/static/src/img/android-chrome-48x48.png b/web_favicon/static/src/img/android-chrome-48x48.png new file mode 100644 index 00000000..5a31a338 Binary files /dev/null and b/web_favicon/static/src/img/android-chrome-48x48.png differ diff --git a/web_favicon/static/src/img/android-chrome-72x72.png b/web_favicon/static/src/img/android-chrome-72x72.png new file mode 100644 index 00000000..1e22c520 Binary files /dev/null and b/web_favicon/static/src/img/android-chrome-72x72.png differ diff --git a/web_favicon/static/src/img/android-chrome-96x96.png b/web_favicon/static/src/img/android-chrome-96x96.png new file mode 100644 index 00000000..63ba2618 Binary files /dev/null and b/web_favicon/static/src/img/android-chrome-96x96.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-114x114.png b/web_favicon/static/src/img/apple-touch-icon-114x114.png new file mode 100644 index 00000000..0aaacd34 Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-114x114.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-120x120.png b/web_favicon/static/src/img/apple-touch-icon-120x120.png new file mode 100644 index 00000000..3909ec7f Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-120x120.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-144x144.png b/web_favicon/static/src/img/apple-touch-icon-144x144.png new file mode 100644 index 00000000..f295122a Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-144x144.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-152x152.png b/web_favicon/static/src/img/apple-touch-icon-152x152.png new file mode 100644 index 00000000..93fd730b Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-152x152.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-180x180.png b/web_favicon/static/src/img/apple-touch-icon-180x180.png new file mode 100644 index 00000000..2899fa5d Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-180x180.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-57x57.png b/web_favicon/static/src/img/apple-touch-icon-57x57.png new file mode 100644 index 00000000..1f06b9f2 Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-57x57.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-60x60.png b/web_favicon/static/src/img/apple-touch-icon-60x60.png new file mode 100644 index 00000000..715f3339 Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-60x60.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-72x72.png b/web_favicon/static/src/img/apple-touch-icon-72x72.png new file mode 100644 index 00000000..6e869d45 Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-72x72.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-76x76.png b/web_favicon/static/src/img/apple-touch-icon-76x76.png new file mode 100644 index 00000000..490ff715 Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-76x76.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon-precomposed.png b/web_favicon/static/src/img/apple-touch-icon-precomposed.png new file mode 100644 index 00000000..2b3af81e Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon-precomposed.png differ diff --git a/web_favicon/static/src/img/apple-touch-icon.png b/web_favicon/static/src/img/apple-touch-icon.png new file mode 100644 index 00000000..2899fa5d Binary files /dev/null and b/web_favicon/static/src/img/apple-touch-icon.png differ diff --git a/web_favicon/static/src/img/browserconfig.xml b/web_favicon/static/src/img/browserconfig.xml new file mode 100644 index 00000000..65380f38 --- /dev/null +++ b/web_favicon/static/src/img/browserconfig.xml @@ -0,0 +1,12 @@ + + + + + + + + + #da532c + + + diff --git a/web_favicon/static/src/img/favicon-16x16.png b/web_favicon/static/src/img/favicon-16x16.png new file mode 100644 index 00000000..b9f30800 Binary files /dev/null and b/web_favicon/static/src/img/favicon-16x16.png differ diff --git a/web_favicon/static/src/img/favicon-32x32.png b/web_favicon/static/src/img/favicon-32x32.png new file mode 100644 index 00000000..8e73a163 Binary files /dev/null and b/web_favicon/static/src/img/favicon-32x32.png differ diff --git a/web_favicon/static/src/img/favicon-96x96.png b/web_favicon/static/src/img/favicon-96x96.png new file mode 100644 index 00000000..63ba2618 Binary files /dev/null and b/web_favicon/static/src/img/favicon-96x96.png differ diff --git a/web_favicon/static/src/img/favicon.ico b/web_favicon/static/src/img/favicon.ico new file mode 100644 index 00000000..cdf7926f Binary files /dev/null and b/web_favicon/static/src/img/favicon.ico differ diff --git a/web_favicon/static/src/img/manifest.json b/web_favicon/static/src/img/manifest.json new file mode 100644 index 00000000..0f649d7b --- /dev/null +++ b/web_favicon/static/src/img/manifest.json @@ -0,0 +1,41 @@ +{ + "name": "Odoo", + "icons": [ + { + "src": "\/android-chrome-36x36.png", + "sizes": "36x36", + "type": "image\/png", + "density": "0.75" + }, + { + "src": "\/android-chrome-48x48.png", + "sizes": "48x48", + "type": "image\/png", + "density": "1.0" + }, + { + "src": "\/android-chrome-72x72.png", + "sizes": "72x72", + "type": "image\/png", + "density": "1.5" + }, + { + "src": "\/android-chrome-96x96.png", + "sizes": "96x96", + "type": "image\/png", + "density": "2.0" + }, + { + "src": "\/android-chrome-144x144.png", + "sizes": "144x144", + "type": "image\/png", + "density": "3.0" + }, + { + "src": "\/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image\/png", + "density": "4.0" + } + ] +} diff --git a/web_favicon/static/src/img/master_original_favicon.png b/web_favicon/static/src/img/master_original_favicon.png new file mode 100644 index 00000000..22a0aa8f Binary files /dev/null and b/web_favicon/static/src/img/master_original_favicon.png differ diff --git a/web_favicon/static/src/img/master_original_favicon.svg b/web_favicon/static/src/img/master_original_favicon.svg new file mode 100644 index 00000000..078a9ef3 --- /dev/null +++ b/web_favicon/static/src/img/master_original_favicon.svg @@ -0,0 +1,56 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/web_favicon/static/src/img/mstile-144x144.png b/web_favicon/static/src/img/mstile-144x144.png new file mode 100644 index 00000000..e44e2367 Binary files /dev/null and b/web_favicon/static/src/img/mstile-144x144.png differ diff --git a/web_favicon/static/src/img/mstile-150x150.png b/web_favicon/static/src/img/mstile-150x150.png new file mode 100644 index 00000000..96b4e865 Binary files /dev/null and b/web_favicon/static/src/img/mstile-150x150.png differ diff --git a/web_favicon/static/src/img/mstile-310x150.png b/web_favicon/static/src/img/mstile-310x150.png new file mode 100644 index 00000000..a924d3ff Binary files /dev/null and b/web_favicon/static/src/img/mstile-310x150.png differ diff --git a/web_favicon/static/src/img/mstile-310x310.png b/web_favicon/static/src/img/mstile-310x310.png new file mode 100644 index 00000000..b9b4a3e8 Binary files /dev/null and b/web_favicon/static/src/img/mstile-310x310.png differ diff --git a/web_favicon/static/src/img/mstile-70x70.png b/web_favicon/static/src/img/mstile-70x70.png new file mode 100644 index 00000000..c02805fe Binary files /dev/null and b/web_favicon/static/src/img/mstile-70x70.png differ diff --git a/web_favicon/static/src/img/website_favicon_sample.html b/web_favicon/static/src/img/website_favicon_sample.html new file mode 100644 index 00000000..db828882 --- /dev/null +++ b/web_favicon/static/src/img/website_favicon_sample.html @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web_favicon/tests/__init__.py b/web_favicon/tests/__init__.py new file mode 100644 index 00000000..6a5f7312 --- /dev/null +++ b/web_favicon/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_web_favicon diff --git a/web_favicon/tests/test_web_favicon.py b/web_favicon/tests/test_web_favicon.py new file mode 100644 index 00000000..2af4f83c --- /dev/null +++ b/web_favicon/tests/test_web_favicon.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# © 2015 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import base64 +from openerp.tests.common import TransactionCase +from openerp.tools.misc import file_open +from openerp import http + + +class FakeRequest(object): + def __init__(self, env): + self.env = env + + def make_response(self, data, headers): + return FakeResponse(data, headers) + + +class FakeResponse(object): + def __init__(self, data, headers): + self.data = data + self.headers = dict(headers) + + +class TestWebFavicon(TransactionCase): + def test_web_favicon(self): + original_request = http.request + http.request = FakeRequest(self.env) + from openerp.addons.web_favicon.controllers.web_favicon import\ + WebFavicon + company = self.env['res.company'].search([], limit=1) + # default icon + company.write({ + 'favicon_backend': False, + 'favicon_backend_mimetype': False, + }) + data = WebFavicon().icon() + self.assertEqual(data.headers['Content-Type'], 'image/x-icon') + # our own icon + company.write({ + 'favicon_backend': base64.b64encode(file_open( + 'web_favicon/static/description/icon.png').read()), + 'favicon_backend_mimetype': 'image/png', + }) + data = WebFavicon().icon() + self.assertEqual(data.headers['Content-Type'], + company.favicon_backend_mimetype) + http.request = original_request diff --git a/web_favicon/views/res_company.xml b/web_favicon/views/res_company.xml new file mode 100644 index 00000000..fa270399 --- /dev/null +++ b/web_favicon/views/res_company.xml @@ -0,0 +1,17 @@ + + + + + res.company + + + + + + + + + + + + diff --git a/web_favicon/views/templates.xml b/web_favicon/views/templates.xml new file mode 100644 index 00000000..ed80510a --- /dev/null +++ b/web_favicon/views/templates.xml @@ -0,0 +1,10 @@ + + + + + +