X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/51140311bb3b0d4d0e859d5045ffe4c74478f5fe..e5ca46bf4b974ce3b51d09da4c7ad741aaa70ede:/ui-shared.c diff --git a/ui-shared.c b/ui-shared.c index a03661a..60aa2e3 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -60,19 +60,21 @@ char *cgit_repourl(const char *reponame) char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename, const char *query) { + char *tmp; + char *delim; + if (cgit_virtual_root) { - if (query) - return fmt("%s/%s/%s/%s?%s", cgit_virtual_root, reponame, - pagename, filename?filename:"", query); - else - return fmt("%s/%s/%s/", cgit_virtual_root, reponame, - pagename); + tmp = fmt("%s/%s/%s/%s", cgit_virtual_root, reponame, + pagename, (filename ? filename:"")); + delim = "?"; } else { - if (query) - return fmt("?r=%s&p=%s&%s", reponame, pagename, query); - else - return fmt("?r=%s&p=%s", reponame, pagename); + tmp = fmt("?url=%s/%s/%s", reponame, pagename, + (filename ? filename : "")); + delim = "&"; } + if (query) + tmp = fmt("%s%s%s", tmp, delim, query); + return tmp; } char *cgit_pageurl(const char *reponame, const char *pagename, @@ -270,6 +272,12 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, html(""); } +void cgit_patch_link(char *name, char *title, char *class, char *head, + char *rev) +{ + reporevlink("patch", name, title, class, head, rev, NULL); +} + void cgit_object_link(struct object *obj) { char *page, *arg, *url; @@ -302,6 +310,8 @@ void cgit_print_date(time_t secs, char *format) char buf[64]; struct tm *time; + if (!secs) + return; time = gmtime(&secs); strftime(buf, sizeof(buf)-1, format, time); html_txt(buf); @@ -311,6 +321,8 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) { time_t now, secs; + if (!t) + return; time(&now); secs = now - t; @@ -350,18 +362,20 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) void cgit_print_docstart(char *title, struct cacheitem *item) { - html("Content-Type: text/html; charset=utf-8\n"); + html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); 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"); html(cgit_doctype); - html("\n"); + html("\n"); html("\n"); html(""); html_txt(title); html("\n"); htmlf("\n", cgit_version); + if (cgit_robots && *cgit_robots) + htmlf("\n", cgit_robots); html("\n"); @@ -371,7 +385,7 @@ void cgit_print_docstart(char *title, struct cacheitem *item) void cgit_print_docend() { - html("\n\n\n\n\n"); + html("\n\n
\n\n\n"); } int print_branch_option(const char *refname, const unsigned char *sha1, @@ -409,7 +423,7 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, hashcpy(fileid, sha1); } if (!*header) { - html("

download

"); + html("

download

\n"); *header = 1; } url = cgit_pageurl(cgit_query_repo, "blob", @@ -421,13 +435,15 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, return 0; } -void add_hidden_formfields(int incl_head, int incl_search) +void add_hidden_formfields(int incl_head, int incl_search, char *page) { + char *url; + if (!cgit_virtual_root) { - if (cgit_query_repo) - html_hidden("r", cgit_query_repo); - if (cgit_query_page) - html_hidden("p", cgit_query_page); + url = fmt("%s/%s", cgit_query_repo, page); + if (cgit_query_path) + url = fmt("%s/%s", url, cgit_query_path); + html_hidden("url", url); } if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) @@ -450,50 +466,76 @@ void cgit_print_pageheader(char *title, int show_search) { static const char *default_info = "This is cgit, a fast webinterface for git repositories"; int header = 0; + char *url; - html("\n
\n"); + html("\n"); }