Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
6421-ct-Add-dark-mode-support-to-coverage-pages...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 6421-ct-Add-dark-mode-support-to-coverage-pages.patch of Package erlang
From e54538fb6c8971b42c41798fcf8ccac379cbe281 Mon Sep 17 00:00:00 2001 From: Johannes Christ <jc@jchri.st> Date: Mon, 6 Nov 2023 17:17:46 +0100 Subject: [PATCH] ct: Add dark mode support to coverage pages When common test is tasked with generating coverage via `-cover`, invert the colours of the webpage when the user prefers a dark color scheme. Similar support was added to the other CT-generated pages in commit bbe14c9ff74d7f87d74622f7918e6a8d53963a4d. --- lib/common_test/src/test_server_ctrl.erl | 29 ++++++++++++++++++++---- lib/tools/priv/styles.css | 14 ++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/lib/common_test/src/test_server_ctrl.erl b/lib/common_test/src/test_server_ctrl.erl index 664e0b96a0..dab512e641 100644 --- a/lib/common_test/src/test_server_ctrl.erl +++ b/lib/common_test/src/test_server_ctrl.erl @@ -101,6 +101,25 @@ -define(last_link, "last_link"). -define(last_test, "last_test"). -define(html_ext, ".html"). +-define(cover_html_stylesheet, + "<style>\n" + " @media (prefers-color-scheme: dark) {\n" + " body {" + " filter: invert(100%) hue-rotate(180deg) brightness(105%) contrast(95%);\n" + " /* Workaround for Microsoft Edge, set the background color so it knows\n" + " which original color to rotate from, otherwise the background stays white. */\n" + " background-color: #000000;\n" + " }\n" + " /* Match light theme with links on all browsers */\n" + " a:link {\n" + " color: #2B507D;\n" + " }\n" + " a:visited, a:active {\n" + " /* Match light theme */\n" + " color: #85ABD5;\n" + " }\n" + " }" + "</style>\n"). -define(now, os:timestamp()). -define(void_fun, fun() -> ok end). @@ -5614,7 +5633,8 @@ analyse_modules(_Dir, [], _DetailsFun, Acc) -> %% Support functions for writing the cover logs (both cross and normal) write_coverlog_header(CoverLog) -> - case catch io:put_chars(CoverLog,html_header("Coverage results")) of + Style = [?cover_html_stylesheet], + case catch io:put_chars(CoverLog,html_header("Coverage results", Style)) of {'EXIT',Reason} -> io:format("\n\nERROR: Could not write normal heading in coverlog.\n" "CoverLog: ~tw\n" @@ -5664,7 +5684,8 @@ pc(Cov,NotCov) -> write_not_covered(CoverOut,M,Lines) -> - io:put_chars(CoverOut,html_header("Coverage results for "++atom_to_list(M))), + Style = [?cover_html_stylesheet], + io:put_chars(CoverOut,html_header("Coverage results for "++atom_to_list(M), Style)), io:fwrite(CoverOut, "The following lines in module ~w are not covered:\n" "<table border=3 cellpadding=5>\n" @@ -5741,12 +5762,12 @@ html_header(Title) -> "<body bgcolor=\"white\" text=\"black\" " "link=\"blue\" vlink=\"purple\" alink=\"red\">\n"]. -html_header(Title, Meta) -> +html_header(Title, Extra) -> ["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n" "<!-- autogenerated by '", atom_to_list(?MODULE), "'. -->\n" "<html>\n" "<head>\n" - "<title>", Title, "</title>\n"] ++ Meta ++ ["</head>\n"]. + "<title>", Title, "</title>\n"] ++ Extra ++ ["</head>\n"]. open_html_file(File) -> open_utf8_file(File). diff --git a/lib/tools/priv/styles.css b/lib/tools/priv/styles.css index 84f00be9fd..80fb608fbc 100644 --- a/lib/tools/priv/styles.css +++ b/lib/tools/priv/styles.css @@ -94,3 +94,17 @@ td.source { white-space: pre; font: 12px monospace; } + + +@media (prefers-color-scheme: dark) { + body { + filter: invert(100%) hue-rotate(180deg) brightness(105%) contrast(95%); + background-color: #000000; + } + a:link { + color: #2B507D; + } + a:visited, a:active { + color: #85ABD5; + } +} -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor