parent
6856761423
commit
63f5bd25c1
@ -0,0 +1,131 @@ |
|||||||
|
/* ui-tag.c: display a tag
|
||||||
|
* |
||||||
|
* Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com> |
||||||
|
* |
||||||
|
* Licensed under GNU General Public License v2 |
||||||
|
* (see COPYING for full license text) |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "cgit.h" |
||||||
|
#include "ui-tag.h" |
||||||
|
#include "html.h" |
||||||
|
#include "ui_70-shared.h" |
||||||
|
|
||||||
|
static void print_tag_content(char *buf) |
||||||
|
{ |
||||||
|
char *p; |
||||||
|
|
||||||
|
if (!buf) |
||||||
|
return; |
||||||
|
|
||||||
|
p = strchr(buf, '\n'); |
||||||
|
if (p) |
||||||
|
*p = '\0'; |
||||||
|
cgit_gopher_start_selector(GOPHER_INFO); |
||||||
|
cgit_gopher_text(buf); |
||||||
|
cgit_gopher_tab(); |
||||||
|
cgit_gopher_selector_link("Err"); |
||||||
|
cgit_gopher_end_selector(); |
||||||
|
if (p) { |
||||||
|
cgit_gopher_start_selector(GOPHER_INFO); |
||||||
|
cgit_gopher_text(++p); |
||||||
|
cgit_gopher_tab(); |
||||||
|
cgit_gopher_selector_link("Err"); |
||||||
|
cgit_gopher_end_selector(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static void print_download_links(char *revname) |
||||||
|
{ |
||||||
|
html("<tr><th>download</th><td class='sha1'>"); |
||||||
|
cgit_print_snapshot_links(ctx.repo, revname, "<br/>"); |
||||||
|
html("</td></tr>"); |
||||||
|
} |
||||||
|
|
||||||
|
void cgit_print_tag(char *revname) |
||||||
|
{ |
||||||
|
struct strbuf fullref = STRBUF_INIT; |
||||||
|
struct object_id oid; |
||||||
|
struct object *obj; |
||||||
|
|
||||||
|
if (!revname) |
||||||
|
revname = ctx.qry.head; |
||||||
|
|
||||||
|
strbuf_addf(&fullref, "refs/tags/%s", revname); |
||||||
|
if (get_oid(fullref.buf, &oid)) { |
||||||
|
cgit_gopher_error("Bad tag reference"); |
||||||
|
goto cleanup; |
||||||
|
} |
||||||
|
obj = parse_object(&oid); |
||||||
|
if (!obj) { |
||||||
|
cgit_gopher_error("Bad object id"); |
||||||
|
goto cleanup; |
||||||
|
} |
||||||
|
if (obj->type == OBJ_TAG) { |
||||||
|
struct tag *tag; |
||||||
|
struct taginfo *info; |
||||||
|
|
||||||
|
tag = lookup_tag(&oid); |
||||||
|
if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { |
||||||
|
cgit_gopher_error("Bad tag object"); |
||||||
|
goto cleanup; |
||||||
|
} |
||||||
|
cgit_print_layout_start(); |
||||||
|
cgit_gopher_start_selector(GOPHER_INFO); |
||||||
|
cgit_gopher_text_pad("tag name", GOPHER_SUMMARY_NAME_LEN); |
||||||
|
cgit_gopher_text(revname); |
||||||
|
gopherf(" (%s)", oid_to_hex(&oid)); |
||||||
|
cgit_gopher_tab(); |
||||||
|
cgit_gopher_selector_link("Err"); |
||||||
|
cgit_gopher_end_selector(); |
||||||
|
if (info->tagger_date > 0) { |
||||||
|
cgit_gopher_start_selector(GOPHER_INFO); |
||||||
|
cgit_gopher_text_pad("tag date", GOPHER_SUMMARY_NAME_LEN); |
||||||
|
cgit_gopher_text(show_date(info->tagger_date, info->tagger_tz, |
||||||
|
cgit_date_mode(DATE_ISO8601))); |
||||||
|
cgit_gopher_tab(); |
||||||
|
cgit_gopher_selector_link("Err"); |
||||||
|
cgit_gopher_end_selector(); |
||||||
|
} |
||||||
|
if (info->tagger) { |
||||||
|
cgit_gopher_start_selector(GOPHER_INFO); |
||||||
|
cgit_gopher_text_pad("tagged by", GOPHER_SUMMARY_NAME_LEN); |
||||||
|
cgit_gopher_text(info->tagger); |
||||||
|
if (info->tagger_email && !ctx.cfg.noplainemail) { |
||||||
|
cgit_gopher_text(" "); |
||||||
|
cgit_gopher_text(info->tagger_email); |
||||||
|
} |
||||||
|
cgit_gopher_tab(); |
||||||
|
cgit_gopher_selector_link("Err"); |
||||||
|
cgit_gopher_end_selector(); |
||||||
|
} |
||||||
|
cgit_gopher_start_selector(GOPHER_MENU); |
||||||
|
cgit_gopher_text_pad("tagged object", GOPHER_SUMMARY_NAME_LEN); |
||||||
|
cgit_gopher_text(oid_to_hex(&tag->tagged->oid)); |
||||||
|
cgit_gopher_tab(); |
||||||
|
cgit_object_link(tag->tagged); |
||||||
|
cgit_gopher_end_selector();
|
||||||
|
print_tag_content(info->msg); |
||||||
|
cgit_print_layout_end(); |
||||||
|
cgit_free_taginfo(info); |
||||||
|
} else { |
||||||
|
cgit_print_layout_start(); |
||||||
|
cgit_gopher_start_selector(GOPHER_INFO); |
||||||
|
cgit_gopher_text_pad("tag name", GOPHER_SUMMARY_NAME_LEN); |
||||||
|
cgit_gopher_text(revname); |
||||||
|
cgit_gopher_tab(); |
||||||
|
cgit_gopher_selector_link("Err"); |
||||||
|
cgit_gopher_end_selector(); |
||||||
|
|
||||||
|
cgit_gopher_start_selector(GOPHER_MENU); |
||||||
|
cgit_gopher_text_pad("tagged object", GOPHER_SUMMARY_NAME_LEN); |
||||||
|
cgit_gopher_text(oid_to_hex(&obj->oid)); |
||||||
|
cgit_gopher_tab(); |
||||||
|
cgit_object_link(obj); |
||||||
|
cgit_gopher_end_selector();
|
||||||
|
cgit_print_layout_end(); |
||||||
|
} |
||||||
|
|
||||||
|
cleanup: |
||||||
|
strbuf_release(&fullref); |
||||||
|
} |
Loading…
Reference in new issue