Commit c3bcdfd5079e63b840d5dc9ee58515a3144502a5

Tracey Emery 2020-01-29T15:10:47

alternate color of tree lines to prepare for blob/blame conversion

diff --git a/gotweb/files/htdocs/gotweb/gotweb.css b/gotweb/files/htdocs/gotweb/gotweb.css
index 9044940..1464010 100644
--- a/gotweb/files/htdocs/gotweb/gotweb.css
+++ b/gotweb/files/htdocs/gotweb/gotweb.css
@@ -50,6 +50,13 @@ body {
 	color: blue;
 }
 
+.back_white {
+	background-color: #ffffff;
+}
+.back_lightgray {
+	background-color: #d8f3ef;
+}
+
 #dotted_line {
 	clear: left;
 	float: left;
@@ -631,7 +638,8 @@ body {
 }
 #tree_line {
 	clear: left;
-	float:left ;
+	float: left;
+	width: 20em;
 }
 
 /* tag.tmpl */
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 8f338a0..6c89bc7 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -2456,8 +2456,8 @@ gw_get_repo_tree(struct gw_trans *gw_trans)
 	struct buf *diffbuf = NULL;
 	size_t newsize;
 	char *tree_html = NULL, *path = NULL, *in_repo_path = NULL,
-	    *tree_row = NULL, *id_str;
-	int nentries, i;
+	    *tree_row = NULL, *id_str, *class = NULL;
+	int nentries, i, class_flip = 0;
 
 	error = buf_alloc(&diffbuf, 0);
 	if (error)
@@ -2535,6 +2535,14 @@ gw_get_repo_tree(struct gw_trans *gw_trans)
 		else if (mode & S_IXUSR)
 			modestr = "*";
 
+		if (class_flip == 0) {
+			class = strdup("back_lightgray");
+			class_flip = 1;
+		} else {
+			class = strdup("back_white");
+			class_flip = 0;
+		}
+
 		char *build_folder = NULL;
 		if (S_ISDIR(got_tree_entry_get_mode(te))) {
 			if (gw_trans->repo_folder != NULL) {
@@ -2582,7 +2590,7 @@ gw_get_repo_tree(struct gw_trans *gw_trans)
 		if (error)
 			goto done;
 
-		if (asprintf(&tree_row, tree_line, url_html) == -1) {
+		if ((asprintf(&tree_row, tree_line, class, url_html)) == -1) {
 			error = got_error_from_errno("asprintf");
 			goto done;
 		}
diff --git a/gotweb/gotweb_ui.h b/gotweb/gotweb_ui.h
index cd26c41..683c22a 100644
--- a/gotweb/gotweb_ui.h
+++ b/gotweb/gotweb_ui.h
@@ -249,7 +249,7 @@ char *tree_header =
 
 char *tree_line =
 	"<div id='tree_wrapper'>" \
-	"<div id='tree_line'>%s</div>" \
+	"<div id='tree_line' class='%s'>%s</div>" \
 	"</div>";
 
 /* tag.tmpl */