-rw-r--r-- | ui-shared.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index 197ee37..4408969 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -373,96 +373,98 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
373 | time_t now, secs; | 373 | time_t now, secs; |
374 | 374 | ||
375 | if (!t) | 375 | if (!t) |
376 | return; | 376 | return; |
377 | time(&now); | 377 | time(&now); |
378 | secs = now - t; | 378 | secs = now - t; |
379 | 379 | ||
380 | if (secs > max_relative && max_relative >= 0) { | 380 | if (secs > max_relative && max_relative >= 0) { |
381 | cgit_print_date(t, format, ctx.cfg.local_time); | 381 | cgit_print_date(t, format, ctx.cfg.local_time); |
382 | return; | 382 | return; |
383 | } | 383 | } |
384 | 384 | ||
385 | if (secs < TM_HOUR * 2) { | 385 | if (secs < TM_HOUR * 2) { |
386 | htmlf("<span class='age-mins'>%.0f min.</span>", | 386 | htmlf("<span class='age-mins'>%.0f min.</span>", |
387 | secs * 1.0 / TM_MIN); | 387 | secs * 1.0 / TM_MIN); |
388 | return; | 388 | return; |
389 | } | 389 | } |
390 | if (secs < TM_DAY * 2) { | 390 | if (secs < TM_DAY * 2) { |
391 | htmlf("<span class='age-hours'>%.0f hours</span>", | 391 | htmlf("<span class='age-hours'>%.0f hours</span>", |
392 | secs * 1.0 / TM_HOUR); | 392 | secs * 1.0 / TM_HOUR); |
393 | return; | 393 | return; |
394 | } | 394 | } |
395 | if (secs < TM_WEEK * 2) { | 395 | if (secs < TM_WEEK * 2) { |
396 | htmlf("<span class='age-days'>%.0f days</span>", | 396 | htmlf("<span class='age-days'>%.0f days</span>", |
397 | secs * 1.0 / TM_DAY); | 397 | secs * 1.0 / TM_DAY); |
398 | return; | 398 | return; |
399 | } | 399 | } |
400 | if (secs < TM_MONTH * 2) { | 400 | if (secs < TM_MONTH * 2) { |
401 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 401 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
402 | secs * 1.0 / TM_WEEK); | 402 | secs * 1.0 / TM_WEEK); |
403 | return; | 403 | return; |
404 | } | 404 | } |
405 | if (secs < TM_YEAR * 2) { | 405 | if (secs < TM_YEAR * 2) { |
406 | htmlf("<span class='age-months'>%.0f months</span>", | 406 | htmlf("<span class='age-months'>%.0f months</span>", |
407 | secs * 1.0 / TM_MONTH); | 407 | secs * 1.0 / TM_MONTH); |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | htmlf("<span class='age-years'>%.0f years</span>", | 410 | htmlf("<span class='age-years'>%.0f years</span>", |
411 | secs * 1.0 / TM_YEAR); | 411 | secs * 1.0 / TM_YEAR); |
412 | } | 412 | } |
413 | 413 | ||
414 | void cgit_print_http_headers(struct cgit_context *ctx) | 414 | void cgit_print_http_headers(struct cgit_context *ctx) |
415 | { | 415 | { |
416 | if (ctx->page.mimetype && ctx->page.charset) | 416 | if (ctx->page.mimetype && ctx->page.charset) |
417 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 417 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
418 | ctx->page.charset); | 418 | ctx->page.charset); |
419 | else if (ctx->page.mimetype) | 419 | else if (ctx->page.mimetype) |
420 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 420 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
421 | if (ctx->page.size) | ||
422 | htmlf("Content-Length: %ld\n", ctx->page.size); | ||
421 | if (ctx->page.filename) | 423 | if (ctx->page.filename) |
422 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 424 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
423 | ctx->page.filename); | 425 | ctx->page.filename); |
424 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 426 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
425 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 427 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
426 | html("\n"); | 428 | html("\n"); |
427 | } | 429 | } |
428 | 430 | ||
429 | void cgit_print_docstart(struct cgit_context *ctx) | 431 | void cgit_print_docstart(struct cgit_context *ctx) |
430 | { | 432 | { |
431 | html(cgit_doctype); | 433 | html(cgit_doctype); |
432 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 434 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
433 | html("<head>\n"); | 435 | html("<head>\n"); |
434 | html("<title>"); | 436 | html("<title>"); |
435 | html_txt(ctx->page.title); | 437 | html_txt(ctx->page.title); |
436 | html("</title>\n"); | 438 | html("</title>\n"); |
437 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 439 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
438 | if (ctx->cfg.robots && *ctx->cfg.robots) | 440 | if (ctx->cfg.robots && *ctx->cfg.robots) |
439 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 441 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
440 | html("<link rel='stylesheet' type='text/css' href='"); | 442 | html("<link rel='stylesheet' type='text/css' href='"); |
441 | html_attr(ctx->cfg.css); | 443 | html_attr(ctx->cfg.css); |
442 | html("'/>\n"); | 444 | html("'/>\n"); |
443 | if (ctx->cfg.favicon) { | 445 | if (ctx->cfg.favicon) { |
444 | html("<link rel='shortcut icon' href='"); | 446 | html("<link rel='shortcut icon' href='"); |
445 | html_attr(ctx->cfg.favicon); | 447 | html_attr(ctx->cfg.favicon); |
446 | html("'/>\n"); | 448 | html("'/>\n"); |
447 | } | 449 | } |
448 | html("</head>\n"); | 450 | html("</head>\n"); |
449 | html("<body>\n"); | 451 | html("<body>\n"); |
450 | } | 452 | } |
451 | 453 | ||
452 | void cgit_print_docend() | 454 | void cgit_print_docend() |
453 | { | 455 | { |
454 | html("</div>"); | 456 | html("</div>"); |
455 | if (ctx.cfg.footer) | 457 | if (ctx.cfg.footer) |
456 | html_include(ctx.cfg.footer); | 458 | html_include(ctx.cfg.footer); |
457 | else { | 459 | else { |
458 | html("<div class='footer'>generated "); | 460 | html("<div class='footer'>generated "); |
459 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); | 461 | cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time); |
460 | htmlf(" by cgit %s", cgit_version); | 462 | htmlf(" by cgit %s", cgit_version); |
461 | html("</div>\n"); | 463 | html("</div>\n"); |
462 | } | 464 | } |
463 | html("</body>\n</html>\n"); | 465 | html("</body>\n</html>\n"); |
464 | } | 466 | } |
465 | 467 | ||
466 | int print_branch_option(const char *refname, const unsigned char *sha1, | 468 | int print_branch_option(const char *refname, const unsigned char *sha1, |
467 | int flags, void *cb_data) | 469 | int flags, void *cb_data) |
468 | { | 470 | { |