Diffstat (limited to 'ui-refs.c')
| -rw-r--r-- | ui-refs.c | 43 |
1 files changed, 33 insertions, 10 deletions
@@ -6,8 +6,6 @@ * (see COPYING for full license text) */ -#define USE_THE_REPOSITORY_VARIABLE - #include "cgit.h" #include "ui-refs.h" #include "html.h" @@ -92,6 +90,34 @@ static void print_tag_header(void) "<th class='left' colspan='2'>Age</th></tr>\n"); } +static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) +{ + const struct cgit_snapshot_format* f; + const char *basename; + struct strbuf filename = STRBUF_INIT; + size_t prefixlen; + + if (!ref || strlen(ref) < 1) + return; + + basename = cgit_repobasename(repo->url); + if (starts_with(ref, basename)) + strbuf_addstr(&filename, ref); + else + cgit_compose_snapshot_prefix(&filename, basename, ref); + prefixlen = filename.len; + for (f = cgit_snapshot_formats; f->suffix; f++) { + if (!(repo->snapshots & f->bit)) + continue; + strbuf_setlen(&filename, prefixlen); + strbuf_addstr(&filename, f->suffix); + cgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL, filename.buf); + html(" "); + } + + strbuf_release(&filename); +} + static int print_tag(struct refinfo *ref) { struct tag *tag = NULL; @@ -111,7 +137,7 @@ static int print_tag(struct refinfo *ref) cgit_tag_link(name, NULL, NULL, name); html("</td><td>"); if (ctx.repo->snapshots && (obj->type == OBJ_COMMIT)) - cgit_print_snapshot_links(ctx.repo, name, " "); + print_tag_downloads(ctx.repo, name); else cgit_object_link(obj); html("</td><td>"); @@ -138,7 +164,7 @@ static int print_tag(struct refinfo *ref) return 0; } -static void print_refs_link(const char *path) +static void print_refs_link(char *path) { html("<tr class='nohover'><td colspan='5'>"); cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); @@ -157,11 +183,9 @@ void cgit_print_branches(int maxcount) list.refs = NULL; list.alloc = list.count = 0; - refs_for_each_branch_ref(get_main_ref_store(the_repository), - cgit_refs_cb, &list); + for_each_branch_ref(cgit_refs_cb, &list); if (ctx.repo->enable_remote_branches) - refs_for_each_remote_ref(get_main_ref_store(the_repository), - cgit_refs_cb, &list); + for_each_remote_ref(cgit_refs_cb, &list); if (maxcount == 0 || maxcount > list.count) maxcount = list.count; @@ -186,8 +210,7 @@ void cgit_print_tags(int maxcount) list.refs = NULL; list.alloc = list.count = 0; - refs_for_each_tag_ref(get_main_ref_store(the_repository), - cgit_refs_cb, &list); + for_each_tag_ref(cgit_refs_cb, &list); if (list.count == 0) return; qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); |