cgit

commit 0274b57d55a12ed38259757dbfae96b79cfa2e0b

Author: Lars Hjemli <hjemli@gmail.com>

ui-log: add support for showing the full commit message

Some users prefer to see the full message, so to make these users happy
the new querystring parameter "showmsg" can be used to print the full
commit message per log entry.

A link is provided in the log heading to make this function accessible,
and all links and forms tries to preserve the users preference.

Note: the new link is not displayed on the summary page since the point
of the summary page is to be a summary, but it is still obeyed if specified
manually.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>

 cgit.c | 2 ++
 cgit.h | 1 +
 ui-log.c | 32 +++++++++++++++++++++++++++-----
 ui-refs.c | 3 ++-
 ui-repolist.c | 2 +-
 ui-shared.c | 12 ++++++++++--
 ui-shared.h | 2 +-
 ui-tree.c | 2 +-


diff --git a/cgit.c b/cgit.c
index c82587b68b8cc5169f4265eaad98fbc938aa0b8e..db5d342ceb196a0ae8f50e1131d1f65f5b41f731 100644
--- a/cgit.c
+++ b/cgit.c
@@ -154,6 +154,8 @@ 	} else if (!strcmp(name, "name")) {
 		ctx.qry.name = xstrdup(value);
 	} else if (!strcmp(name, "mimetype")) {
 		ctx.qry.mimetype = xstrdup(value);
+	} else if (!strcmp(name, "showmsg")) {
+		ctx.qry.showmsg = atoi(value);
 	}
 }
 




diff --git a/cgit.h b/cgit.h
index 91db98aa900061046fa342935f78bd82a89b665b..aab898b03bdbff524059b17b2ebc136243fa605d 100644
--- a/cgit.h
+++ b/cgit.h
@@ -121,6 +121,7 @@ 	char *mimetype;
 	char *url;
 	int   ofs;
 	int nohead;
+	int showmsg;
 };
 
 struct cgit_config {




diff --git a/ui-log.c b/ui-log.c
index 8dd8b898c4deadb9c89dc53f070c2f22e0f56eb0..631e46da94509a833b5305a9c6b14e13744e7b00 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -44,8 +44,12 @@ 	html_link_open(tmp, NULL, NULL);
 	cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
 	html_link_close();
 	html("</td><td>");
+	if (ctx.qry.showmsg)
+		html("<u>");
 	cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
 			 sha1_to_hex(commit->object.sha1));
+	if (ctx.qry.showmsg)
+		html("</u>");
 	html("</td><td>");
 	html_txt(info->author);
 	if (ctx.repo->enable_log_filecount) {
@@ -61,6 +65,17 @@ 			htmlf("-%d/+%d", rem_lines, add_lines);
 		}
 	}
 	html("</td></tr>\n");
+	if (ctx.qry.showmsg) {
+		html("<tr class='nohover'><td></td><td><div class='commit-msg'>");
+		html_txt(info->msg);
+		html("</div><br/></td><td></td>");
+		if (ctx.repo->enable_log_filecount) {
+			html("<td></td>");
+			if (ctx.repo->enable_log_linecount)
+				html("<td></td>");
+		}
+		html("</tr>\n");
+	}
 	cgit_free_commitinfo(info);
 }
 
@@ -100,8 +115,15 @@ 	if (pager)
 		html("<table class='list nowrap'>");
 
 	html("<tr class='nohover'><th class='left'>Age</th>"
-	     "<th class='left'>Commit message</th>"
-	     "<th class='left'>Author</th>");
+	      "<th class='left'>Commit message");
+	if (pager) {
+		html(" (");
+		cgit_log_link("toggle", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
+			      ctx.qry.path, ctx.qry.ofs, ctx.qry.grep,
+			      ctx.qry.search, ctx.qry.showmsg ? 0 : 1);
+		html(")");
+	}
+	html("</th><th class='left'>Author</th>");
 	if (ctx.repo->enable_log_filecount) {
 		html("<th class='left'>Files</th>");
 		columns++;
@@ -136,20 +158,20 @@ 		if (ofs > 0) {
 			cgit_log_link("[prev]", NULL, NULL, ctx.qry.head,
 				      ctx.qry.sha1, ctx.qry.path,
 				      ofs - cnt, ctx.qry.grep,
-				      ctx.qry.search);
+				      ctx.qry.search, ctx.qry.showmsg);
 			html("&nbsp;");
 		}
 		if ((commit = get_revision(&rev)) != NULL) {
 			cgit_log_link("[next]", NULL, NULL, ctx.qry.head,
 				      ctx.qry.sha1, ctx.qry.path,
 				      ofs + cnt, ctx.qry.grep,
-				      ctx.qry.search);
+				      ctx.qry.search, ctx.qry.showmsg);
 		}
 		html("</div>");
 	} else if ((commit = get_revision(&rev)) != NULL) {
 		html("<tr class='nohover'><td colspan='3'>");
 		cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0,
-			      NULL, NULL);
+			      NULL, NULL, ctx.qry.showmsg);
 		html("</td></tr>\n");
 	}
 }




