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