timekeeper

My first (abandoned unfinished) web application for time tracking
git clone git://jacobedwards.org/timekeeper
Log | Files | Refs | README

index.c (1303B)


      1 #include "common.h"
      2 #include "pages.h"
      3 #include "../frag.h"
      4 
      5 enum kcgi_err
      6 pageindex(struct pagedata *pd)
      7 {
      8 	static char *css[] = { "css/main.css", NULL };
      9 	static struct pagetemplate template = {
     10 		"Timekeeper",
     11 		.css = css
     12 	};
     13 
     14 	enum kcgi_err status;
     15 
     16 	if ((status = tk_startpage(pd, &template, KHTTP_200)) != KCGI_OK)
     17 		return status;
     18 
     19 	if ((status = htmlwithin(pd, KELEM_H1, "Timekeeper Project")) != KCGI_OK)
     20 		return status;
     21 
     22 	if (frag(pd, "synopsis"))
     23 		return KCGI_SYSTEM;
     24 
     25 	if ((status = htmllink(pd, pd->user ? "/logout" : "/login",
     26 	    pd->user ? "Logout" : "Login")) != KCGI_OK)
     27 		return status;
     28 
     29 	if (pd->user) {
     30 		if ((status = khtml_puts(&pd->html, " | ")) != KCGI_OK ||
     31 		    (status = htmllink(pd, pd->pages[PageAccount], "Manage account")))
     32 			return status;
     33 		if ((status = khtml_puts(&pd->html, " | ")) != KCGI_OK ||
     34 		    (status = htmllink(pd, pd->pages[PageMain], "Timekeeper")))
     35 			return status;
     36 	}
     37 
     38 	if ((status = khtml_elem(&pd->html, KELEM_P)) != KCGI_OK ||
     39 	    (status = khtml_elem(&pd->html, KELEM_HR)) != KCGI_OK ||
     40 	    (status = htmllink(pd, pd->pages[PageAbout], "Learn more about the project")) != KCGI_OK ||
     41 	    (status = khtml_putc(&pd->html, '.')) != KCGI_OK ||
     42 	    (status = khtml_closeelem(&pd->html, 1)))
     43 		return status;
     44 
     45 	return endpage(pd, &template);
     46 }