diff options
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 260 |
1 files changed, 193 insertions, 67 deletions
diff --git a/ui-shared.c b/ui-shared.c index 8a7cc32..c398d7a 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -27,7 +27,7 @@ static char *http_date(time_t t) | |||
27 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 27 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
28 | } | 28 | } |
29 | 29 | ||
30 | void cgit_print_error(char *msg) | 30 | void cgit_print_error(const char *msg) |
31 | { | 31 | { |
32 | html("<div class='error'>"); | 32 | html("<div class='error'>"); |
33 | html_txt(msg); | 33 | html_txt(msg); |
@@ -133,7 +133,7 @@ char *cgit_currurl() | |||
133 | return fmt("%s/", ctx.cfg.virtual_root); | 133 | return fmt("%s/", ctx.cfg.virtual_root); |
134 | } | 134 | } |
135 | 135 | ||
136 | static void site_url(char *page, char *search, int ofs) | 136 | static void site_url(const char *page, const char *search, int ofs) |
137 | { | 137 | { |
138 | char *delim = "?"; | 138 | char *delim = "?"; |
139 | 139 | ||
@@ -160,8 +160,8 @@ static void site_url(char *page, char *search, int ofs) | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | static void site_link(char *page, char *name, char *title, char *class, | 163 | static void site_link(const char *page, const char *name, const char *title, |
164 | char *search, int ofs) | 164 | const char *class, const char *search, int ofs) |
165 | { | 165 | { |
166 | html("<a"); | 166 | html("<a"); |
167 | if (title) { | 167 | if (title) { |
@@ -181,14 +181,14 @@ static void site_link(char *page, char *name, char *title, char *class, | |||
181 | html("</a>"); | 181 | html("</a>"); |
182 | } | 182 | } |
183 | 183 | ||
184 | void cgit_index_link(char *name, char *title, char *class, char *pattern, | 184 | void cgit_index_link(const char *name, const char *title, const char *class, |
185 | int ofs) | 185 | const char *pattern, int ofs) |
186 | { | 186 | { |
187 | site_link(NULL, name, title, class, pattern, ofs); | 187 | site_link(NULL, name, title, class, pattern, ofs); |
188 | } | 188 | } |
189 | 189 | ||
190 | static char *repolink(char *title, char *class, char *page, char *head, | 190 | static char *repolink(const char *title, const char *class, const char *page, |
191 | char *path) | 191 | const char *head, const char *path) |
192 | { | 192 | { |
193 | char *delim = "?"; | 193 | char *delim = "?"; |
194 | 194 | ||
@@ -240,8 +240,9 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
240 | return fmt("%s", delim); | 240 | return fmt("%s", delim); |
241 | } | 241 | } |
242 | 242 | ||
243 | static void reporevlink(char *page, char *name, char *title, char *class, | 243 | static void reporevlink(const char *page, const char *name, const char *title, |
244 | char *head, char *rev, char *path) | 244 | const char *class, const char *head, const char *rev, |
245 | const char *path) | ||
245 | { | 246 | { |
246 | char *delim; | 247 | char *delim; |
247 | 248 | ||
@@ -256,32 +257,33 @@ static void reporevlink(char *page, char *name, char *title, char *class, | |||
256 | html("</a>"); | 257 | html("</a>"); |
257 | } | 258 | } |
258 | 259 | ||
259 | void cgit_summary_link(char *name, char *title, char *class, char *head) | 260 | void cgit_summary_link(const char *name, const char *title, const char *class, |
261 | const char *head) | ||
260 | { | 262 | { |
261 | reporevlink(NULL, name, title, class, head, NULL, NULL); | 263 | reporevlink(NULL, name, title, class, head, NULL, NULL); |
262 | } | 264 | } |
263 | 265 | ||
264 | void cgit_tag_link(char *name, char *title, char *class, char *head, | 266 | void cgit_tag_link(const char *name, const char *title, const char *class, |
265 | char *rev) | 267 | const char *head, const char *rev) |
266 | { | 268 | { |
267 | reporevlink("tag", name, title, class, head, rev, NULL); | 269 | reporevlink("tag", name, title, class, head, rev, NULL); |
268 | } | 270 | } |
269 | 271 | ||
270 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 272 | void cgit_tree_link(const char *name, const char *title, const char *class, |
271 | char *rev, char *path) | 273 | const char *head, const char *rev, const char *path) |
272 | { | 274 | { |
273 | reporevlink("tree", name, title, class, head, rev, path); | 275 | reporevlink("tree", name, title, class, head, rev, path); |
274 | } | 276 | } |
275 | 277 | ||
276 | void cgit_plain_link(char *name, char *title, char *class, char *head, | 278 | void cgit_plain_link(const char *name, const char *title, const char *class, |
277 | char *rev, char *path) | 279 | const char *head, const char *rev, const char *path) |
278 | { | 280 | { |
279 | reporevlink("plain", name, title, class, head, rev, path); | 281 | reporevlink("plain", name, title, class, head, rev, path); |
280 | } | 282 | } |
281 | 283 | ||
282 | void cgit_log_link(char *name, char *title, char *class, char *head, | 284 | void cgit_log_link(const char *name, const char *title, const char *class, |
283 | char *rev, char *path, int ofs, char *grep, char *pattern, | 285 | const char *head, const char *rev, const char *path, |
284 | int showmsg) | 286 | int ofs, const char *grep, const char *pattern, int showmsg) |
285 | { | 287 | { |
286 | char *delim; | 288 | char *delim; |
287 | 289 | ||
@@ -316,8 +318,9 @@ void cgit_log_link(char *name, char *title, char *class, char *head, | |||
316 | html("</a>"); | 318 | html("</a>"); |
317 | } | 319 | } |
318 | 320 | ||
319 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 321 | void cgit_commit_link(char *name, const char *title, const char *class, |
320 | char *rev) | 322 | const char *head, const char *rev, const char *path, |
323 | int toggle_ssdiff) | ||
321 | { | 324 | { |
322 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { | 325 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { |
323 | name[ctx.cfg.max_msg_len] = '\0'; | 326 | name[ctx.cfg.max_msg_len] = '\0'; |
@@ -325,23 +328,48 @@ void cgit_commit_link(char *name, char *title, char *class, char *head, | |||
325 | name[ctx.cfg.max_msg_len - 2] = '.'; | 328 | name[ctx.cfg.max_msg_len - 2] = '.'; |
326 | name[ctx.cfg.max_msg_len - 3] = '.'; | 329 | name[ctx.cfg.max_msg_len - 3] = '.'; |
327 | } | 330 | } |
328 | reporevlink("commit", name, title, class, head, rev, NULL); | 331 | |
332 | char *delim; | ||
333 | |||
334 | delim = repolink(title, class, "commit", head, path); | ||
335 | if (rev && strcmp(rev, ctx.qry.head)) { | ||
336 | html(delim); | ||
337 | html("id="); | ||
338 | html_url_arg(rev); | ||
339 | delim = "&"; | ||
340 | } | ||
341 | if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { | ||
342 | html(delim); | ||
343 | html("ss=1"); | ||
344 | delim = "&"; | ||
345 | } | ||
346 | if (ctx.qry.context > 0 && ctx.qry.context != 3) { | ||
347 | html(delim); | ||
348 | html("context="); | ||
349 | htmlf("%d", ctx.qry.context); | ||
350 | delim = "&"; | ||
351 | } | ||
352 | html("'>"); | ||
353 | html_txt(name); | ||
354 | html("</a>"); | ||
329 | } | 355 | } |
330 | 356 | ||
331 | void cgit_refs_link(char *name, char *title, char *class, char *head, | 357 | void cgit_refs_link(const char *name, const char *title, const char *class, |
332 | char *rev, char *path) | 358 | const char *head, const char *rev, const char *path) |
333 | { | 359 | { |
334 | reporevlink("refs", name, title, class, head, rev, path); | 360 | reporevlink("refs", name, title, class, head, rev, path); |
335 | } | 361 | } |
336 | 362 | ||
337 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, | 363 | void cgit_snapshot_link(const char *name, const char *title, const char *class, |
338 | char *rev, char *archivename) | 364 | const char *head, const char *rev, |
365 | const char *archivename) | ||
339 | { | 366 | { |
340 | reporevlink("snapshot", name, title, class, head, rev, archivename); | 367 | reporevlink("snapshot", name, title, class, head, rev, archivename); |
341 | } | 368 | } |
342 | 369 | ||
343 | void cgit_diff_link(char *name, char *title, char *class, char *head, | 370 | void cgit_diff_link(const char *name, const char *title, const char *class, |
344 | char *new_rev, char *old_rev, char *path) | 371 | const char *head, const char *new_rev, const char *old_rev, |
372 | const char *path, int toggle_ssdiff) | ||
345 | { | 373 | { |
346 | char *delim; | 374 | char *delim; |
347 | 375 | ||
@@ -356,24 +384,94 @@ void cgit_diff_link(char *name, char *title, char *class, char *head, | |||
356 | html(delim); | 384 | html(delim); |
357 | html("id2="); | 385 | html("id2="); |
358 | html_url_arg(old_rev); | 386 | html_url_arg(old_rev); |
387 | delim = "&"; | ||
388 | } | ||
389 | if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { | ||
390 | html(delim); | ||
391 | html("ss=1"); | ||
392 | delim = "&"; | ||
393 | } | ||
394 | if (ctx.qry.context > 0 && ctx.qry.context != 3) { | ||
395 | html(delim); | ||
396 | html("context="); | ||
397 | htmlf("%d", ctx.qry.context); | ||
398 | delim = "&"; | ||
359 | } | 399 | } |
360 | html("'>"); | 400 | html("'>"); |
361 | html_txt(name); | 401 | html_txt(name); |
362 | html("</a>"); | 402 | html("</a>"); |
363 | } | 403 | } |
364 | 404 | ||
365 | void cgit_patch_link(char *name, char *title, char *class, char *head, | 405 | void cgit_patch_link(const char *name, const char *title, const char *class, |
366 | char *rev) | 406 | const char *head, const char *rev, const char *path) |
367 | { | 407 | { |
368 | reporevlink("patch", name, title, class, head, rev, NULL); | 408 | reporevlink("patch", name, title, class, head, rev, path); |
369 | } | 409 | } |
370 | 410 | ||
371 | void cgit_stats_link(char *name, char *title, char *class, char *head, | 411 | void cgit_stats_link(const char *name, const char *title, const char *class, |
372 | char *path) | 412 | const char *head, const char *path) |
373 | { | 413 | { |
374 | reporevlink("stats", name, title, class, head, NULL, path); | 414 | reporevlink("stats", name, title, class, head, NULL, path); |
375 | } | 415 | } |
376 | 416 | ||
417 | void cgit_self_link(char *name, const char *title, const char *class, | ||
418 | struct cgit_context *ctx) | ||
419 | { | ||
420 | if (!strcmp(ctx->qry.page, "repolist")) | ||
421 | return cgit_index_link(name, title, class, ctx->qry.search, | ||
422 | ctx->qry.ofs); | ||
423 | else if (!strcmp(ctx->qry.page, "summary")) | ||
424 | return cgit_summary_link(name, title, class, ctx->qry.head); | ||
425 | else if (!strcmp(ctx->qry.page, "tag")) | ||
426 | return cgit_tag_link(name, title, class, ctx->qry.head, | ||
427 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL); | ||
428 | else if (!strcmp(ctx->qry.page, "tree")) | ||
429 | return cgit_tree_link(name, title, class, ctx->qry.head, | ||
430 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | ||
431 | ctx->qry.path); | ||
432 | else if (!strcmp(ctx->qry.page, "plain")) | ||
433 | return cgit_plain_link(name, title, class, ctx->qry.head, | ||
434 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | ||
435 | ctx->qry.path); | ||
436 | else if (!strcmp(ctx->qry.page, "log")) | ||
437 | return cgit_log_link(name, title, class, ctx->qry.head, | ||
438 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | ||
439 | ctx->qry.path, ctx->qry.ofs, | ||
440 | ctx->qry.grep, ctx->qry.search, | ||
441 | ctx->qry.showmsg); | ||
442 | else if (!strcmp(ctx->qry.page, "commit")) | ||
443 | return cgit_commit_link(name, title, class, ctx->qry.head, | ||
444 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | ||
445 | ctx->qry.path, 0); | ||
446 | else if (!strcmp(ctx->qry.page, "patch")) | ||
447 | return cgit_patch_link(name, title, class, ctx->qry.head, | ||
448 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | ||
449 | ctx->qry.path); | ||
450 | else if (!strcmp(ctx->qry.page, "refs")) | ||
451 | return cgit_refs_link(name, title, class, ctx->qry.head, | ||
452 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | ||
453 | ctx->qry.path); | ||
454 | else if (!strcmp(ctx->qry.page, "snapshot")) | ||
455 | return cgit_snapshot_link(name, title, class, ctx->qry.head, | ||
456 | ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, | ||
457 | ctx->qry.path); | ||
458 | else if (!strcmp(ctx->qry.page, "diff")) | ||
459 | return cgit_diff_link(name, title, class, ctx->qry.head, | ||
460 | ctx->qry.sha1, ctx->qry.sha2, | ||
461 | ctx->qry.path, 0); | ||
462 | else if (!strcmp(ctx->qry.page, "stats")) | ||
463 | return cgit_stats_link(name, title, class, ctx->qry.head, | ||
464 | ctx->qry.path); | ||
465 | |||
466 | /* Don't known how to make link for this page */ | ||
467 | repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path); | ||
468 | html("><!-- cgit_self_link() doesn't know how to make link for page '"); | ||
469 | html_txt(ctx->qry.page); | ||
470 | html("' -->"); | ||
471 | html_txt(name); | ||
472 | html("</a>"); | ||
473 | } | ||
474 | |||
377 | void cgit_object_link(struct object *obj) | 475 | void cgit_object_link(struct object *obj) |
378 | { | 476 | { |
379 | char *page, *shortrev, *fullrev, *name; | 477 | char *page, *shortrev, *fullrev, *name; |
@@ -383,7 +481,7 @@ void cgit_object_link(struct object *obj) | |||
383 | shortrev[10] = '\0'; | 481 | shortrev[10] = '\0'; |
384 | if (obj->type == OBJ_COMMIT) { | 482 | if (obj->type == OBJ_COMMIT) { |
385 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, | 483 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, |
386 | ctx.qry.head, fullrev); | 484 | ctx.qry.head, fullrev, NULL, 0); |
387 | return; | 485 | return; |
388 | } else if (obj->type == OBJ_TREE) | 486 | } else if (obj->type == OBJ_TREE) |
389 | page = "tree"; | 487 | page = "tree"; |
@@ -395,7 +493,7 @@ void cgit_object_link(struct object *obj) | |||
395 | reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); | 493 | reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); |
396 | } | 494 | } |
397 | 495 | ||
398 | void cgit_print_date(time_t secs, char *format, int local_time) | 496 | void cgit_print_date(time_t secs, const char *format, int local_time) |
399 | { | 497 | { |
400 | char buf[64]; | 498 | char buf[64]; |
401 | struct tm *time; | 499 | struct tm *time; |
@@ -410,7 +508,7 @@ void cgit_print_date(time_t secs, char *format, int local_time) | |||
410 | html_txt(buf); | 508 | html_txt(buf); |
411 | } | 509 | } |
412 | 510 | ||
413 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 511 | void cgit_print_age(time_t t, time_t max_relative, const char *format) |
414 | { | 512 | { |
415 | time_t now, secs; | 513 | time_t now, secs; |
416 | 514 | ||
@@ -509,7 +607,7 @@ void cgit_print_docstart(struct cgit_context *ctx) | |||
509 | html("<link rel='alternate' title='Atom feed' href='"); | 607 | html("<link rel='alternate' title='Atom feed' href='"); |
510 | html(cgit_httpscheme()); | 608 | html(cgit_httpscheme()); |
511 | html_attr(cgit_hosturl()); | 609 | html_attr(cgit_hosturl()); |
512 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | 610 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.vpath, |
513 | fmt("h=%s", ctx->qry.head))); | 611 | fmt("h=%s", ctx->qry.head))); |
514 | html("' type='application/atom+xml'/>\n"); | 612 | html("' type='application/atom+xml'/>\n"); |
515 | } | 613 | } |
@@ -589,14 +687,15 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, | |||
589 | return 0; | 687 | return 0; |
590 | } | 688 | } |
591 | 689 | ||
592 | void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page) | 690 | void cgit_add_hidden_formfields(int incl_head, int incl_search, |
691 | const char *page) | ||
593 | { | 692 | { |
594 | char *url; | 693 | char *url; |
595 | 694 | ||
596 | if (!ctx.cfg.virtual_root) { | 695 | if (!ctx.cfg.virtual_root) { |
597 | url = fmt("%s/%s", ctx.qry.repo, page); | 696 | url = fmt("%s/%s", ctx.qry.repo, page); |
598 | if (ctx.qry.path) | 697 | if (ctx.qry.vpath) |
599 | url = fmt("%s/%s", url, ctx.qry.path); | 698 | url = fmt("%s/%s", url, ctx.qry.vpath); |
600 | html_hidden("url", url); | 699 | html_hidden("url", url); |
601 | } | 700 | } |
602 | 701 | ||
@@ -619,11 +718,30 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page) | |||
619 | } | 718 | } |
620 | } | 719 | } |
621 | 720 | ||
622 | const char *fallback_cmd = "repolist"; | 721 | static const char *hc(struct cgit_context *ctx, const char *page) |
722 | { | ||
723 | return strcmp(ctx->qry.page, page) ? NULL : "active"; | ||
724 | } | ||
623 | 725 | ||
624 | char *hc(struct cgit_cmd *cmd, const char *page) | 726 | static void cgit_print_path_crumbs(struct cgit_context *ctx, char *path) |
625 | { | 727 | { |
626 | return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active"); | 728 | char *old_path = ctx->qry.path; |
729 | char *p = path, *q, *end = path + strlen(path); | ||
730 | |||
731 | ctx->qry.path = NULL; | ||
732 | cgit_self_link("root", NULL, NULL, ctx); | ||
733 | ctx->qry.path = p = path; | ||
734 | while (p < end) { | ||
735 | if (!(q = strchr(p, '/'))) | ||
736 | q = end; | ||
737 | *q = '\0'; | ||
738 | html_txt("/"); | ||
739 | cgit_self_link(p, NULL, NULL, ctx); | ||
740 | if (q < end) | ||
741 | *q = '/'; | ||
742 | p = q + 1; | ||
743 | } | ||
744 | ctx->qry.path = old_path; | ||
627 | } | 745 | } |
628 | 746 | ||
629 | static void print_header(struct cgit_context *ctx) | 747 | static void print_header(struct cgit_context *ctx) |
@@ -675,47 +793,44 @@ static void print_header(struct cgit_context *ctx) | |||
675 | 793 | ||
676 | void cgit_print_pageheader(struct cgit_context *ctx) | 794 | void cgit_print_pageheader(struct cgit_context *ctx) |
677 | { | 795 | { |
678 | struct cgit_cmd *cmd = cgit_get_cmd(ctx); | ||
679 | |||
680 | if (!cmd && ctx->repo) | ||
681 | fallback_cmd = "summary"; | ||
682 | |||
683 | html("<div id='cgit'>"); | 796 | html("<div id='cgit'>"); |
684 | if (!ctx->cfg.noheader) | 797 | if (!ctx->cfg.noheader) |
685 | print_header(ctx); | 798 | print_header(ctx); |
686 | 799 | ||
687 | html("<table class='tabs'><tr><td>\n"); | 800 | html("<table class='tabs'><tr><td>\n"); |
688 | if (ctx->repo) { | 801 | if (ctx->repo) { |
689 | cgit_summary_link("summary", NULL, hc(cmd, "summary"), | 802 | cgit_summary_link("summary", NULL, hc(ctx, "summary"), |
690 | ctx->qry.head); | 803 | ctx->qry.head); |
691 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, | 804 | cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head, |
692 | ctx->qry.sha1, NULL); | 805 | ctx->qry.sha1, NULL); |
693 | cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, | 806 | cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head, |
694 | NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg); | 807 | NULL, ctx->qry.vpath, 0, NULL, NULL, |
695 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, | 808 | ctx->qry.showmsg); |
696 | ctx->qry.sha1, NULL); | 809 | cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head, |
697 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), | 810 | ctx->qry.sha1, ctx->qry.vpath); |
698 | ctx->qry.head, ctx->qry.sha1); | 811 | cgit_commit_link("commit", NULL, hc(ctx, "commit"), |
699 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, | 812 | ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath, 0); |
700 | ctx->qry.sha1, ctx->qry.sha2, NULL); | 813 | cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head, |
814 | ctx->qry.sha1, ctx->qry.sha2, ctx->qry.vpath, 0); | ||
701 | if (ctx->repo->max_stats) | 815 | if (ctx->repo->max_stats) |
702 | cgit_stats_link("stats", NULL, hc(cmd, "stats"), | 816 | cgit_stats_link("stats", NULL, hc(ctx, "stats"), |
703 | ctx->qry.head, NULL); | 817 | ctx->qry.head, ctx->qry.vpath); |
704 | if (ctx->repo->readme) | 818 | if (ctx->repo->readme) |
705 | reporevlink("about", "about", NULL, | 819 | reporevlink("about", "about", NULL, |
706 | hc(cmd, "about"), ctx->qry.head, NULL, | 820 | hc(ctx, "about"), ctx->qry.head, NULL, |
707 | NULL); | 821 | NULL); |
708 | html("</td><td class='form'>"); | 822 | html("</td><td class='form'>"); |
709 | html("<form class='right' method='get' action='"); | 823 | html("<form class='right' method='get' action='"); |
710 | if (ctx->cfg.virtual_root) | 824 | if (ctx->cfg.virtual_root) |
711 | html_url_path(cgit_fileurl(ctx->qry.repo, "log", | 825 | html_url_path(cgit_fileurl(ctx->qry.repo, "log", |
712 | ctx->qry.path, NULL)); | 826 | ctx->qry.vpath, NULL)); |
713 | html("'>\n"); | 827 | html("'>\n"); |
714 | cgit_add_hidden_formfields(1, 0, "log"); | 828 | cgit_add_hidden_formfields(1, 0, "log"); |
715 | html("<select name='qt'>\n"); | 829 | html("<select name='qt'>\n"); |
716 | html_option("grep", "log msg", ctx->qry.grep); | 830 | html_option("grep", "log msg", ctx->qry.grep); |
717 | html_option("author", "author", ctx->qry.grep); | 831 | html_option("author", "author", ctx->qry.grep); |
718 | html_option("committer", "committer", ctx->qry.grep); | 832 | html_option("committer", "committer", ctx->qry.grep); |
833 | html_option("range", "range", ctx->qry.grep); | ||
719 | html("</select>\n"); | 834 | html("</select>\n"); |
720 | html("<input class='txt' type='text' size='10' name='q' value='"); | 835 | html("<input class='txt' type='text' size='10' name='q' value='"); |
721 | html_attr(ctx->qry.search); | 836 | html_attr(ctx->qry.search); |
@@ -723,9 +838,9 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
723 | html("<input type='submit' value='search'/>\n"); | 838 | html("<input type='submit' value='search'/>\n"); |
724 | html("</form>\n"); | 839 | html("</form>\n"); |
725 | } else { | 840 | } else { |
726 | site_link(NULL, "index", NULL, hc(cmd, "repolist"), NULL, 0); | 841 | site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, 0); |
727 | if (ctx->cfg.root_readme) | 842 | if (ctx->cfg.root_readme) |
728 | site_link("about", "about", NULL, hc(cmd, "about"), | 843 | site_link("about", "about", NULL, hc(ctx, "about"), |
729 | NULL, 0); | 844 | NULL, 0); |
730 | html("</td><td class='form'>"); | 845 | html("</td><td class='form'>"); |
731 | html("<form method='get' action='"); | 846 | html("<form method='get' action='"); |
@@ -738,6 +853,12 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
738 | html("</form>"); | 853 | html("</form>"); |
739 | } | 854 | } |
740 | html("</td></tr></table>\n"); | 855 | html("</td></tr></table>\n"); |
856 | if (ctx->qry.vpath) { | ||
857 | html("<div class='path'>"); | ||
858 | html("path: "); | ||
859 | cgit_print_path_crumbs(ctx, ctx->qry.vpath); | ||
860 | html("</div>"); | ||
861 | } | ||
741 | html("<div class='content'>"); | 862 | html("<div class='content'>"); |
742 | } | 863 | } |
743 | 864 | ||
@@ -760,13 +881,18 @@ void cgit_print_snapshot_links(const char *repo, const char *head, | |||
760 | const char *hex, int snapshots) | 881 | const char *hex, int snapshots) |
761 | { | 882 | { |
762 | const struct cgit_snapshot_format* f; | 883 | const struct cgit_snapshot_format* f; |
884 | char *prefix; | ||
763 | char *filename; | 885 | char *filename; |
886 | unsigned char sha1[20]; | ||
764 | 887 | ||
888 | if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 && | ||
889 | (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1])) | ||
890 | hex++; | ||
891 | prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex)); | ||
765 | for (f = cgit_snapshot_formats; f->suffix; f++) { | 892 | for (f = cgit_snapshot_formats; f->suffix; f++) { |
766 | if (!(snapshots & f->bit)) | 893 | if (!(snapshots & f->bit)) |
767 | continue; | 894 | continue; |
768 | filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, | 895 | filename = fmt("%s%s", prefix, f->suffix); |
769 | f->suffix); | ||
770 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); | 896 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); |
771 | html("<br/>"); | 897 | html("<br/>"); |
772 | } | 898 | } |