summaryrefslogtreecommitdiffstats
path: root/usr.sbin/httpd
diff options
context:
space:
mode:
authorcwen <cwen@openbsd.org>2020-05-18 14:40:06 +0000
committercwen <cwen@openbsd.org>2020-05-18 14:40:06 +0000
commitaa3aed545c710959415b79b9b939bd135e4ca9f6 (patch)
treefb1e9e43445cb2943af950a6e581e908dd7586fb /usr.sbin/httpd
parentAdd client certificate test in appstest.sh (diff)
downloadwireguard-openbsd-aa3aed545c710959415b79b9b939bd135e4ca9f6.tar.xz
wireguard-openbsd-aa3aed545c710959415b79b9b939bd135e4ca9f6.zip
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)
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r--usr.sbin/httpd/server_file.c8
-rw-r--r--usr.sbin/httpd/server_http.c7
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,