@@ -242,7 +242,7 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
242242 self . refreshNativeAuthScript ( url : self . currentURL , auth : self . auth )
243243 self . webView . stopLoading ( )
244244 self . webView . loadHTMLString (
245- Self . failureHTML ( title : title , message : message , detail : detail , url : nil ) ,
245+ DashboardFailurePage . html ( title : title , message : message , detail : detail , url : nil ) ,
246246 baseURL : nil )
247247 self . show ( )
248248 }
@@ -846,121 +846,13 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
846846 dashboard load failed url= \( dashboardLogString ( for : self . currentURL ) , privacy : . public ) \
847847 error= \( error . localizedDescription , privacy : . public )
848848 """ )
849- let html = Self . failureHTML (
849+ let html = DashboardFailurePage . html (
850850 title : " Dashboard unavailable " ,
851851 message : error . localizedDescription ,
852852 detail : " The dashboard window is open, but the web UI could not load from this endpoint. " ,
853853 url : self . currentURL )
854854 self . webView . loadHTMLString ( html , baseURL : nil )
855855 }
856-
857- private static func failureHTML ( title : String , message : String , detail : String ? , url : URL ? ) -> String {
858- let detailHTML = detail . map { " <p class= \" detail \" > \( self . htmlEscape ( $0 ) ) </p> " } ?? " "
859- let urlHTML = url . map { " <code> \( self . htmlEscape ( $0 . absoluteString ) ) </code> " } ?? " "
860- return """
861- <!doctype html>
862- <html>
863- <head>
864- <meta charset= " utf-8 " >
865- <style>
866- :root { color-scheme: light dark; }
867- * { box-sizing: border-box; }
868- body {
869- margin: 0;
870- min-height: 100vh;
871- display: grid;
872- place-items: center;
873- background: #101114;
874- color: rgba(255,255,255,.92);
875- font: 15px -apple-system, BlinkMacSystemFont, " SF Pro Text " , system-ui, sans-serif;
876- }
877- main {
878- width: min(540px, calc(100vw - 72px));
879- padding: 34px;
880- border: 1px solid rgba(255,255,255,.12);
881- border-radius: 22px;
882- background: rgba(255,255,255,.035);
883- box-shadow: 0 28px 90px rgba(0,0,0,.36);
884- line-height: 1.45;
885- }
886- .badge {
887- width: 44px;
888- height: 44px;
889- display: grid;
890- place-items: center;
891- margin-bottom: 20px;
892- border-radius: 14px;
893- background: rgba(255,255,255,.07);
894- color: #ff746b;
895- font-size: 24px;
896- }
897- h1 {
898- margin: 0 0 12px;
899- font-size: 24px;
900- line-height: 1.16;
901- font-weight: 700;
902- letter-spacing: 0;
903- }
904- p {
905- margin: 0;
906- color: rgba(255,255,255,.76);
907- font-size: 16px;
908- }
909- .detail {
910- margin-top: 14px;
911- color: rgba(255,255,255,.56);
912- font-size: 13px;
913- }
914- code {
915- display: block;
916- margin-top: 18px;
917- padding: 12px;
918- border: 1px solid rgba(255,255,255,.08);
919- border-radius: 10px;
920- background: rgba(0,0,0,.26);
921- color: rgba(255,255,255,.76);
922- overflow-wrap: anywhere;
923- font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
924- }
925- @media (prefers-color-scheme: light) {
926- body { background: #f5f6f8; color: rgba(0,0,0,.86); }
927- main {
928- background: rgba(255,255,255,.84);
929- border-color: rgba(0,0,0,.1);
930- box-shadow: 0 28px 90px rgba(0,0,0,.12);
931- }
932- .badge { background: rgba(0,0,0,.06); }
933- p { color: rgba(0,0,0,.68); }
934- .detail { color: rgba(0,0,0,.54); }
935- code {
936- background: rgba(0,0,0,.05);
937- border-color: rgba(0,0,0,.08);
938- color: rgba(0,0,0,.68);
939- }
940- }
941- </style>
942- </head>
943- <body>
944- <main>
945- <div class= " badge " >!</div>
946- <h1> \( self . htmlEscape ( title ) ) </h1>
947- <p> \( self . htmlEscape ( message ) ) </p>
948- \( detailHTML )
949- \( urlHTML )
950- </main>
951- </body>
952- </html>
953- """
954- }
955-
956- private static func htmlEscape ( _ value : String ) -> String {
957- value
958- . replacingOccurrences ( of : " & " , with : " & " )
959- . replacingOccurrences ( of : " < " , with : " < " )
960- . replacingOccurrences ( of : " > " , with : " > " )
961- . replacingOccurrences ( of : " \" " , with : " " " )
962- . replacingOccurrences ( of : " ' " , with : " ' " )
963- }
964856}
965857
966858#if DEBUG
0 commit comments