Skip to contentSkip to conversation

GitWeb: Adding fork visualization based on objects/info/alternates

PATCH Marius Storm-Olsen 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

In an effort to tidy up the project list, and given that the current fork support in GitWeb doesn't exactly fit my structure (where forks are in subdirs of parent repo, and has to be first level down; alas no seek unlike when not showing forks), I set out to add fork support based on
objects/info/alternates
of each repo. The result can be seen here:
http://chaos.troll.no/~marius/git/forks_collapsed.png
http://chaos.troll.no/~marius/git/forks_expanded.png

I doubt you'd want it in the mainline, as you can't turn the feature off; it's just like another column which you can sort by. If you do not sort by the 'fork' column, the forks will still be colored with the first level color, but not ordered under it's parent repo.

Just wanted to feed back what I did so others can get inspiration, tweak it, and add it to their own gitwebs.

It cleans up the project list real nicely though.

Later!

--
.marius

--------------------------------------------------------------

Quoted 1 line

From a3659e21447181717b8b9edec319fe78f5643bdd Mon Sep 17 00:00:00 2001

From: Marius Storm-Olsen <[email protected]>
Date: Sat, 26 May 2007 18:25:41 +0200
Subject: [PATCH] Adding fork visualization based on objects/info/alternates.
1) All projects which have alternates are colorized
2) When sorting based on forks, the forks are shown in
a tree-like structure, which is collapsed by default.
The user can expand each node to see the fork projects.

---
 gitweb/closed.png        |  Bin 0 -> 496 bytes
 gitweb/gitweb.css        |   23 ++++++++
 gitweb/gitweb.perl       |  137 +++++++++++++++++++++++++++++++++++----------
 gitweb/gitweb_scripts.js |   55 ++++++++++++++++++
 gitweb/open.png          |  Bin 0 -> 497 bytes
 5 files changed, 184 insertions(+), 31 deletions(-)
 create mode 100644 gitweb/closed.png
 create mode 100644 gitweb/gitweb_scripts.js
 create mode 100644 gitweb/open.png
gitweb/closed.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ae630014d068e541f2b4d6b24617a4d6c896bd62
GIT binary patch
gitweb/gitweb.css +23 -0
index 9f0822f..ca9a77a 100644
@@ -214,6 +214,29 @@ th {
 	text-align: left;
 }
 
+.folder {
+	background: url(closed.png) no-repeat;
+	float: left;
+	height: 14px;
+	width: 10px;
+	padding-right: 3px;
+}
+
+tr.fork, /* All forks higher than 10 will use this one */
+tr.fork1 { background-color: #ffffc0; }
+tr.fork2 { background-color: #ffffa0; }
+tr.fork3 { background-color: #ffff80; }
+tr.fork4 { background-color: #ffff60; }
+tr.fork5 { background-color: #ffff40; }
+tr.fork6 { background-color: #ffff20; }
+tr.fork7 { background-color: #ffff00; }
+tr.fork8 { background-color: #ffc000; }
+tr.fork9 { background-color: #ffa000; }
+
+tr.alternates {
+	color: #a0a0a0;
+}
+
 tr.light:hover {
 	background-color: #edece6;
 }
gitweb/gitweb.perl +106 -31

208 lines not on this page · raw message

gitweb/gitweb_scripts.js new file +55 -0

55 lines not on this page · raw message

gitweb/open.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..ea1f3a0d4affc87d570d36a960479efd07105c9c
GIT binary patch

--
1.5.2.58.g98ee

#1 lore raw

Hi,

Quoted 16 lines · Marius Storm-Olsen

In an effort to tidy up the project list, and given that the current fork support in GitWeb doesn't exactly fit my structure (where forks are in subdirs of parent repo, and has to be first level down; alas no seek unlike when not showing forks), I set out to add fork support based on
objects/info/alternates
of each repo. The result can be seen here:
http://chaos.troll.no/~marius/git/forks_collapsed.png
http://chaos.troll.no/~marius/git/forks_expanded.png

I doubt you'd want it in the mainline, as you can't turn the feature off; it's just like another column which you can sort by. If you do not sort by the 'fork' column, the forks will still be colored with the first level color, but not ordered under it's parent repo.

Quoted 4 lines

Just wanted to feed back what I did so others can get inspiration, tweak it, and add it to their own gitwebs.

It cleans up the project list real nicely though.

I think this patch is quite an interesting idea, and I kind of like
the possibility to show forks in the summary project list, if it's optional (I actually don't think if I would enable this say at repo.or.cz - some projects have quite a lot of forks and it would clutter it up a lot e.g. for text-mode browsers that don't grok enough javascript). OTOH, taking fork info from alternates is more controversial; I don't want to force the repo.or.cz forks model on everyone but having $proj in alternates may not mean it is a fork... but if more people think it's a reasonable heuristic, we might optionally support it too.

If you would be willing to split this patch to two and make both
features optional (and sign off the patch), I think at least the forks-in-summary part might be quite a worthy addition.

gitweb/gitweb.perl EOF · line 1927

Quoted 11 lines
gitweb/gitweb.perl +2 -1
@@ -1909,8 +1919,9 @@ EOF
 		print qq(<link rel="shortcut icon" href="$favicon" type="image/png"/>\n);
 	}
 
+	print "<script src=\"gitweb_scripts.js\" type=\"text/javascript\"></script>\n";
 	print "</head>\n" .
-	      "<body>\n";
+	      "<body onload=\"collapseAllRows();\">\n";
 
 	if (-f $site_header) {
 		open (my $fd, $site_header);

Would it be more reasonable to just set the style for these rows by default to display: none?

gitweb/gitweb_scripts.js

Quoted 2 lines
gitweb/gitweb_scripts.js new file +0 -0

We have other patch introducing blame.js, so maybe call this forks.js? Or do we have a strong reason to prefer a single .js file with all the lot?

Signature · 4 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Ever try. Ever fail. No matter. // Try again. Fail again. Fail better.
		-- Samuel Beckett