/* ui-shared.c: common web output functions * * Copyright (C) 2006 Lars Hjemli * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ #include "cgit.h" #include "ui-shared.h" #include "cmd.h" #include "html.h" const char cgit_doctype[] = "\n"; static char *http_date(time_t t) { static char day[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; static char month[][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; struct tm *tm = gmtime(&t); return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], tm->tm_mday, month[tm->tm_mon], 1900 + tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); } void cgit_print_error(const char *fmt, ...) { va_list ap; va_start(ap, fmt); cgit_vprint_error(fmt, ap); va_end(ap); } void cgit_vprint_error(const char *fmt, va_list ap) { va_list cp; html("
\n"); if (ctx->repo) { cgit_summary_link("summary", NULL, hc(ctx, "summary"), ctx->qry.head); cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head, ctx->qry.sha1, NULL); cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head, NULL, ctx->qry.vpath, 0, NULL, NULL, ctx->qry.showmsg); cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath); cgit_commit_link("commit", NULL, hc(ctx, "commit"), ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath, 0); cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head, ctx->qry.sha1, ctx->qry.sha2, ctx->qry.vpath, 0); if (ctx->repo->max_stats) cgit_stats_link("stats", NULL, hc(ctx, "stats"), ctx->qry.head, ctx->qry.vpath); if (ctx->repo->readme.nr) reporevlink("about", "about", NULL, hc(ctx, "about"), ctx->qry.head, NULL, NULL); html(" | "); html("\n"); } else { site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, NULL, 0); if (ctx->cfg.root_readme) site_link("about", "about", NULL, hc(ctx, "about"), NULL, NULL, 0); html(" | "); html(""); } html(" |