aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorGravatar Jason A. Donenfeld <Jason@zx2c4.com>2013-03-21 04:21:25 (JST)
committerGravatar Jason A. Donenfeld <Jason@zx2c4.com>2013-03-21 04:21:25 (JST)
commit0255821e22678d4c58c809efe17bf2798835d5b9 (patch)
treed4679ff23796406648cf83ff0b98940ba844c5e1 /ui-shared.c
parent6d8a789d61f3a682bc040f1f7f44050b1f723546 (diff)
parent59fe348deaa270434f05afc56ca8d13618af9ca9 (diff)
downloadcgit-0255821e22678d4c58c809efe17bf2798835d5b9.zip
cgit-0255821e22678d4c58c809efe17bf2798835d5b9.tar.gz
Merge branch 'wip'
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c64
1 files changed, 7 insertions, 57 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 80f4aee..968933f 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -121,18 +121,6 @@ const char *cgit_repobasename(const char *reponame)
121 return rvbuf; 121 return rvbuf;
122} 122}
123 123
124char *cgit_currurl()
125{
126 if (!ctx.cfg.virtual_root)
127 return ctx.cfg.script_name;
128 else if (ctx.qry.page)
129 return fmt("%s/%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo, ctx.qry.page);
130 else if (ctx.qry.repo)
131 return fmt("%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo);
132 else
133 return fmt("%s/", ctx.cfg.virtual_root);
134}
135
136static void site_url(const char *page, const char *search, const char *sort, int ofs) 124static void site_url(const char *page, const char *search, const char *sort, int ofs)
137{ 125{
138 char *delim = "?"; 126 char *delim = "?";
@@ -433,8 +421,8 @@ void cgit_stats_link(const char *name, const char *title, const char *class,
433 reporevlink("stats", name, title, class, head, NULL, path); 421 reporevlink("stats", name, title, class, head, NULL, path);
434} 422}
435 423
436void cgit_self_link(char *name, const char *title, const char *class, 424static void cgit_self_link(char *name, const char *title, const char *class,
437 struct cgit_context *ctx) 425 struct cgit_context *ctx)
438{ 426{
439 if (!strcmp(ctx->qry.page, "repolist")) 427 if (!strcmp(ctx->qry.page, "repolist"))
440 cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.sort, 428 cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.sort,
@@ -513,8 +501,8 @@ void cgit_object_link(struct object *obj)
513 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); 501 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
514} 502}
515 503
516struct string_list_item *lookup_path(struct string_list *list, 504static struct string_list_item *lookup_path(struct string_list *list,
517 const char *path) 505 const char *path)
518{ 506{
519 struct string_list_item *item; 507 struct string_list_item *item;
520 508
@@ -717,53 +705,14 @@ void cgit_print_docend()
717 html("</body>\n</html>\n"); 705 html("</body>\n</html>\n");
718} 706}
719 707
720int print_branch_option(const char *refname, const unsigned char *sha1, 708static int print_branch_option(const char *refname, const unsigned char *sha1,
721 int flags, void *cb_data) 709 int flags, void *cb_data)
722{ 710{
723 char *name = (char *)refname; 711 char *name = (char *)refname;
724 html_option(name, name, ctx.qry.head); 712 html_option(name, name, ctx.qry.head);
725 return 0; 713 return 0;
726} 714}
727 715
728int print_archive_ref(const char *refname, const unsigned char *sha1,
729 int flags, void *cb_data)
730{
731 struct tag *tag;
732 struct taginfo *info;
733 struct object *obj;
734 char buf[256], *url;
735 unsigned char fileid[20];
736 int *header = (int *)cb_data;
737
738 if (prefixcmp(refname, "refs/archives"))
739 return 0;
740 strncpy(buf, refname + 14, sizeof(buf));
741 obj = parse_object(sha1);
742 if (!obj)
743 return 1;
744 if (obj->type == OBJ_TAG) {
745 tag = lookup_tag(sha1);
746 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
747 return 0;
748 hashcpy(fileid, tag->tagged->sha1);
749 } else if (obj->type != OBJ_BLOB) {
750 return 0;
751 } else {
752 hashcpy(fileid, sha1);
753 }
754 if (!*header) {
755 html("<h1>download</h1>\n");
756 *header = 1;
757 }
758 url = cgit_pageurl(ctx.qry.repo, "blob",
759 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid),
760 buf));
761 html_link_open(url, NULL, "menu");
762 html_txt(strlpart(buf, 20));
763 html_link_close();
764 return 0;
765}
766
767void cgit_add_hidden_formfields(int incl_head, int incl_search, 716void cgit_add_hidden_formfields(int incl_head, int incl_search,
768 const char *page) 717 const char *page)
769{ 718{
@@ -983,4 +932,5 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
983 cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); 932 cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
984 html("<br/>"); 933 html("<br/>");
985 } 934 }
935 free(prefix);
986} 936}