about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cgit.c2
-rw-r--r--ui-shared.c9
-rw-r--r--ui-tag.c24
3 files changed, 27 insertions, 8 deletions
diff --git a/cgit.c b/cgit.c
index bd37788..a17f40d 100644
--- a/cgit.c
+++ b/cgit.c
@@ -209,6 +209,8 @@ static void querystring_cb(const char *name, const char *value)
 	} else if (!strcmp(name, "p")) {
 		ctx.qry.page = xstrdup(value);
 	} else if (!strcmp(name, "url")) {
+		if (*value == '/')
+			value++;
 		ctx.qry.url = xstrdup(value);
 		cgit_parse_url(value);
 	} else if (!strcmp(name, "qt")) {
diff --git a/ui-shared.c b/ui-shared.c
index 4049a2b..3a9e67b 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -760,13 +760,18 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
 			       const char *hex, int snapshots)
 {
 	const struct cgit_snapshot_format* f;
+	char *prefix;
     	char *filename;
+	unsigned char sha1[20];
 
+	if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
+	    (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))
+		hex++;
+	prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex));
 	for (f = cgit_snapshot_formats; f->suffix; f++) {
 		if (!(snapshots & f->bit))
 			continue;
-		filename = fmt("%s-%s%s", cgit_repobasename(repo), hex,
-			       f->suffix);
+		filename = fmt("%s%s", prefix, f->suffix);
 		cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
 		html("<br/>");
 	}
diff --git a/ui-tag.c b/ui-tag.c
index c2d72af..39e4cb8 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -30,6 +30,14 @@ static void print_tag_content(char *buf)
 	}
 }
 
+void print_download_links(char *revname)
+{
+	html("<tr><th>download</th><td class='sha1'>");
+	cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
+				  revname, ctx.repo->snapshots);
+	html("</td></tr>");
+}
+
 void cgit_print_tag(char *revname)
 {
 	unsigned char sha1[20];
@@ -56,16 +64,16 @@ void cgit_print_tag(char *revname)
 			return;
 		}
 		html("<table class='commit-info'>\n");
-		htmlf("<tr><td>Tag name</td><td>");
+		htmlf("<tr><td>tag name</td><td>");
 		html_txt(revname);
 		htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1));
 		if (info->tagger_date > 0) {
-			html("<tr><td>Tag date</td><td>");
+			html("<tr><td>tag date</td><td>");
 			cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
 			html("</td></tr>\n");
 		}
 		if (info->tagger) {
-			html("<tr><td>Tagged by</td><td>");
+			html("<tr><td>tagged by</td><td>");
 			html_txt(info->tagger);
 			if (info->tagger_email && !ctx.cfg.noplainemail) {
 				html(" ");
@@ -73,19 +81,23 @@ void cgit_print_tag(char *revname)
 			}
 			html("</td></tr>\n");
 		}
-		html("<tr><td>Tagged object</td><td>");
+		html("<tr><td>tagged object</td><td class='sha1'>");
 		cgit_object_link(tag->tagged);
 		html("</td></tr>\n");
+		if (ctx.repo->snapshots)
+			print_download_links(revname);
 		html("</table>\n");
 		print_tag_content(info->msg);
 	} else {
 		html("<table class='commit-info'>\n");
-		htmlf("<tr><td>Tag name</td><td>");
+		htmlf("<tr><td>tag name</td><td>");
 		html_txt(revname);
 		html("</td></tr>\n");
-		html("<tr><td>Tagged object</td><td>");
+		html("<tr><td>Tagged object</td><td class='sha1'>");
 		cgit_object_link(obj);
 		html("</td></tr>\n");
+		if (ctx.repo->snapshots)
+			print_download_links(revname);
 		html("</table>\n");
         }
 	return;