X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/5db39170b6c979655a0238dcd627e206febed88b..334aed8ab42b9513af0f4458081abc033d66c535:/ui-shared.c diff --git a/ui-shared.c b/ui-shared.c index acc771b..1e19421 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -7,6 +7,9 @@ */ #include "cgit.h" +#include "ui-shared.h" +#include "cmd.h" +#include "html.h" const char cgit_doctype[] = "tm_wday], - tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, + tm->tm_mday, month[tm->tm_mon], 1900 + tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); } -static long ttl_seconds(long ttl) +void cgit_print_error(const char *fmt, ...) { - if (ttl<0) - return 60 * 60 * 24 * 365; - else - return ttl * 60; + va_list ap; + va_start(ap, fmt); + cgit_vprint_error(fmt, ap); + va_end(ap); } -void cgit_print_error(char *msg) +void cgit_vprint_error(const char *fmt, va_list ap) { + va_list cp; html("
| "); - html(cgit_root_title); - html(" | ");
- html(" |
| "); - htmlf("root", cgit_rooturl()); - if (cgit_query_repo) { - htmlf(" : ", cgit_repourl(cgit_repo->url)); - html_txt(cgit_repo->name); - htmlf(" : %s", title); - } - html(" | "); - html(""); - if (show_search) { - html(" |
| "); -} - -void cgit_print_snapshot_start(const char *mimetype, const char *filename, - struct cacheitem *item) -{ - htmlf("Content-Type: %s\n", mimetype); - htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); - htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); - htmlf("Expires: %s\n", http_date(item->st.st_mtime + - ttl_seconds(item->ttl))); - html("\n"); + + if (is_null_sha1(sha1)) { + path1 = "dev/null"; + htmlf("\n--- /%s\n", path1); + } else + htmlf("\n--- a/%s\n", path1); + + if (is_null_sha1(sha2)) { + path2 = "dev/null"; + htmlf("+++ /%s\n", path2); + } else + htmlf("+++ b/%s\n", path2); + } +} + +void filepair_cb_raw(struct diff_filepair *pair) +{ + unsigned long old_size = 0; + unsigned long new_size = 0; + int binary = 0; + + header_raw(pair->one->sha1, pair->one->path, pair->one->mode, + pair->two->sha1, pair->two->path, pair->two->mode); + if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) { + if (S_ISGITLINK(pair->one->mode)) + print_line_raw(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52); + if (S_ISGITLINK(pair->two->mode)) + print_line_raw(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52); + return; + } + if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, + &new_size, &binary, 0, 0, print_line_raw)) + html("Error running diff"); + if (binary) + html("Binary files differ\n"); } | |