Skip to content
Permalink
Browse files

Add support for per-app shortcut icons

Browsers ususally use these icons when displaying bookmarked
URLs. Varying them helps distinguish one app from another. When not
specified, the default icon is the one in apps/shared.
  • Loading branch information
lovett committed Dec 1, 2019
1 parent e0599ae commit eea3446807651949a36a34ecc649d027f6897bc6
1 .ackrc
@@ -4,6 +4,7 @@
--ignore-dir=htmlcov
--ignore-dir=logs
--ignore-dir=db
--ignore-dir=storage
--ignore-dir=.mypy_cache
--ignore-dir=__pycache__
--ignore-file=ext:pyc
@@ -12,6 +12,11 @@ APPS := $(notdir $(APPS))
APPS := $(filter-out __%,$(APPS))
APPS := $(addprefix apps., $(APPS))

# A list of app-specific icons.
APP_ICONS := $(wildcard apps/*/static/app-icon.svg)
APP_ICONS := $(patsubst %.svg,%.png,$(APP_ICONS))


# A list of parsers with test suites in the form "parsers.[name of parser]".
PARSERS := $(wildcard parsers/*_test.py)
PARSERS := $(notdir $(PARSERS))
@@ -32,7 +37,6 @@ REQUIREMENTS_TEMP := $(CURDIR)/temp-requirements.txt
PIP_OUTDATED_TEMP := temp-pip-outdated.txt

SHARED_JS_DIR := $(CURDIR)/apps/shared/static/js
FAVICON_DIR := $(CURDIR)/apps/shared/static/favicon
TMUX_SESSION_NAME := medley

vpath %.cov coverage
@@ -316,13 +320,12 @@ hooks: dummy


favicon: dummy
convert -density 900 -background none -geometry 360x360 $(FAVICON_DIR)/app-icon.svg $(FAVICON_DIR)/app-icon.png
convert -density 900 -background none -geometry 48x48 $(FAVICON_DIR)/app-icon.svg temp-48.png
convert -density 900 -background none -geometry 32x32 $(FAVICON_DIR)/app-icon.svg temp-32.png
convert -density 900 -background none -geometry 16x16 $(FAVICON_DIR)/app-icon.svg temp-16.png
convert temp-16.png temp-32.png temp-48.png apps/shared/static/favicon/favicon.ico
convert -density 900 -background none -geometry 48x48 apps/shared/static/app-icon.svg temp-48.png
convert -density 900 -background none -geometry 32x32 apps/shared/static/app-icon.svg temp-32.png
convert -density 900 -background none -geometry 16x16 apps/shared/static/app-icon.svg temp-16.png
convert temp-16.png temp-32.png temp-48.png apps/shared/static/favicon.ico
rm temp-48.png temp-32.png temp-16.png
cd $(FAVICON_DIR) && optipng -quiet -o 3 *.png
cd apps/shared/static && optipng -quiet -o 3 *.png

# Automation for merging changes from the master branch into the
# production branch.
@@ -362,3 +365,10 @@ reset:
rm -r coverage
rm -r htmlcov
rm .coverage

# Render an app icon SVG to PNG.
$(APP_ICONS):
convert -density 900 -background none -geometry 360x360 $(patsubst %.png, %.svg, $@) $@

# Geneate PNGs for all app icon SVGs.
app-icons: $(APP_ICONS)
Binary file not shown.
@@ -0,0 +1,5 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<title>earth</title>
<path d="M16 0c-8.837 0-16 7.163-16 16s7.163 16 16 16 16-7.163 16-16-7.163-16-16-16zM16 30c-1.967 0-3.84-0.407-5.538-1.139l7.286-8.197c0.163-0.183 0.253-0.419 0.253-0.664v-3c0-0.552-0.448-1-1-1-3.531 0-7.256-3.671-7.293-3.707-0.188-0.188-0.442-0.293-0.707-0.293h-4c-0.552 0-1 0.448-1 1v6c0 0.379 0.214 0.725 0.553 0.894l3.447 1.724v5.871c-3.627-2.53-6-6.732-6-11.489 0-2.147 0.484-4.181 1.348-6h3.652c0.265 0 0.52-0.105 0.707-0.293l4-4c0.188-0.188 0.293-0.442 0.293-0.707v-2.419c1.268-0.377 2.61-0.581 4-0.581 2.2 0 4.281 0.508 6.134 1.412-0.13 0.109-0.256 0.224-0.376 0.345-1.133 1.133-1.757 2.64-1.757 4.243s0.624 3.109 1.757 4.243c1.139 1.139 2.663 1.758 4.239 1.758 0.099 0 0.198-0.002 0.297-0.007 0.432 1.619 1.211 5.833-0.263 11.635-0.014 0.055-0.022 0.109-0.026 0.163-2.541 2.596-6.084 4.208-10.004 4.208z"></path>
</svg>
@@ -1,6 +1,10 @@
{% extends "base.jinja.html" %}
{% import "macros.jinja.html" as macros -%}

{% block app_icon -%}
{{ macros.appSpecificIcon(app_url) }}
{%- endblock %}

{% block stylesheets %}
{{ macros.staticAsset('reminder', 'reminder.css') }}
{% endblock %}
Binary file not shown.
@@ -0,0 +1,6 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<title>alarm</title>
<path d="M16 4c-7.732 0-14 6.268-14 14s6.268 14 14 14 14-6.268 14-14-6.268-14-14-14zM16 29.25c-6.213 0-11.25-5.037-11.25-11.25s5.037-11.25 11.25-11.25c6.213 0 11.25 5.037 11.25 11.25s-5.037 11.25-11.25 11.25zM29.212 8.974c0.501-0.877 0.788-1.892 0.788-2.974 0-3.314-2.686-6-6-6-1.932 0-3.65 0.913-4.747 2.331 4.121 0.851 7.663 3.287 9.96 6.643v0zM12.748 2.331c-1.097-1.418-2.816-2.331-4.748-2.331-3.314 0-6 2.686-6 6 0 1.082 0.287 2.098 0.788 2.974 2.297-3.356 5.838-5.792 9.96-6.643z"></path>
<path d="M16 18v-8h-2v10h8v-2z"></path>
</svg>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
@@ -0,0 +1,5 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<title>cloud</title>
<path d="M32 20.548c0-2.565-1.771-4.716-4.156-5.296-0.101-4.022-3.389-7.252-7.433-7.252-2.369 0-4.477 1.109-5.839 2.835-0.764-0.987-1.959-1.624-3.303-1.624-2.307 0-4.176 1.871-4.176 4.179 0 0.201 0.015 0.399 0.043 0.592-0.351-0.063-0.711-0.098-1.080-0.098-3.344-0-6.054 2.712-6.054 6.058s2.71 6.058 6.054 6.058l20.508-0c3.004-0.006 5.438-2.444 5.438-5.451z"></path>
</svg>
@@ -1,4 +1,9 @@
{% extends "base.jinja.html" %}
{% import "macros.jinja.html" as macros -%}

{% block app_icon -%}
{{ macros.appSpecificIcon(app_url) }}
{%- endblock %}

{% block page_body %}
<main>
@@ -144,7 +144,7 @@ def setup() -> None:
app_config["/favicon.ico"] = {
"tools.staticfile.on": True,
"tools.staticfile.filename": os.path.realpath(
"./apps/shared/static/favicon/favicon.ico"
"./apps/shared/static/favicon.ico"
),
}

@@ -22,8 +22,10 @@

{% block stylesheets %}{% endblock %}

<link rel="apple-touch-icon" href="/shared/static/favicon/app-icon.png"/>
<link rel="mask-icon" href="/shared/static/favicon/app-icon.svg" color="black">
{% block app_icon -%}
<link rel="shortcut icon" href="/shared/static/app-icon.png" />
<link rel="mask-icon" href="/shared/static/app-icon.svg" color="black">
{%- endblock %}

<meta name="medley-home" content="{{ '/' | internal_url }}" />
<meta name="medley-startpage" content="{{ '/startpage' | internal_url }}" />
@@ -248,3 +248,8 @@
{% endif %}
</section>
{%- endmacro -%}

{% macro appSpecificIcon(app_url) -%}
<link rel="shortcut icon" href="{{ app_url }}/static/app-icon.png" />
<link rel="mask-icon" href="{{ app_url }}/static/app-icon.svg" color="black">
{%- endmacro %}

0 comments on commit eea3446

Please sign in to comment.
You can’t perform that action at this time.