From: Christian Hofstaedtler Date: Tue, 30 Apr 2013 13:28:02 +0000 (+0200) Subject: restyle builtin webserver page X-Git-Tag: auth-3.3-rc1~147^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1071abdd53b4a71c0c210a6b4f5aee86a30e6b98;p=pdns restyle builtin webserver page should closely match the powerdns CI, except for the font. --- diff --git a/pdns/webserver.cc b/pdns/webserver.cc index ae0190466..9eba79c14 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -143,7 +143,7 @@ void *WebServer::serveConnection(void *p) client->putLine("WWW-Authenticate: Basic realm=\"PowerDNS\"\n"); client->putLine("Connection: close\n"); - client->putLine("Content-type: text/html\n\n"); + client->putLine("Content-type: text/html; charset=UTF-8\n\n"); client->putLine("Please enter a valid password!\n"); client->close(); delete client; @@ -158,14 +158,14 @@ void *WebServer::serveConnection(void *p) if(!custom) { client->putLine("HTTP/1.1 200 OK\n"); client->putLine("Connection: close\n"); - client->putLine("Content-type: text/html\n\n"); + client->putLine("Content-type: text/html; charset=UTF-8\n\n"); } client->putLine(ret); } else { client->putLine("HTTP/1.1 404 Not found\n"); client->putLine("Connection: close\n"); - client->putLine("Content-type: text/html\n\n"); + client->putLine("Content-type: text/html; charset=UTF-8\n\n"); // FIXME: CSS problem? client->putLine("

Did not find file '"+baseUrl+"'\n"); } diff --git a/pdns/ws.cc b/pdns/ws.cc index 1bd4562b9..3050ccedb 100644 --- a/pdns/ws.cc +++ b/pdns/ws.cc @@ -95,20 +95,17 @@ void printtable(ostringstream &ret, const string &ringname, const string &title, int entries=0; vector >ring=S.getRing(ringname); - for(vector >::const_iterator i=ring.begin(); i!=ring.end();++i) { + for(vector >::const_iterator i=ring.begin(); i!=ring.end();++i) { tot+=i->second; entries++; } - - ret<<""<"<

Variables

" - "Top-"<"; - ret<<"
" - "ResetResize: "; - + ret<<"
"<"; + ret<<""; int printed=0; for(vector >::const_iterator i=ring.begin();limit && i!=ring.end();++i,--limit) { ret<<""<"<"; - ret<<"
"<first<<""<second<<""<< StatWebServer::makePercentage(i->second*100.0/tot)<<"Rest:"<"<< StatWebServer::makePercentage((tot-printed)*100.0/tot)<<"Total:"<100%

"<"<
Variables
"<entries=S.getEntries(); for(vector::const_iterator i=entries.begin();i!=entries.end();++i) { ret<<"
"<<*i<<""<"<"<"<"<"<PowerDNS Operational Monitor"<"; - if(!arg()["config-name"].empty()) - ret<<"["<"<Back to main page"<"<"<PowerDNS Authoritative Server Monitor"<"<"<"<"; + ret<<"PowerDNS "VERSION; + if(!arg()["config-name"].empty()) { + ret<<" ["<"<"; + ret<<"
"; time_t passed=time(0)-s_starttime; @@ -221,7 +221,7 @@ string StatWebServer::indexfunction(const string& method, const string& post, co sws->d_qcachemisses.get10()<<". Max queries/second: "<d_qcachemisses.getMax()<< "
"<"<
"<entries=S.listRings(); for(vector::const_iterator i=entries.begin();i!=entries.end();++i) @@ -234,6 +234,8 @@ string StatWebServer::indexfunction(const string& method, const string& post, co else printtable(ret,rvarmap["ring"],S.getRingTitle(rvarmap["ring"]),100); + ret<<"
"<PowerDNS Authoritative Server "VERSION". © 2013
PowerDNS.COM BV."<"< &varmap, void *ptr, bool *custom) +{ + *custom=1; // indicates we build the response + ostringstream ret; + ret<<"HTTP/1.1 200 OK\r\n" + "Server: PowerDNS/"VERSION"\r\n" + "Connection: close\r\n" + "Cache-Control: max-age=86400\r\n" + "Content-Type: text/css\r\n" + "\r\n"; + + ret<<"* { box-sizing: border-box; margin: 0; padding: 0; }"<setCaller(this); d_ws->registerHandler("",&indexfunction); + d_ws->registerHandler("style.css",&cssfunction); if(::arg().mustDo("experimental-json-interface")) d_ws->registerHandler("jsonstat", &jsonstat); d_ws->go(); diff --git a/pdns/ws.hh b/pdns/ws.hh index e5c6ff726..2113e1ab3 100644 --- a/pdns/ws.hh +++ b/pdns/ws.hh @@ -87,6 +87,7 @@ private: static void *threadHelper(void *); static void *statThreadHelper(void *p); static string indexfunction(const string& method, const string& post, const map &varmap, void *ptr, bool *custom); + static string cssfunction(const string& method, const string& post, const map &varmap, void *ptr, bool *custom); static string jsonstat(const string& method, const string& post, const map &varmap, void *ptr, bool *custom); void printvars(ostringstream &ret); void printargs(ostringstream &ret);