unitaryfund / unitary.fund

πŸ•ΈοΈ πŸ’› Unitary Fund Website πŸ’› πŸ•ΈοΈ
https://unitary.fund
47 stars 54 forks source link

ensure charset set to utf8 on all pages #256

Closed natestemen closed 2 years ago

natestemen commented 2 years ago

When using the recommended way to develop this site (python -m http.server 8000 --bind 127.0.0.1), many unicode characters are not displayed properly. Thankfully this does not effect production, but this changes ensures further consistency between prod and dev.

before after
Screen Shot 2022-08-22 at 1 28 36 PM Screen Shot 2022-08-22 at 1 28 25 PM

Note: In some files <meta charset="UTF-8"> is added while in others it's <meta charset="UTF-8" />. This discrepancy comes from the fact that prettier is only run on HTML files in the root directory (and it likes the self closing syntax), and not within any directory.

nathanshammah commented 2 years ago

Great find @natestemen.

natestemen commented 2 years ago

I've figured out what is the reason for the difference in prod and dev.

On dev the site is served by python as is and has a rather limited set of HTTP headers that it sends along with requests:

Server: SimpleHTTP/0.6 Python/3.10.6
Date: Tue, 23 Aug 2022 18:04:19 GMT
Content-type: text/html
Content-Length: 18438
Last-Modified: Mon, 22 Aug 2022 20:37:02 GMT

As you can see the Content-type is only text/html.

On prod where GitHub is in control of the server, there is a larger set of headers added to requests, and in particular a change to the Content-type:

server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Tue, 23 Aug 2022 14:57:01 GMT
access-control-allow-origin: *
etag: W/"6304eabd-481e"
expires: Tue, 23 Aug 2022 18:09:01 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: BB30:6933:208829:25B19F:63051565
accept-ranges: bytes
date: Tue, 23 Aug 2022 18:05:05 GMT
via: 1.1 varnish
age: 6
x-served-by: cache-bfi-krnt7300089-BFI
x-cache: HIT
x-cache-hits: 1
x-timer: S1661277905.024509,VS0,VE1
vary: Accept-Encoding
x-fastly-request-id: 31c8c7e400e77e63d4223da65e6c412521d5c574
content-length: 5259
X-Firefox-Spdy: h2
nathanshammah commented 2 years ago

Maybe @WrathfulSpatula you have the skills to review this PR? Otherwise I am happy to merge on good faith basis.

WrathfulSpatula commented 2 years ago

@natestemen At high level, the self-closing tags are probably "correct." A browser might understand it either way, but, as a web developer, my intuition is that every opening tag in the DOM should have a closing tag. I'm still reviewing, but you might want to go in manually and make them all self-closing, if that's reasonable.

natestemen commented 2 years ago

After conversing with Dan, we decided to not use the "formally correct" self-closing tags in all files since a linter/formatter is not being applied across all files. If we transition to that, these will be updated.