about summary refs log tree commit diff
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c42
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)
 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,
@@ -421,13 +423,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))
@@ -483,7 +487,7 @@ void cgit_print_pageheader(char *title, int show_search)
 
 		html("<p>\n<h1>branch</h1>\n");
 		html("<form method='get' action=''>\n");
-		add_hidden_formfields(0, 1);
+		add_hidden_formfields(0, 1, cgit_query_page);
 		html("<select name='h' onchange='this.form.submit();'>\n");
 		for_each_branch_ref(print_branch_option, cgit_query_head);
 		html("</select>\n");
@@ -491,9 +495,11 @@ void cgit_print_pageheader(char *title, int show_search)
 
 		html("<p>\n<h1>search</h1>\n");
 		html("<form method='get' action='");
-		html_attr(cgit_pageurl(cgit_query_repo, "log", NULL));
+		if (cgit_virtual_root)
+			html_attr(cgit_fileurl(cgit_query_repo, "log",
+					       cgit_query_path, NULL));
 		html("'>\n");
-		add_hidden_formfields(1, 0);
+		add_hidden_formfields(1, 0, "log");
 		html("<select name='qt'>\n");
 		html_option("grep", "log msg", cgit_query_grep);
 		html_option("author", "author", cgit_query_grep);
'2019-09-27 19:30:01 -0400'>2019-09-27Fail on HTTP failure status in titleJune McEnroe 2019-09-23Add Trail of LightningJune McEnroe 2019-09-22Revert "Enable cookies in title"June McEnroe This reverts commit 3231fe21d3b389448c9a5ca7b4c91fdd25c9e677. 2019-09-20Enable cookies in titleJune McEnroe Perhaps this will make it less suspicious to Google. Who knows. 2019-09-16Use sensitivity aliases in TF2June McEnroe 2019-09-16Add The Just CityJune McEnroe 2019-09-12Only GET the final redirect locationJune McEnroe 2019-09-12Consume entire bodyJune McEnroe Aborting the request and leaving data around may be causing intermittent errors. Just discard the rest of the data. 2019-09-10Add title -v flagJune McEnroe 2019-09-10Use curl error bufferJune McEnroe 2019-09-10Set Accept-Encoding in titleJune McEnroe Because apparently it's fine for servers to respond with Content-Encoding you didn't ask for, and curl won't decode it if you didn't ask for it. 2019-09-08Set title User-AgentJune McEnroe Some things don't like you if you don't send one. 2019-09-07Add -x flag to titleJune McEnroe 2019-09-07Ignore SIGPIPE in relayJune McEnroe Allows restarting consumers safely. 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe Oops, didn't see this. 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe