Skip to content

Commit

Permalink
[IMP] web_favicon: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dc-oerp committed Mar 14, 2024
1 parent c0cd006 commit 7538a6e
Show file tree
Hide file tree
Showing 18 changed files with 266 additions and 185 deletions.
58 changes: 30 additions & 28 deletions web_favicon/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@ Custom shortcut icon
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/12.0/web_favicon
:target: https://github.com/OCA/web/tree/17.0/web_favicon
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_favicon
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_favicon
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=12.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|


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.
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.

The icon is shown also for portal users when the website modules are not
installed.
Expand All @@ -48,52 +47,55 @@ 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.
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
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
<base_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.
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.

To allow a user to edit the favicon it has to be member of group "Administration / Settings".
To allow a user to edit the favicon it has to be member of group
"Administration / Settings".

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.
- 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 <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_favicon%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_favicon%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~
-------

* Therp BV
* Tecnativa

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -105,6 +107,6 @@ 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.

This module is part of the `OCA/web <https://github.com/OCA/web/tree/12.0/web_favicon>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/17.0/web_favicon>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 1 addition & 3 deletions web_favicon/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
{
"name": "Custom shortcut icon",
"version": "12.0.1.0.0",
"author": "Therp BV, "
"Tecnativa, "
"Odoo Community Association (OCA)",
"author": "Therp BV, " "Tecnativa, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Website",
"summary": "Allows to set a custom shortcut icon (aka favicon)",
Expand Down
19 changes: 10 additions & 9 deletions web_favicon/controllers/web_favicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
# Copyright 2017 QubiQ 2010 <http://www.qubiq.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from io import BytesIO
import base64
from io import BytesIO

from odoo import http
from odoo.tools.misc import file_open


class WebFavicon(http.Controller):

@http.route('/web_favicon/favicon', type='http', auth="none")
@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'])
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)
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', 'rb')
favicon_mimetype = 'image/x-icon'
favicon = file_open("web/static/src/img/favicon.ico", "rb")
favicon_mimetype = "image/x-icon"
else:
favicon = BytesIO(base64.b64decode(favicon))
return request.make_response(
favicon.read(), [('Content-Type', favicon_mimetype)])
favicon.read(), [("Content-Type", favicon_mimetype)]
)
15 changes: 9 additions & 6 deletions web_favicon/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
# Copyright 2016 Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models, fields
from odoo import fields, models


class ResCompany(models.Model):
_inherit = 'res.company'
_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.')
selection=[
("image/x-icon", "image/x-icon"),
("image/gif", "image/gif"),
("image/png", "image/png"),
],
help="Set the mimetype of your file.",
)
3 changes: 3 additions & 0 deletions web_favicon/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
16 changes: 16 additions & 0 deletions web_favicon/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
\<base_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.

To allow a user to edit the favicon it has to be member of group
"Administration / Settings".
15 changes: 0 additions & 15 deletions web_favicon/readme/CONFIGURE.rst

This file was deleted.

9 changes: 9 additions & 0 deletions web_favicon/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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.

The icon is shown also for portal users when the website modules are not
installed.

More info about favicon: <https://en.wikipedia.org/wiki/Favicon>
10 changes: 0 additions & 10 deletions web_favicon/readme/DESCRIPTION.rst

This file was deleted.

8 changes: 8 additions & 0 deletions web_favicon/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- 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.
6 changes: 0 additions & 6 deletions web_favicon/readme/ROADMAP.rst

This file was deleted.

49 changes: 26 additions & 23 deletions web_favicon/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ <h1 class="title">Custom shortcut icon</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4af1c92721d131728f92364370ba5145f45bac9b8e4d4396572737b9ccacd56e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/12.0/web_favicon"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_favicon"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=12.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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.</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/17.0/web_favicon"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_favicon"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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.</p>
<p>The icon is shown also for portal users when the website modules are not
installed.</p>
<p>More info about favicon: <a class="reference external" href="https://en.wikipedia.org/wiki/Favicon">https://en.wikipedia.org/wiki/Favicon</a></p>
Expand All @@ -393,35 +393,38 @@ <h1 class="title">Custom shortcut icon</h1>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>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.</p>
<p>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
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.</p>
<p>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
&lt;base_url&gt;/web_favicon/favicon.</p>
<p>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.</p>
<p>To allow a user to edit the favicon it has to be member of group “Administration / Settings”.</p>
<p>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.</p>
<p>To allow a user to edit the favicon it has to be member of group
“Administration / Settings”.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Allow to upload some big icon (preferrably SVG or the like) and generate
all the icons from it</li>
<li>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.</li>
<li>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.</li>
<li>Allow to upload some big icon (preferrably SVG or the like) and
generate all the icons from it</li>
<li>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.</li>
<li>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.</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_favicon%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_favicon%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -440,7 +443,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_favicon">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/17.0/web_favicon">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions web_favicon/static/src/img/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/mstile-70x70.png"/>
<square150x150logo src="/mstile-150x150.png"/>
<square310x310logo src="/mstile-310x310.png"/>
<wide310x150logo src="/mstile-310x150.png"/>
<square70x70logo src="/mstile-70x70.png" />
<square150x150logo src="/mstile-150x150.png" />
<square310x310logo src="/mstile-310x310.png" />
<wide310x150logo src="/mstile-310x150.png" />
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
Expand Down
Loading

0 comments on commit 7538a6e

Please sign in to comment.