notifications: Use a dynamic SVG favicon for unread counts.

Closes #2304.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-10-20 19:07:35 -07:00 committed by Tim Abbott
parent 621bef5958
commit 5c6202ca97
116 changed files with 688 additions and 123 deletions

View File

@ -1,5 +1,7 @@
"use strict"; "use strict";
const rewiremock = require("rewiremock/node");
// Dependencies // Dependencies
set_global( set_global(
"$", "$",
@ -32,7 +34,9 @@ zrequire("ui");
zrequire("spoilers"); zrequire("spoilers");
spoilers.hide_spoilers_in_notification = () => {}; spoilers.hide_spoilers_in_notification = () => {};
zrequire("notifications"); rewiremock.proxy(() => zrequire("notifications"), {
"../../static/js/favicon": {},
});
// Not muted streams // Not muted streams
const general = { const general = {

View File

@ -104,7 +104,9 @@ zrequire("narrow");
zrequire("search_suggestion"); zrequire("search_suggestion");
zrequire("search"); zrequire("search");
zrequire("tutorial"); zrequire("tutorial");
zrequire("notifications"); rewiremock.proxy(() => zrequire("notifications"), {
"../../static/js/favicon": {},
});
zrequire("pm_conversations"); zrequire("pm_conversations");
zrequire("pm_list"); zrequire("pm_list");
zrequire("list_cursor"); zrequire("list_cursor");

View File

@ -32,6 +32,7 @@
"file-loader": "^6.0.0", "file-loader": "^6.0.0",
"flatpickr": "^4.5.7", "flatpickr": "^4.5.7",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
"font-subset-loader2": "^1.1.7",
"ga-gtag": "^1.0.1", "ga-gtag": "^1.0.1",
"handlebars": "^4.7.2", "handlebars": "^4.7.2",
"handlebars-loader": "^1.7.1", "handlebars-loader": "^1.7.1",
@ -65,6 +66,7 @@
"style-loader": "^1.0.0", "style-loader": "^1.0.0",
"terser-webpack-plugin": "^4.1.0", "terser-webpack-plugin": "^4.1.0",
"turndown": "^6.0.0", "turndown": "^6.0.0",
"url-loader": "^4.1.1",
"webfonts-loader": "^7.0.1", "webfonts-loader": "^7.0.1",
"webpack": "^4.33.0", "webpack": "^4.33.0",
"webpack-cli": "^3.3.2", "webpack-cli": "^3.3.2",

View File

@ -1 +0,0 @@
/tmp.svg

View File

@ -1,24 +0,0 @@
#!/usr/bin/env python3
import subprocess
from xml.etree import ElementTree as ET
# Generates the favicon images containing unread message counts.
# Open the SVG and find the number text elements using XPath
tree = ET.parse('orig.svg')
elems = [tree.getroot().findall(
f".//*[@id='{name}']/{{http://www.w3.org/2000/svg}}tspan")[0]
for name in ('number_back', 'number_front')]
for i in range(1, 100):
# Prepare a modified SVG
s = f'{i:2}'
for e in elems:
e.text = s
with open('tmp.svg', 'wb') as out:
tree.write(out)
# Convert to PNG
subprocess.check_call(['inkscape', '--without-gui', '--export-area-page',
f'--export-png=../../../static/images/favicon/favicon-{i}.png',
'tmp.svg'])

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

Some files were not shown because too many files have changed in this diff Show More