diff --git a/ui-refs.c b/ui-refs.c
index 32e0429242776e7d48e7666a1d585a2dca58685a..7eb16d58c1097f2f2e3c5cfb625d7814caea34cb 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -58,7 +58,8 @@
 	if (!info)
 		return 1;
 	html("<tr><td>");
-	cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL);
+	cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL,
+		      ctx.qry.showmsg);
 	html("</td><td>");
 
 	if (ref->object->type == OBJ_COMMIT) {




diff --git a/ui-repolist.c b/ui-repolist.c
index c23232c36ac1a02194ac8b3c0c833d9e0bc18725..58331404b7e45482fd3162e6c5f624c89b4c7959 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -146,7 +146,7 @@ 		if (ctx.cfg.enable_index_links) {
 			html("<td>");
 			cgit_summary_link("summary", NULL, "button", NULL);
 			cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
-				      0, NULL, NULL);
+				      0, NULL, NULL, ctx.qry.showmsg);
 			cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
 			html("</td>");
 		}




diff --git a/ui-shared.c b/ui-shared.c
index 224e5f3b2f3da88d89a0ea3034b9182cf7775cd7..dc39e64ceea8dd0851b2233d72cbbffb704bd25a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -281,7 +281,8 @@ 	reporevlink("plain", name, title, class, head, rev, path);
 }
 
 void cgit_log_link(char *name, char *title, char *class, char *head,
-		   char *rev, char *path, int ofs, char *grep, char *pattern)
+		   char *rev, char *path, int ofs, char *grep, char *pattern,
+		   int showmsg)
 {
 	char *delim;
 
@@ -305,6 +306,11 @@ 	if (ofs > 0) {
 		html(delim);
 		html("ofs=");
 		htmlf("%d", ofs);
+		delim = "&";
+	}
+	if (showmsg) {
+		html(delim);
+		html("showmsg=1");
 	}
 	html("'>");
 	html_txt(name);
@@ -568,6 +574,8 @@ 	if (ctx.qry.sha1)
 		html_hidden("id", ctx.qry.sha1);
 	if (ctx.qry.sha2)
 		html_hidden("id2", ctx.qry.sha2);
+	if (ctx.qry.showmsg)
+		html_hidden("showmsg", "1");
 
 	if (incl_search) {
 		if (ctx.qry.grep)
@@ -634,7 +642,7 @@ 				  ctx->qry.head);
 		cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
 			       ctx->qry.sha1, NULL);
 		cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
-			      NULL, NULL, 0, NULL, NULL);
+			      NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
 		cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
 			       ctx->qry.sha1, NULL);
 		cgit_commit_link("commit", NULL, hc(cmd, "commit"),




diff --git a/ui-shared.h b/ui-shared.h
index 3c8a6d09ad5db04475235d73cf32518f5a555be0..2ab53ae215b00b749fefcc13d95ca738491ca7ae 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -19,7 +19,7 @@ extern void cgit_plain_link(char *name, char *title, char *class, char *head,
 			    char *rev, char *path);
 extern void cgit_log_link(char *name, char *title, char *class, char *head,
 			  char *rev, char *path, int ofs, char *grep,
-			  char *pattern);
+			  char *pattern, int showmsg);
 extern void cgit_commit_link(char *name, char *title, char *class, char *head,
 			     char *rev);
 extern void cgit_patch_link(char *name, char *title, char *class, char *head,




diff --git a/ui-tree.c b/ui-tree.c
index 79332fc9eb22cc83bf4a098abcaf32102862b4d1..051db7cb28cbf2321ca67582aac866596743a465 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -106,7 +106,7 @@ 	htmlf("%li", size);
 
 	html("<td>");
 	cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev,
-		      fullpath, 0, NULL, NULL);
+		      fullpath, 0, NULL, NULL, ctx.qry.showmsg);
 	html("</td></tr>\n");
 	free(name);
 	return 0;