Skip to content

Commit

Permalink
Add user preference "ShortBanners"
Browse files Browse the repository at this point in the history
If this option is set to <K>true</K>, only the first line of each package
banner (including the name, version and description of the package) is
displayed.
  • Loading branch information
zickgraf committed Mar 13, 2023
1 parent 64e6d65 commit 585778a
Showing 1 changed file with 73 additions and 56 deletions.
129 changes: 73 additions & 56 deletions lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,19 @@ InstallGlobalFunction( IsPackageMarkedForLoading, function( name, version )
##
#F DefaultPackageBannerString( <inforec> )
##

DeclareUserPreference( rec(
name:= "ShortBanners",
description:= [
"If this option is set to <K>true</K>, only the first line of each \
package banner (including the name, version and description of the package) \
is displayed."
],
default:= false,
values:= [ true, false ],
multi:= false,
) );

InstallGlobalFunction( DefaultPackageBannerString, function( inforec )
local len, sep, i, str, authors, maintainers, contributors, printPersons;

Expand Down Expand Up @@ -1136,69 +1149,73 @@ InstallGlobalFunction( DefaultPackageBannerString, function( inforec )
fi;
Add( str, '\n' );

# Add info about the authors and/or maintainers
printPersons := function( role, persons )
local fill, person;
fill:= ListWithIdenticalEntries( Length(role), ' ' );
Append( str, role );
for i in [ 1 .. Length( persons ) ] do
person:= persons[i];
Append( str, person.FirstNames );
Append( str, " " );
Append( str, person.LastName );
if IsBound( person.WWWHome ) then
Append( str, Concatenation( " (", person.WWWHome, ")" ) );
elif IsBound( person.Email ) then
Append( str, Concatenation( " (", person.Email, ")" ) );
fi;
if i = Length( persons ) then
Append( str, ".\n" );
elif i = Length( persons )-1 then
if i = 1 then
Append( str, " and\n" );
else
Append( str, ", and\n" );
if not UserPreference( "ShortBanners" ) then
# Add info about the authors and/or maintainers
printPersons := function( role, persons )
local fill, person;
fill:= ListWithIdenticalEntries( Length(role), ' ' );
Append( str, role );
for i in [ 1 .. Length( persons ) ] do
person:= persons[i];
Append( str, person.FirstNames );
Append( str, " " );
Append( str, person.LastName );
if IsBound( person.WWWHome ) then
Append( str, Concatenation( " (", person.WWWHome, ")" ) );
elif IsBound( person.Email ) then
Append( str, Concatenation( " (", person.Email, ")" ) );
fi;
if i = Length( persons ) then
Append( str, ".\n" );
elif i = Length( persons )-1 then
if i = 1 then
Append( str, " and\n" );
else
Append( str, ", and\n" );
fi;
Append( str, fill );
else
Append( str, ",\n" );
Append( str, fill );
fi;
od;
end;
if IsBound( inforec.Persons ) then
authors:= Filtered( inforec.Persons, x -> x.IsAuthor );
if not IsEmpty( authors ) then
printPersons( "by ", authors );
fi;
contributors:= Filtered( inforec.Persons, x -> not x.IsAuthor and not x.IsMaintainer );
if not IsEmpty( contributors ) then
Append( str, "with contributions by:\n");
printPersons( " ", contributors );
fi;
maintainers:= Filtered( inforec.Persons, x -> x.IsMaintainer );
if not IsEmpty( maintainers ) and authors <> maintainers then
Append( str, "maintained by:\n");
printPersons( " ", maintainers );
fi;
Append( str, fill );
else
Append( str, ",\n" );
Append( str, fill );
fi;
od;
end;
if IsBound( inforec.Persons ) then
authors:= Filtered( inforec.Persons, x -> x.IsAuthor );
if not IsEmpty( authors ) then
printPersons( "by ", authors );
fi;
contributors:= Filtered( inforec.Persons, x -> not x.IsAuthor and not x.IsMaintainer );
if not IsEmpty( contributors ) then
Append( str, "with contributions by:\n");
printPersons( " ", contributors );
fi;
maintainers:= Filtered( inforec.Persons, x -> x.IsMaintainer );
if not IsEmpty( maintainers ) and authors <> maintainers then
Append( str, "maintained by:\n");
printPersons( " ", maintainers );
fi;
fi;

# Add info about the home page of the package.
if IsBound( inforec.PackageWWWHome ) then
Append( str, "Homepage: " );
Append( str, inforec.PackageWWWHome );
Append( str, "\n" );
fi;
# Add info about the home page of the package.
if IsBound( inforec.PackageWWWHome ) then
Append( str, "Homepage: " );
Append( str, inforec.PackageWWWHome );
Append( str, "\n" );
fi;

# Add info about the issue tracker of the package.
if IsBound( inforec.IssueTrackerURL ) then
Append( str, "Report issues at " );
Append( str, inforec.IssueTrackerURL );
Append( str, "\n" );
fi;

# Add info about the issue tracker of the package.
if IsBound( inforec.IssueTrackerURL ) then
Append( str, "Report issues at " );
Append( str, inforec.IssueTrackerURL );
Append( str, "\n" );
str := Concatenation(sep, str, sep);
fi;

# temporary hack, in some package names with umlauts are in HTML encoding
str := Concatenation(sep, RecodeForCurrentTerminal(str), sep);
str := RecodeForCurrentTerminal(str);
str:= ReplacedString( str, "&auml;", RecodeForCurrentTerminal("ä") );
str:= ReplacedString( str, "&ouml;", RecodeForCurrentTerminal("ö") );
str:= ReplacedString( str, "&uuml;", RecodeForCurrentTerminal("ü") );
Expand Down

0 comments on commit 585778a

Please sign in to comment.