author | Lars Hjemli <hjemli@gmail.com> | 2007-11-03 09:42:37 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-11-03 09:42:37 (UTC) |
commit | 51140311bb3b0d4d0e859d5045ffe4c74478f5fe (patch) (unidiff) | |
tree | 6575f174e32abd5f5d1f481e5f7f5978525ae416 /ui-shared.c | |
parent | df203a293e3ac19245f8761cf7c5808f8735f917 (diff) | |
download | cgit-51140311bb3b0d4d0e859d5045ffe4c74478f5fe.zip cgit-51140311bb3b0d4d0e859d5045ffe4c74478f5fe.tar.gz cgit-51140311bb3b0d4d0e859d5045ffe4c74478f5fe.tar.bz2 |
Add search parameters to cgit_log_link
This makes the [prev] and [next] links work correctly on search results.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c index 1d66940..a03661a 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -173,59 +173,68 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
173 | 173 | ||
174 | static void reporevlink(char *page, char *name, char *title, char *class, | 174 | static void reporevlink(char *page, char *name, char *title, char *class, |
175 | char *head, char *rev, char *path) | 175 | char *head, char *rev, char *path) |
176 | { | 176 | { |
177 | char *delim; | 177 | char *delim; |
178 | 178 | ||
179 | delim = repolink(title, class, page, head, path); | 179 | delim = repolink(title, class, page, head, path); |
180 | if (rev && strcmp(rev, cgit_query_head)) { | 180 | if (rev && strcmp(rev, cgit_query_head)) { |
181 | html(delim); | 181 | html(delim); |
182 | html("id="); | 182 | html("id="); |
183 | html_attr(rev); | 183 | html_attr(rev); |
184 | } | 184 | } |
185 | html("'>"); | 185 | html("'>"); |
186 | html_txt(name); | 186 | html_txt(name); |
187 | html("</a>"); | 187 | html("</a>"); |
188 | } | 188 | } |
189 | 189 | ||
190 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 190 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
191 | char *rev, char *path) | 191 | char *rev, char *path) |
192 | { | 192 | { |
193 | reporevlink("tree", name, title, class, head, rev, path); | 193 | reporevlink("tree", name, title, class, head, rev, path); |
194 | } | 194 | } |
195 | 195 | ||
196 | void cgit_log_link(char *name, char *title, char *class, char *head, | 196 | void cgit_log_link(char *name, char *title, char *class, char *head, |
197 | char *rev, char *path, int ofs) | 197 | char *rev, char *path, int ofs, char *grep, char *pattern) |
198 | { | 198 | { |
199 | char *delim; | 199 | char *delim; |
200 | 200 | ||
201 | delim = repolink(title, class, "log", head, path); | 201 | delim = repolink(title, class, "log", head, path); |
202 | if (rev && strcmp(rev, cgit_query_head)) { | 202 | if (rev && strcmp(rev, cgit_query_head)) { |
203 | html(delim); | 203 | html(delim); |
204 | html("id="); | 204 | html("id="); |
205 | html_attr(rev); | 205 | html_attr(rev); |
206 | delim = "&"; | 206 | delim = "&"; |
207 | } | 207 | } |
208 | if (grep && pattern) { | ||
209 | html(delim); | ||
210 | html("qt="); | ||
211 | html_attr(grep); | ||
212 | delim = "&"; | ||
213 | html(delim); | ||
214 | html("q="); | ||
215 | html_attr(pattern); | ||
216 | } | ||
208 | if (ofs > 0) { | 217 | if (ofs > 0) { |
209 | html(delim); | 218 | html(delim); |
210 | html("ofs="); | 219 | html("ofs="); |
211 | htmlf("%d", ofs); | 220 | htmlf("%d", ofs); |
212 | } | 221 | } |
213 | html("'>"); | 222 | html("'>"); |
214 | html_txt(name); | 223 | html_txt(name); |
215 | html("</a>"); | 224 | html("</a>"); |
216 | } | 225 | } |
217 | 226 | ||
218 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 227 | void cgit_commit_link(char *name, char *title, char *class, char *head, |
219 | char *rev) | 228 | char *rev) |
220 | { | 229 | { |
221 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { | 230 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { |
222 | name[cgit_max_msg_len] = '\0'; | 231 | name[cgit_max_msg_len] = '\0'; |
223 | name[cgit_max_msg_len - 1] = '.'; | 232 | name[cgit_max_msg_len - 1] = '.'; |
224 | name[cgit_max_msg_len - 2] = '.'; | 233 | name[cgit_max_msg_len - 2] = '.'; |
225 | name[cgit_max_msg_len - 3] = '.'; | 234 | name[cgit_max_msg_len - 3] = '.'; |
226 | } | 235 | } |
227 | reporevlink("commit", name, title, class, head, rev, NULL); | 236 | reporevlink("commit", name, title, class, head, rev, NULL); |
228 | } | 237 | } |
229 | 238 | ||
230 | void cgit_refs_link(char *name, char *title, char *class, char *head, | 239 | void cgit_refs_link(char *name, char *title, char *class, char *head, |
231 | char *rev, char *path) | 240 | char *rev, char *path) |
@@ -440,49 +449,49 @@ void add_hidden_formfields(int incl_head, int incl_search) | |||
440 | void cgit_print_pageheader(char *title, int show_search) | 449 | void cgit_print_pageheader(char *title, int show_search) |
441 | { | 450 | { |
442 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; | 451 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; |
443 | int header = 0; | 452 | int header = 0; |
444 | 453 | ||
445 | html("<div id='sidebar'>\n"); | 454 | html("<div id='sidebar'>\n"); |
446 | html("<a href='"); | 455 | html("<a href='"); |
447 | html_attr(cgit_rooturl()); | 456 | html_attr(cgit_rooturl()); |
448 | htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n", | 457 | htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n", |
449 | cgit_logo); | 458 | cgit_logo); |
450 | html("<div class='infobox'>"); | 459 | html("<div class='infobox'>"); |
451 | if (cgit_query_repo) { | 460 | if (cgit_query_repo) { |
452 | html("<h1>"); | 461 | html("<h1>"); |
453 | html_txt(strrpart(cgit_repo->name, 20)); | 462 | html_txt(strrpart(cgit_repo->name, 20)); |
454 | html("</h1>\n"); | 463 | html("</h1>\n"); |
455 | html_txt(cgit_repo->desc); | 464 | html_txt(cgit_repo->desc); |
456 | if (cgit_repo->owner) { | 465 | if (cgit_repo->owner) { |
457 | html("<p>\n<h1>owner</h1>\n"); | 466 | html("<p>\n<h1>owner</h1>\n"); |
458 | html_txt(cgit_repo->owner); | 467 | html_txt(cgit_repo->owner); |
459 | } | 468 | } |
460 | html("<p>\n<h1>navigate</h1>\n"); | 469 | html("<p>\n<h1>navigate</h1>\n"); |
461 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, | 470 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, |
462 | NULL, NULL); | 471 | NULL, NULL); |
463 | cgit_log_link("log", NULL, "menu", cgit_query_head, | 472 | cgit_log_link("log", NULL, "menu", cgit_query_head, |
464 | cgit_query_sha1, cgit_query_path, 0); | 473 | cgit_query_sha1, cgit_query_path, 0, NULL, NULL); |
465 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, | 474 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, |
466 | cgit_query_sha1, NULL); | 475 | cgit_query_sha1, NULL); |
467 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, | 476 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, |
468 | cgit_query_sha1); | 477 | cgit_query_sha1); |
469 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, | 478 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, |
470 | cgit_query_sha1, cgit_query_sha2, | 479 | cgit_query_sha1, cgit_query_sha2, |
471 | cgit_query_path); | 480 | cgit_query_path); |
472 | 481 | ||
473 | for_each_ref(print_archive_ref, &header); | 482 | for_each_ref(print_archive_ref, &header); |
474 | 483 | ||
475 | html("<p>\n<h1>branch</h1>\n"); | 484 | html("<p>\n<h1>branch</h1>\n"); |
476 | html("<form method='get' action=''>\n"); | 485 | html("<form method='get' action=''>\n"); |
477 | add_hidden_formfields(0, 1); | 486 | add_hidden_formfields(0, 1); |
478 | html("<select name='h' onchange='this.form.submit();'>\n"); | 487 | html("<select name='h' onchange='this.form.submit();'>\n"); |
479 | for_each_branch_ref(print_branch_option, cgit_query_head); | 488 | for_each_branch_ref(print_branch_option, cgit_query_head); |
480 | html("</select>\n"); | 489 | html("</select>\n"); |
481 | html("</form>\n"); | 490 | html("</form>\n"); |
482 | 491 | ||
483 | html("<p>\n<h1>search</h1>\n"); | 492 | html("<p>\n<h1>search</h1>\n"); |
484 | html("<form method='get' action='"); | 493 | html("<form method='get' action='"); |
485 | html_attr(cgit_pageurl(cgit_query_repo, "log", NULL)); | 494 | html_attr(cgit_pageurl(cgit_query_repo, "log", NULL)); |
486 | html("'>\n"); | 495 | html("'>\n"); |
487 | add_hidden_formfields(1, 0); | 496 | add_hidden_formfields(1, 0); |
488 | html("<select name='qt'>\n"); | 497 | html("<select name='qt'>\n"); |