git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: tree view: eliminate redundant "blob"

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 2, 2006, 11:06 UTC
Message-ID
<200610021306.16037.jnareb@gmail.com>
In-Reply-To
<7vhcynxjbc.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 21 quoted lines
> Junio C Hamano <junkio@cox.net> writes:
> 
>> Jakub Narebski <jnareb@gmail.com> writes:
>>
>>> ... That means that we cannot distinguish really well (at 
>>> least color) between tree and blob entries.
>>
>> Do we even say links are blue and underlined by forcing that in
>> our css?
>>
>> Doesn't leading drwxr-xr-x mean anything?
>>
>> Why is making the distinction important in the first place?
> 
> Anyhow, I was too tired to sleep after an unscheduled day-job on
> Sunday X-<, and whipped this up for fun.
> 
> -- >8 --
> [PATCH] gitweb: remove UNIXy mode bits from tree display
> 
> and replace it with an image icon for cuteness ;-).
[...]
Show 20 quoted lines
> +td.executable {
> +  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANAQMAAABIJXY/AAAABlBMVEX///+UAN7OszyBAAAAAXRSTlMAQObYZgAAACVJREFUCNdjYGBgYGdgMEhgUFBgYGJgcBKAIiAbKAIUB8oyMAAANBcCqbivEbgAAAAASUVORK5CYII=);
> +  background-repeat: no-repeat;
> +}
> +
> +td.folder {
> +  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANAQMAAABIJXY/AAAABlBMVEX///+UAN7OszyBAAAAAXRSTlMAQObYZgAAAB1JREFUCNdjYGBgkGFgUGJgcPzA4CCABdV/ACoBAFTTBQ822ZerAAAAAElFTkSuQmCC);
> +  background-repeat: no-repeat;
> +}
> +
> +td.regular {
> +  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANAQMAAABIJXY/AAAABlBMVEX///+UAN7OszyBAAAAAXRSTlMAQObYZgAAABtJREFUCNdjqD/A4JDA4BDA4FDB4MCBHdX/AACO5wbfUNnbqwAAAABJRU5ErkJggg==);
> +  background-repeat: no-repeat;
> +}
> +
> +td.symlink {
> +  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANAQMAAABIJXY/AAAABlBMVEX///+UAN7OszyBAAAAAXRSTlMAQObYZgAAACVJREFUCNdjYGBg4G9gMEhgUFBgcBAAIQYYYlFg4ElgkG8AKgEARSsDX750+Y0AAAAASUVORK5CYII=);
> +  background-repeat: no-repeat;
> +}
> +

Wouldn't it be better to use out-of-line images? I'm not sure if all browsers support CSS embedded images, and if all browsers can cache such images.

Perhaps we could reuse Apache's MultiView/index.html.var... err, gitweb tries to be web server agnostic...

And what about text browsers? It would be better to use <img> element, with alt attribute set either to old UNIX-y mode bits, and title set to the file type... or perhaps both alt and title attributes set to file type.

Show 18 quoted lines
>  # convert file mode in octal to symbolic file mode string
> +sub kind_class {
> +	my ($type, $mode) = @_;
> +	$mode = oct $mode;
> +	if (S_ISDIR($mode & S_IFMT)) {
> +		return 'folder';
> +	} elsif (S_ISLNK($mode)) {
> +		return 'symlink';
> +	} elsif (S_ISREG($mode)) {
> +		# git cares only about the executable bit
> +		if ($mode & S_IXUSR) {
> +			return 'executable';
> +		} else {
> +			return 'regular';
> +		};
> +	}
> +}
> +

We have file_type subroutine, which does almost the same work. It doesn't mark file as "executable", and it uses "directory" instead of non-standard "folder".

By the way, $type argument (parameter) is not used at all.
Show 11 quoted lines
> @@ -1651,7 +1668,9 @@ sub git_print_tree_entry {
>  	# the mode of the entry, list is the name of the entry, an href,
>  	# and link is the action links of the entry.
>  
> -	print "<td class=\"mode\">" . mode_str($t->{'mode'}) . "</td>\n";
> +	my $kind = kind_class($t->{'type'}, $t->{'mode'});
> +	print "<td class=\"$kind\">&nbsp;</td>\n";
> +
>  	if ($t->{'type'} eq "blob") {
>  		print "<td class=\"list\">" .
>  			$cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
-- 
Jakub Narebski
Poland
Previous: Junio C HamanoNext: Luben Tuikov
Message 23 of 33 in “gitweb: tree view: eliminate redundant "blob"”
  1. gitweb: tree view: eliminate redundant "blob"Luben Tuikov, Sep 26, 2006
  2. Junio C HamanoSep 26, 2006
  3. Luben TuikovSep 26, 2006
  4. Jakub NarebskiSep 26, 2006
  5. Jakub NarebskiSep 26, 2006
  6. Petr BaudisSep 26, 2006
  7. Jakub NarebskiSep 26, 2006
  8. Luben TuikovSep 26, 2006
  9. Junio C HamanoSep 27, 2006
  10. Jakub NarebskiOct 1, 2006
  11. Luben TuikovSep 26, 2006
  12. Jakub NarebskiSep 26, 2006
  13. Luben TuikovSep 26, 2006
  14. Jakub NarebskiSep 26, 2006
  15. Jakub NarebskiSep 26, 2006
  16. Junio C HamanoSep 27, 2006
  17. Jakub NarebskiOct 1, 2006
  18. Junio C HamanoOct 1, 2006
  19. Jakub NarebskiOct 1, 2006
  20. Andreas EricssonOct 2, 2006
  21. Jakub NarebskiOct 2, 2006
  22. Junio C HamanoOct 2, 2006
  23. Jakub NarebskiOct 2, 2006
  24. Luben TuikovOct 2, 2006
  25. Luben TuikovOct 2, 2006
  26. Jakub NarebskiOct 2, 2006
  27. Junio C HamanoOct 3, 2006
  28. Jakub NarebskiOct 3, 2006
  29. Junio C HamanoOct 3, 2006
  30. Jakub NarebskiOct 3, 2006
  31. Luben TuikovOct 5, 2006
  32. Luben TuikovOct 3, 2006
  33. Linus TorvaldsOct 3, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.