From bb5f338e2e84c3f961eb619e965e4b2f47d3a13f Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Sun, 15 May 2011 20:01:38 +1000 Subject: [PATCH] Remove headers callback and tidy up html module a bit. --- graph_db.c | 8 +------- hosts_db.c | 4 ++-- html.c | 51 ++++++++++++++++++++++++++------------------------- html.h | 2 +- 4 files changed, 30 insertions(+), 35 deletions(-) diff --git a/graph_db.c b/graph_db.c index 44685e9..edba22d 100644 --- a/graph_db.c +++ b/graph_db.c @@ -302,12 +302,6 @@ graph_export(const int fd) return 1; } -static void cb_headers(struct str *buf) -{ - str_appendf(buf, "\n", base_url, "graph.js"); -} - /* --------------------------------------------------------------------------- * Web interface: front page! */ @@ -319,7 +313,7 @@ html_front_page(void) char start_when[100]; buf = str_make(); - html_open(buf, "Graphs", interface, cb_headers); + html_open(buf, "Graphs", interface, /*want_graph_js=*/1); str_append(buf, "

\n"); str_append(buf, "Running for "); diff --git a/hosts_db.c b/hosts_db.c index 954daba..d3c65df 100644 --- a/hosts_db.c +++ b/hosts_db.c @@ -974,7 +974,7 @@ html_hosts_main(const char *qs) #define NEXT "next page >>>" #define FULL "full table" - html_open(buf, "Hosts", interface, NULL); + html_open(buf, "Hosts", interface, /*want_graph_js=*/0); format_table(buf, hosts_db, start, sort, full); /* */ @@ -1031,7 +1031,7 @@ html_hosts_detail(const char *ip) /* Overview. */ buf = str_make(); - html_open(buf, ip, interface, NULL); + html_open(buf, ip, interface, /*want_graph_js=*/0); if (strcmp(ip, canonical) != 0) str_appendf(buf, "(canonically %s)\n", canonical); str_appendf(buf, diff --git a/html.c b/html.c index 18d434f..ebc5eca 100644 --- a/html.c +++ b/html.c @@ -14,34 +14,37 @@ #include "http.h" /* for base_url */ void html_open(struct str *buf, const char *title, const char *interface, - void (*header_callback)(struct str *buf)) + const int want_graph_js) { - str_append(buf, + str_appendf(buf, "\n" "\n" - "\n"); - str_appendf(buf, "%s (darkstat3 : %s)\n" - "\n", title, interface, - PACKAGE_STRING); - str_append(buf, "\n"); - str_appendf(buf, "\n", - base_url, "style.css"); - if (header_callback != NULL) - header_callback(buf); - - str_append(buf, "\n" + "\n" + "%s (darkstat3 %s)\n" + "\n" + "\n" + "\n" + , title, interface, PACKAGE_STRING, base_url); + + if (want_graph_js) + str_appendf(buf, + "\n" + , base_url); + + str_appendf(buf, + "\n" "\n" "

\n" - "\n" + "\n" "
\n" - "
\n"); - str_appendf(buf, "

%s

\n", title); + "
\n" + "

%s

\n" + , PACKAGE_STRING, base_url, base_url, title); } void html_close(struct str *buf) @@ -49,9 +52,7 @@ void html_close(struct str *buf) str_append(buf, "
\n" "\n" - "\n" - ); + "\n"); } - /* vim:set ts=4 sw=4 tw=78 expandtab: */ diff --git a/html.h b/html.h index 296e022..2dcc874 100644 --- a/html.h +++ b/html.h @@ -10,7 +10,7 @@ #include "config.h" /* for PACKAGE_STRING */ void html_open(struct str *buf, const char *title, const char *interface, - void (*header_callback)(struct str *buf)); + const int want_graph_js); void html_close(struct str *buf); #endif -- 2.17.1