about summary refs log tree commit diff
path: root/ui-refs.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2008-12-01 21:56:07 +0100
committerLars Hjemli <hjemli@gmail.com>2008-12-01 22:01:10 +0100
commit6596268576a4f5fe2f5c8a3238856b0fb205ff76 (patch)
tree9cd8a7b68a6aeea9aa44e7b25dacc8f9cdc918f1 /ui-refs.c
parentui-shared: exploit snapshot dwimmery in cgit_print_snapshot_links (diff)
downloadcgit-pink-6596268576a4f5fe2f5c8a3238856b0fb205ff76.tar.gz
cgit-pink-6596268576a4f5fe2f5c8a3238856b0fb205ff76.zip
ui-refs.c: show download links for all tags referring to commit objects
The snapshot function has only been linked to from the commit page while
users often would want to download a certain release. With this patch,
direct download links will now be printed for each tagged release on the
repo summary page.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-refs.c')
-rw-r--r--ui-refs.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/ui-refs.c b/ui-refs.c
index 32e0429..0805fc8 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -78,12 +78,37 @@ static int print_branch(struct refinfo *ref)
 static void print_tag_header()
 {
 	html("<tr class='nohover'><th class='left'>Tag</th>"
-	     "<th class='left'>Reference</th>"
+	     "<th class='left'>Download</th>"
 	     "<th class='left'>Author</th>"
 	     "<th class='left' colspan='2'>Age</th></tr>\n");
 	header = 1;
 }
 
+static void print_tag_downloads(const struct cgit_repo *repo, const char *ref)
+{
+	const struct cgit_snapshot_format* f;
+    	char *filename;
+	const char *basename;
+
+	if (!ref || strlen(ref) < 2)
+		return;
+
+	basename = cgit_repobasename(repo->url);
+	if (prefixcmp(ref, basename) != 0) {
+		if ((ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]))
+			ref++;
+		if (isdigit(ref[0]))
+			ref = xstrdup(fmt("%s-%s", basename, ref));
+	}
+
+	for (f = cgit_snapshot_formats; f->suffix; f++) {
+		if (!(repo->snapshots & f->bit))
+			continue;
+		filename = fmt("%s%s", ref, f->suffix);
+		cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
+		html("&nbsp;&nbsp;");
+	}
+}
 static int print_tag(struct refinfo *ref)
 {
 	struct tag *tag;
@@ -98,7 +123,10 @@ static int print_tag(struct refinfo *ref)
 		html("<tr><td>");
 		cgit_tag_link(name, NULL, NULL, ctx.qry.head, name);
 		html("</td><td>");
-		cgit_object_link(tag->tagged);
+		if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT))
+			print_tag_downloads(ctx.repo, name);
+		else
+			cgit_object_link(tag->tagged);
 		html("</td><td>");
 		if (info->tagger)
 			html(info->tagger);
@@ -112,7 +140,10 @@ static int print_tag(struct refinfo *ref)
 		html("<tr><td>");
 		html_txt(name);
 		html("</td><td>");
-		cgit_object_link(ref->object);
+		if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT))
+			print_tag_downloads(ctx.repo, name);
+		else
+			cgit_object_link(ref->object);
 		html("</td></tr>\n");
 	}
 	return 0;
w=1'>Rename listen to localJune McEnroe 2019-11-09Remove extended-join and invite-notifyJune McEnroe The remaining caps only generate new commands which can easily be filtered out when sending to clients so will be in the first pass of support. extended-join is probably safe to pass through unaltered, just causing extraneous parameters on JOIN commands, but maybe not. invite-notify reuses the INVITE command where the invited user is not self. 2019-11-09Maintain stateCaps and offer them to clientsJune McEnroe 2019-11-09Parse capabilitiesJune McEnroe The list that I've defined are the ones that I expect to be able to enable probably without any clients breaking... And of course server-time which pounce implements itself. 2019-11-09Avoid the reserved _A names with BIT macroJune McEnroe 2019-11-09Define macro for bit flag enumsJune McEnroe 2019-11-08Check that password is hashedJune McEnroe 2019-11-08Avoid calling getopt_long again after it returns -1June McEnroe On GNU, calling getopt_long again will reset optind back to the first non-option argument, which would cause an infinite loop of reading the same configurtion file forever. 2019-11-08Only change AWAY status for registered clientsJune McEnroe Turns out I did eventually fix this, because I may want to implement "passive clients" for logging or notification stuff, which wouldn't affect AWAY status either. 2019-11-07Just write the example normallyJune McEnroe 2019-11-07Include path in readlinkat errorJune McEnroe 2019-11-07Call clientConsume before clientRecvJune McEnroe This might reduce the frequency of a client getting its own message back because it was behind in the ring when it sent it. 2019-11-06Use -l:filename in Linux.mkJune McEnroe 2019-11-06Fix compat.h for #defined strlcpyJune McEnroe 2019-11-06Allow unsetting LIBRESSL_PREFIXJune McEnroe 2019-11-06Document calico service configurationJune McEnroe 2019-11-06Document SASL EXTERNAL configuration in more detailJune McEnroe 2019-11-06Document pounce service configurationJune McEnroe 2019-11-06Mention Darwin and GNU/Linux in READMEJune McEnroe 2019-11-06Assume LibreSSL from brew on DarwinJune McEnroe 2019-11-06Remove -DNO_EXPLICIT_BZERO from Darwin.mkJune McEnroe 2019-11-06Don't install rc scripts or dirs on LinuxJune McEnroe