116cc627d7c003ed67ab128d38a88d4d0390e908
[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 "darkstat.h"
12 #include "str.h"
13 #include "html.h"
14 #include "http.h" /* for http_base_url */
15 #include "opt.h"
16
17 void html_open(struct str *buf, const char *title,
18 const int want_graph_js)
19 {
20 str_appendf(buf,
21 "<!DOCTYPE html>\n"
22 "<html>\n"
23 "<head>\n"
24 "<title>%s (darkstat3 %s)</title>\n"
25 "<meta name=\"generator\" content=\"" PACKAGE_STRING "\">\n"
26 "<meta name=\"robots\" content=\"noindex, noarchive\">\n"
27 "<link rel=\"stylesheet\" href=\"%sstyle.css\" type=\"text/css\">\n"
28 , title, opt_interface, http_base_url);
29
30 if (want_graph_js)
31 str_appendf(buf,
32 "<script src=\"%sgraph.js\" type=\"text/javascript\"></script>\n"
33 , http_base_url);
34
35 str_appendf(buf,
36 "</head>\n"
37 "<body>\n"
38 "<div class=\"menu\">\n"
39 "<ul class=\"menu\">" /* no whitespace (newlines) in list */
40 "<li class=\"label\">" PACKAGE_STRING "</li>"
41 "<li><a href=\"%s\">graphs</a></li>"
42 "<li><a href=\"%shosts/\">hosts</a></li>"
43 "<li><a href=\"" PACKAGE_URL "\">homepage</a></li>"
44 "</ul>\n"
45 "</div>\n"
46 "<div class=\"content\">\n"
47 "<h2 class=\"pageheader\">%s</h2>\n"
48 , http_base_url, http_base_url, title);
49 }
50
51 void html_close(struct str *buf)
52 {
53 str_append(buf,
54 "</div>\n"
55 "</body>\n"
56 "</html>\n");
57 }
58
59 /* vim:set ts=4 sw=4 tw=78 expandtab: */