diff options
author | Joursoir <chat@joursoir.net> | 2021-05-15 07:56:30 +0000 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2021-05-15 07:56:30 +0000 |
commit | bdc12a5eb8e122eacf272f9f53c8912f42f3f571 (patch) | |
tree | d42c4b46a3d62715db960f2a22fbe2f329036b10 /ui-common.c | |
parent | 74deb2f3fc4e23ca73ea97059080fd87dfbba81e (diff) | |
download | ctimeline-bdc12a5eb8e122eacf272f9f53c8912f42f3f571.tar.gz ctimeline-bdc12a5eb8e122eacf272f9f53c8912f42f3f571.tar.bz2 ctimeline-bdc12a5eb8e122eacf272f9f53c8912f42f3f571.zip |
move code that generate html to sub-module 'ui-common'
* Generate new html-code
Diffstat (limited to 'ui-common.c')
-rw-r--r-- | ui-common.c | 83 |
1 files changed, 83 insertions, 0 deletions
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 <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); + printf("<link rel='stylesheet' href='%s'>\n", ctx.css); + 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); + printf("</tr>\n"); + + printf("<tr class='sub_text'>\n"); + printf( + "<td>%s</td>\n", ctx.header_desc); + 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); + string_release(br->name); + string_release(br->desc); + } + + 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"); +} |