diff options
author | cwen <cwen@cvs.openbsd.org> | 2020-05-18 14:40:07 +0000 |
---|---|---|
committer | cwen <cwen@cvs.openbsd.org> | 2020-05-18 14:40:07 +0000 |
commit | c92bd873da8d1639a18b0633401ddaba404afba4 (patch) | |
tree | 1c07f5acce9956947147deec9f9d42002a1c6e44 | |
parent | 6e23d601aaaf75809745310900822448162696d9 (diff) |
httpd: add a "dark mode" in directory listings and error pages
Introduce a new "dark mode" for httpd(8) directory listings and error pages,
using the prefers-color-scheme css function. It uses the colorscheme already
used in OpenBSD project websites.
This version will only be displayed if the user's browser specifically sends
a "prefer darker themes if available" request.
Input from florian@, danj@ and clematis.
OK florian@, danj@ (on a previous version with the wrong background color)
-rw-r--r-- | usr.sbin/httpd/server_file.c | 8 | ||||
-rw-r--r-- | usr.sbin/httpd/server_http.c | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/httpd/server_file.c b/usr.sbin/httpd/server_file.c index 7db3431da6f..e568b4503f2 100644 --- a/usr.sbin/httpd/server_file.c +++ b/usr.sbin/httpd/server_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_file.c,v 1.66 2018/06/15 12:36:05 reyk Exp $ */ +/* $OpenBSD: server_file.c,v 1.67 2020/05/18 14:40:06 cwen Exp $ */ /* * Copyright (c) 2006 - 2017 Reyk Floeter <reyk@openbsd.org> @@ -477,7 +477,11 @@ server_file_index(struct httpd *env, struct client *clt, struct stat *st) /* A CSS stylesheet allows minimal customization by the user */ style = "body { background-color: white; color: black; font-family: " - "sans-serif; }\nhr { border: 0; border-bottom: 1px dashed; }\n"; + "sans-serif; }\nhr { border: 0; border-bottom: 1px dashed; }\n" + "@media (prefers-color-scheme: dark) {\n" + "body { background-color: #1E1F21; color: #EEEFF1; }\n" + "a { color: #BAD7FF; }\n}"; + /* Generate simple HTML index document */ if (evbuffer_add_printf(evb, "<!DOCTYPE html>\n" diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index d01c1eab93f..3cbce9c5ff2 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.137 2020/02/25 15:18:41 sthen Exp $ */ +/* $OpenBSD: server_http.c,v 1.138 2020/05/18 14:40:06 cwen Exp $ */ /* * Copyright (c) 2006 - 2018 Reyk Floeter <reyk@openbsd.org> @@ -921,7 +921,10 @@ server_abort_http(struct client *clt, unsigned int code, const char *msg) /* A CSS stylesheet allows minimal customization by the user */ style = "body { background-color: white; color: black; font-family: " "'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', sans-serif; }\n" - "hr { border: 0; border-bottom: 1px dashed; }\n"; + "hr { border: 0; border-bottom: 1px dashed; }\n" + "@media (prefers-color-scheme: dark) {\n" + "body { background-color: #1E1F21; color: #EEEFF1; }\n" + "a { color: #BAD7FF; }\n}"; /* Generate simple HTML error document */ if ((bodylen = asprintf(&body, |