about summary refs log tree commit diff stats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index 5aa9119..b736fca 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -503,6 +503,62 @@ void cgit_object_link(struct object *obj)
503 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); 503 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
504} 504}
505 505
506struct string_list_item *lookup_path(struct string_list *list,
507 const char *path)
508{
509 struct string_list_item *item;
510
511 while (path && path[0]) {
512 if ((item = string_list_lookup(list, path)))
513 return item;
514 if (!(path = strchr(path, '/')))
515 break;
516 path++;
517 }
518 return NULL;
519}
520
521void cgit_submodule_link(const char *class, char *path, const char *rev)
522{
523 struct string_list *list;
524 struct string_list_item *item;
525 char tail, *dir;
526 size_t len;
527
528 tail = 0;
529 list = &ctx.repo->submodules;
530 item = lookup_path(list, path);
531 if (!item) {
532 len = strlen(path);
533 tail = path[len - 1];
534 if (tail == '/') {
535 path[len - 1] = 0;
536 item = lookup_path(list, path);
537 }
538 }
539 html("<a ");
540 if (class)
541 htmlf("class='%s' ", class);
542 html("href='");
543 if (item) {
544 html_attr(fmt(item->util, rev));
545 } else if (ctx.repo->module_link) {
546 dir = strrchr(path, '/');
547 if (dir)
548 dir++;
549 else
550 dir = path;
551 html_attr(fmt(ctx.repo->module_link, dir, rev));
552 } else {
553 html("#");
554 }
555 html("'>");
556 html_txt(path);
557 html("</a>");
558 if (item && tail)
559 path[len - 1] = tail;
560}
561
506void cgit_print_date(time_t secs, const char *format, int local_time) 562void cgit_print_date(time_t secs, const char *format, int local_time)
507{ 563{
508 char buf[64]; 564 char buf[64];