X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/de5e9281719809c5b07051faa88e95bd16e8d485..b2a3d31e8839b53a623b4c99124c2c637d0e3cbb:/ui-shared.c diff --git a/ui-shared.c b/ui-shared.c index 8a00099..37c60b2 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -34,6 +34,21 @@ void cgit_print_error(char *msg) html("\n"); } +char *cgit_hosturl() +{ + char *host, *port; + + host = getenv("SERVER_NAME"); + if (!host) + return NULL; + port = getenv("SERVER_PORT"); + if (port && atoi(port) != 80) + host = xstrdup(fmt("%s:%d", host, atoi(port))); + else + host = xstrdup(host); + return host; +} + char *cgit_rooturl() { if (ctx.cfg.virtual_root) @@ -353,14 +368,17 @@ void cgit_object_link(struct object *obj) html_link_close(); } -void cgit_print_date(time_t secs, char *format) +void cgit_print_date(time_t secs, char *format, int local_time) { char buf[64]; struct tm *time; if (!secs) return; - time = gmtime(&secs); + if(local_time) + time = localtime(&secs); + else + time = gmtime(&secs); strftime(buf, sizeof(buf)-1, format, time); html_txt(buf); } @@ -375,7 +393,7 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) secs = now - t; if (secs > max_relative && max_relative >= 0) { - cgit_print_date(t, format); + cgit_print_date(t, format, ctx.cfg.local_time); return; } @@ -425,6 +443,7 @@ void cgit_print_http_headers(struct cgit_context *ctx) void cgit_print_docstart(struct cgit_context *ctx) { + char *host = cgit_hosturl(); html(cgit_doctype); html("\n"); html("\n"); @@ -437,6 +456,18 @@ void cgit_print_docstart(struct cgit_context *ctx) html("\n"); + if (ctx->cfg.favicon) { + html("\n"); + } + if (host && ctx->repo) { + html(""); + } html("\n"); html("\n"); } @@ -448,7 +479,7 @@ void cgit_print_docend() html_include(ctx.cfg.footer); else { html("\n"); } @@ -513,7 +544,8 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page) html_hidden("url", url); } - if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch)) + if (incl_head && ctx.qry.head && ctx.repo->defbranch && + strcmp(ctx.qry.head, ctx.repo->defbranch)) html_hidden("h", ctx.qry.head); if (ctx.qry.sha1) @@ -567,12 +599,12 @@ void cgit_print_pageheader(struct cgit_context *ctx) html_txt(ctx->cfg.root_title); html("\n"); - html(""); if (ctx->repo) { - html(" colspan='2'>"); html_txt(ctx->repo->desc); + html(""); + html_txt(ctx->repo->owner); } else { - html(">"); if (ctx->cfg.root_desc) html_txt(ctx->cfg.root_desc); else if (ctx->cfg.index_info)