diff options
-rw-r--r-- | ui-shared.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/ui-shared.c b/ui-shared.c index a03661a..88dd6b8 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -60,19 +60,21 @@ char *cgit_repourl(const char *reponame) | |||
60 | char *cgit_fileurl(const char *reponame, const char *pagename, | 60 | char *cgit_fileurl(const char *reponame, const char *pagename, |
61 | const char *filename, const char *query) | 61 | const char *filename, const char *query) |
62 | { | 62 | { |
63 | char *tmp; | ||
64 | char *delim; | ||
65 | |||
63 | if (cgit_virtual_root) { | 66 | if (cgit_virtual_root) { |
64 | if (query) | 67 | tmp = fmt("%s/%s/%s/%s", cgit_virtual_root, reponame, |
65 | return fmt("%s/%s/%s/%s?%s", cgit_virtual_root, reponame, | 68 | pagename, (filename ? filename:"")); |
66 | pagename, filename?filename:"", query); | 69 | delim = "?"; |
67 | else | ||
68 | return fmt("%s/%s/%s/", cgit_virtual_root, reponame, | ||
69 | pagename); | ||
70 | } else { | 70 | } else { |
71 | if (query) | 71 | tmp = fmt("?url=%s/%s/%s", reponame, pagename, |
72 | return fmt("?r=%s&p=%s&%s", reponame, pagename, query); | 72 | (filename ? filename : "")); |
73 | else | 73 | delim = "&"; |
74 | return fmt("?r=%s&p=%s", reponame, pagename); | ||
75 | } | 74 | } |
75 | if (query) | ||
76 | tmp = fmt("%s%s%s", tmp, delim, query); | ||
77 | return tmp; | ||
76 | } | 78 | } |
77 | 79 | ||
78 | char *cgit_pageurl(const char *reponame, const char *pagename, | 80 | char *cgit_pageurl(const char *reponame, const char *pagename, |
@@ -421,13 +423,15 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, | |||
421 | return 0; | 423 | return 0; |
422 | } | 424 | } |
423 | 425 | ||
424 | void add_hidden_formfields(int incl_head, int incl_search) | 426 | void add_hidden_formfields(int incl_head, int incl_search, char *page) |
425 | { | 427 | { |
428 | char *url; | ||
429 | |||
426 | if (!cgit_virtual_root) { | 430 | if (!cgit_virtual_root) { |
427 | if (cgit_query_repo) | 431 | url = fmt("%s/%s", cgit_query_repo, page); |
428 | html_hidden("r", cgit_query_repo); | 432 | if (cgit_query_path) |
429 | if (cgit_query_page) | 433 | url = fmt("%s/%s", url, cgit_query_path); |
430 | html_hidden("p", cgit_query_page); | 434 | html_hidden("url", url); |
431 | } | 435 | } |
432 | 436 | ||
433 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) | 437 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) |
@@ -483,7 +487,7 @@ void cgit_print_pageheader(char *title, int show_search) | |||
483 | 487 | ||
484 | html("<p>\n<h1>branch</h1>\n"); | 488 | html("<p>\n<h1>branch</h1>\n"); |
485 | html("<form method='get' action=''>\n"); | 489 | html("<form method='get' action=''>\n"); |
486 | add_hidden_formfields(0, 1); | 490 | add_hidden_formfields(0, 1, cgit_query_page); |
487 | html("<select name='h' onchange='this.form.submit();'>\n"); | 491 | html("<select name='h' onchange='this.form.submit();'>\n"); |
488 | for_each_branch_ref(print_branch_option, cgit_query_head); | 492 | for_each_branch_ref(print_branch_option, cgit_query_head); |
489 | html("</select>\n"); | 493 | html("</select>\n"); |
@@ -491,9 +495,11 @@ void cgit_print_pageheader(char *title, int show_search) | |||
491 | 495 | ||
492 | html("<p>\n<h1>search</h1>\n"); | 496 | html("<p>\n<h1>search</h1>\n"); |
493 | html("<form method='get' action='"); | 497 | html("<form method='get' action='"); |
494 | html_attr(cgit_pageurl(cgit_query_repo, "log", NULL)); | 498 | if (cgit_virtual_root) |
499 | html_attr(cgit_fileurl(cgit_query_repo, "log", | ||
500 | cgit_query_path, NULL)); | ||
495 | html("'>\n"); | 501 | html("'>\n"); |
496 | add_hidden_formfields(1, 0); | 502 | add_hidden_formfields(1, 0, "log"); |
497 | html("<select name='qt'>\n"); | 503 | html("<select name='qt'>\n"); |
498 | html_option("grep", "log msg", cgit_query_grep); | 504 | html_option("grep", "log msg", cgit_query_grep); |
499 | html_option("author", "author", cgit_query_grep); | 505 | html_option("author", "author", cgit_query_grep); |