Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A proper favicon #1603

Closed
simonw opened this issue Jan 19, 2022 · 19 comments
Closed

A proper favicon #1603

simonw opened this issue Jan 19, 2022 · 19 comments

Comments

@simonw
Copy link
Owner

simonw commented Jan 19, 2022

Tips here: https://adamj.eu/tech/2022/01/18/how-to-add-a-favicon-to-your-django-site/ - I think a PNG served at /favicon.ico is the best option, since safari doesn't support SVG yet.

Relevant code:

datasette/datasette/app.py

Lines 182 to 183 in cb29119

async def favicon(request, send):
await asgi_send(send, "", 200)

I can reuse the icon for https://datasette.io/desktop

@simonw
Copy link
Owner Author

simonw commented Jan 19, 2022

I'd like this to be customizable. I'm going to load it from the template loading system such that a custom favicon for a specific instance can be dropped in using a file in templates/.

@simonw
Copy link
Owner Author

simonw commented Jan 19, 2022

I don't think abusing the template loader mechanism for this will work: Jinja provides an API for loading text templates, but I don't think it can be sensibly abused to open binary image files instead. Loaded code is here: https://github.com/pallets/jinja/blob/main/src/jinja2/loaders.py

@simonw
Copy link
Owner Author

simonw commented Jan 19, 2022

For the moment then I will hard-code a new favicon and leave it to ASGI plugins if people want to define their own.

@simonw
Copy link
Owner Author

simonw commented Jan 19, 2022

Also people can use a custom base template and link to a custom favicon if they want to.

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

This one is 101KB and 1536*1536 which is a bit big! https://github.com/simonw/datasette-app/blob/main/build/icon.png

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

https://adamj.eu/tech/2022/01/18/how-to-add-a-favicon-to-your-django-site/ suggests 64x64, I'm going with 128x128 just in case anyone invents a retina-retina screen.

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

Here's the 128x128 one - 11kb, I resized it using Preview:

icon

Now running it through Squoosh using OxiPNG effort=3 colours=24 - brought it down to 1.36KB.

favicon

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

I'm going to drop it in datasette/static/favicon.png and rewrite the async def favicon() function to return it, with caching headers.

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

Here's what it looks like in Firefox, Chrome and Safari:

CleanShot 2022-01-19 at 21 35 06@2x

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

I'm not crazy about the look - I think this version of the grid may have too many lines for this particular display size.

I'm going to try reducing the number of lines in Figma to see if I like that better. https://www.figma.com/file/LKjceTFNtKm6wCbScDqm1Y/Datasette-Logo

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

My attempt with one less grid line looked awful when shrunk down to the browser size:

image

File here:

favicon

I'm going with the first attempt for the moment.

simonw added a commit that referenced this issue Jan 20, 2022
@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

The new /favicon.ico view:

datasette/datasette/app.py

Lines 182 to 192 in 0467723

FAVICON_PATH = app_root / "datasette" / "static" / "favicon.png"
async def favicon(request, send):
await asgi_send_file(
send,
str(FAVICON_PATH),
content_type="image/png",
chunk_size=4096,
headers={"Cache-Control": "max-age=3600, immutable, public"},
)

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

New favicon now live on https://latest.datasette.io/ - see also https://latest.datasette.io/favicon.ico

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

Oops, I pushed the one I liked least out of the two options! Fixing now.

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

Now live on https://latest.datastte.io/ - I'm happy enough with this for the moment:

image

@simonw simonw closed this as completed Jan 20, 2022
@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

One last go at tidying this up. I decided to do a 32x32 pixel version in Pixelmator, using this trick to access a pixel brush: https://osxdaily.com/2016/11/17/enable-pixel-brush-pixelmator-mac/

image

Frustrating how the white boxes are all exactly four pixels high and ALMOST all four pixels wide, but one of them has to be three pixels wide to fit the space.

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

Here's a comparison between my hand-edited version and the one I have now:

CleanShot 2022-01-20 at 10 38 00@2x

The new 32x32 image:

@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

Resized it down to 208 bytes with https://squoosh.app

image

favicon

simonw added a commit that referenced this issue Jan 20, 2022
@simonw
Copy link
Owner Author

simonw commented Jan 20, 2022

@simonw simonw added this to the Datasette 1.0 milestone Mar 19, 2022
simonw added a commit that referenced this issue Mar 20, 2022
simonw added a commit that referenced this issue Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant