From 63f5bd25c1b8a011a40d9768793bb6b05e5a1507 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Mon, 30 Jul 2018 08:05:57 +0100 Subject: also tags work --- cgit_70.mk | 3 +- ui_70-tag.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 ui_70-tag.c diff --git a/cgit_70.mk b/cgit_70.mk index 8013f1d..0d05ec3 100644 --- a/cgit_70.mk +++ b/cgit_70.mk @@ -103,7 +103,8 @@ CGIT_OBJ_NAMES += ui-snapshot.o CGIT_OBJ_NAMES += ui-stats.o ##CGIT_OBJ_NAMES += ui-summary.o CGIT_OBJ_NAMES += ui_70-summary.o -CGIT_OBJ_NAMES += ui-tag.o +##CGIT_OBJ_NAMES += ui-tag.o +CGIT_OBJ_NAMES += ui_70-tag.o ##CGIT_OBJ_NAMES += ui-tree.o CGIT_OBJ_NAMES += ui_70-tree.o diff --git a/ui_70-tag.c b/ui_70-tag.c new file mode 100644 index 0000000..0a1b386 --- /dev/null +++ b/ui_70-tag.c @@ -0,0 +1,131 @@ +/* ui-tag.c: display a tag + * + * Copyright (C) 2006-2014 cgit Development Team + * + * 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("download"); + cgit_print_snapshot_links(ctx.repo, revname, "
"); + html(""); +} + +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); +} -- cgit v1.2.3