aboutsummaryrefslogtreecommitdiffstats
path: root/ui-common.c
blob: a417180be26690947e95641cf17ec24f1f4964f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>

#include "ui-common.h"
#include "ctimeline.h"

void print_http_headers()
{
	printf("Content-type: text/html\n");
	printf("\n");
}

void print_document_start()
{
	printf("<html>\n");
	printf("<head>\n");
	printf("<title>%s</title>\n", ctx.head_title->s);
	printf("<link rel='stylesheet' href='%s'>\n", ctx.css->s);
	printf("</head>\n");
	printf("</body>\n");
}

void print_document_header()
{
	printf("<div id='ctimeline'>\n");
	printf("<header>\n");
	printf("<table>\n");

	printf("<tr>\n");
	printf(
		"<td><p class='header'>%s</p></td>\n", ctx.header_title->s);
	printf("</tr>\n");

	printf("<tr class='sub_text'>\n");
	printf(
		"<td>%s</td>\n", ctx.header_desc->s);
	printf("</tr>\n");

	printf("</table>\n");
	printf("</header>\n");
}

void print_timelines()
{
	if(ctx.branches.count <= 0)
		return;
	
	int i;
	struct ctimeline_branch *br;

	printf("<ul class='timeline'>\n");

	for(i = 0; i < ctx.branches.count; i++) {
		br = &ctx.branches.list[i];
		printf(
		"<li>\n"
		"	<div class='direction-%s'>\n"
		"		<div class='flag-wrapper'>\n"
		"			<span class='flag'>%s</span>\n"
		"			<span class='time-wrapper'><span class='time'>%d-%d</span></span>\n"
		"		</div>\n"
		"		<div class='desc'>%s</div>\n"
		"	</div>\n"
		"</li>\n",
			(i % 2) ? "left" : "right", br->name->s,
			br->age_from, br->age_to, br->desc->s);
	}

	printf("</ul>\n");
}

void print_document_end()
{
	printf("<footer class='footer'>\n");
	printf(
		"<p>generated by <a href='http://git.joursoir.net/ctimeline'>"
		"ctimeline v%s</a></p>\n", CTIMELINE_VERSION);
	printf("</footer>\n");
	printf("</div>\n"); // <!-- id='ctimeline' -->
	printf("</body>\n");
	printf("</html>\n");
}