0c5c418bb774b69eec13f0b6515a8aaf619ccb7b
[darkstat] / html.c
1 /* darkstat 3
2 *
3 * html.c: HTML header/footer templating for web interface.
4 * copyright (c) 2006 Ben Stewart.
5 * copyright (c) 2010 Malte S. Stretz.
6 *
7 * You may use, modify and redistribute this file under the terms of the
8 * GNU General Public License version 2. (see COPYING.GPL)
9 */
10
11 #include "config.h" /* for PACKAGE_STRING, PACKAGE_URL */
12 #include "str.h"
13 #include "html.h"
14 #include "http.h" /* for base_url */
15
16 void html_open(struct str *buf, const char *title, const char *interface,
17 const int want_graph_js)
18 {
19 str_appendf(buf,
20 "<!DOCTYPE html>\n"
21 "<html>\n"
22 "<head>\n"
23 "<title>%s (darkstat3 %s)</title>\n"
24 "<meta name=\"generator\" content=\"" PACKAGE_STRING "\">\n"
25 "<meta name=\"robots\" content=\"noindex, noarchive\">\n"
26 "<link rel=\"stylesheet\" href=\"%sstyle.css\" type=\"text/css\">\n"
27 , title, interface, base_url);
28
29 if (want_graph_js)
30 str_appendf(buf,
31 "<script src=\"%sgraph.js\" type=\"text/javascript\"></script>\n"
32 , base_url);
33
34 str_appendf(buf,
35 "</head>\n"
36 "<body>\n"
37 "<div class=\"menu\">\n"
38 "<ul class=\"menu\">" /* no whitespace (newlines) in list */
39 "<li class=\"label\">" PACKAGE_STRING "</li>"
40 "<li><a href=\"%s\">graphs</a></li>"
41 "<li><a href=\"%shosts/\">hosts</a></li>"
42 "<li><a href=\"" PACKAGE_URL "\">homepage</a></li>"
43 "</ul>\n"
44 "</div>\n"
45 "<div class=\"content\">\n"
46 "<h2 class=\"pageheader\">%s</h2>\n"
47 , base_url, base_url, title);
48 }
49
50 void html_close(struct str *buf)
51 {
52 str_append(buf,
53 "</div>\n"
54 "</body>\n"
55 "</html>\n");
56 }
57
58 /* vim:set ts=4 sw=4 tw=78 expandtab: */