From bdc12a5eb8e122eacf272f9f53c8912f42f3f571 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Sat, 15 May 2021 07:56:30 +0000 Subject: move code that generate html to sub-module 'ui-common' * Generate new html-code --- ui-common.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 ui-common.c (limited to 'ui-common.c') diff --git a/ui-common.c b/ui-common.c new file mode 100644 index 0000000..66ad5f7 --- /dev/null +++ b/ui-common.c @@ -0,0 +1,83 @@ +#include + +#include "ui-common.h" +#include "ctimeline.h" + +void print_http_headers() +{ + printf("Content-type: text/html\n"); + printf("\n"); +} + +void print_document_start() +{ + printf("\n"); + printf("\n"); + printf("%s\n", ctx.head_title); + printf("\n", ctx.css); + printf("\n"); + printf("\n"); +} + +void print_document_header() +{ + printf("
\n"); + printf("
\n"); + printf("\n"); + + printf("\n"); + printf( + "\n", ctx.header_title); + printf("\n"); + + printf("\n"); + printf( + "\n", ctx.header_desc); + printf("\n"); + + printf("

%s

%s
\n"); + printf("
\n"); +} + +void print_timelines() +{ + if(ctx.branches.count <= 0) + return; + + int i; + struct ctimeline_branch *br; + + printf("
    \n"); + + for(i = 0; i < ctx.branches.count; i++) { + br = &ctx.branches.list[i]; + printf( + "
  • \n" + "
    \n" + "
    \n" + " %s\n" + " %d-%d\n" + "
    \n" + "
    %s
    \n" + "
    \n" + "
  • \n", + (i % 2) ? "left" : "right", br->name->s, + br->age_from, br->age_to, br->desc->s); + string_release(br->name); + string_release(br->desc); + } + + printf("
\n"); +} + +void print_document_end() +{ + printf("\n"); + printf("
\n"); // + printf("\n"); + printf("\n"); +} -- cgit v1.2.3-18-g5258