[Debtags-commits] [svn] r1445 - central-database/branches/alioth/webfrontend

Enrico Zini enrico at costa.debian.org
Sun Oct 30 17:26:13 UTC 2005


Author: enrico
Date: Sun Oct 30 17:26:11 2005
New Revision: 1445

Modified:
   central-database/branches/alioth/webfrontend/browsetemplate.html
   central-database/branches/alioth/webfrontend/index.cgi
Log:
Implemented proper current group / subgroup divisions and trimming


Modified: central-database/branches/alioth/webfrontend/browsetemplate.html
==============================================================================
--- central-database/branches/alioth/webfrontend/browsetemplate.html	(original)
+++ central-database/branches/alioth/webfrontend/browsetemplate.html	Sun Oct 30 17:26:11 2005
@@ -63,7 +63,7 @@
   <TMPL_UNLESS NAME="NUMPACKAGES">
     <p>No Packages shown. All packages can be found in the subcategories.</p>
   <TMPL_ELSE>
-    <p><b><TMPL_VAR NAME="NUMPACKAGES"></b> Packages in this group or in minor subgroups:</p>
+    <p><b><TMPL_VAR NAME="NUMPACKAGES">/<TMPL_VAR NAME="TOTPACKAGES"></b> Packages in this group or in minor subgroups:</p>
     <table border=0>
     <TMPL_LOOP NAME="PACKAGES">
       <TMPL_IF SECTION><tr class="section"><td colspan=2 class="section">

Modified: central-database/branches/alioth/webfrontend/index.cgi
==============================================================================
--- central-database/branches/alioth/webfrontend/index.cgi	(original)
+++ central-database/branches/alioth/webfrontend/index.cgi	Sun Oct 30 17:26:11 2005
@@ -21,10 +21,10 @@
 ## Configuration options
 ##
 
-my $release="unstable";
+#my $release="unstable";
 my $packages_limit = 15; # always show when below this
-my $useless_limit=0.6; # don't put everything into one subgroup.
-my $subgroup_limit=3; # don't make smaller subgroups
+my $subgroup_limit = 3; # don't make smaller subgroups
+#my $useless_limit=0.6; # don't put everything into one subgroup.
 
 ##
 ## Generic functions
@@ -134,74 +134,83 @@
 
 
 ##
-## Package selection
+## Select packages and build navigation
 ##
 
-# Get the list of packages we should display
-# and count the tag cardinalities and the tagset cardinalities
-my (%tag_counts);
+# Packages we should display
+my @pkgs;
 
-# Packages by tagset
-my %ts;
-
-# Current tagset
-my $curts = join(',', sort map{$_->name} @sel_tags);
-
-# Packages that have exactly the current tagset
-my @curpkgs;
-
-# Packages that have more tags than the current tagset
+# Packages displayed in subgroups
 my @subpkgs;
 
-for my $p (Engine::findPackages({tags => \@sel_tags, words => \@sel_words}))
+# Package selection
+if (@sel_tags or @sel_words)
 {
-	next if not $p->tags();
+	# Packages by tagset
+	my %ts;
 
-	# Compute tag statistics
-	foreach my $t ($p->tags())
+	# Current tagset
+	my $curts = join(',', sort map{$_->name} @sel_tags);
+
+	# Packages that have exactly the current tagset
+	my @curpkgs;
+
+	my %sub;
+	for my $p (Engine::findPackages({tags => \@sel_tags, words => \@sel_words}))
 	{
-		$tag_counts{$t->name()} += 1;
-	}
+		next if not $p->tags();
 
-	# Compute tagset statistics
-	my $ts = join(',', sort map{$_->name} $p->tags);
-	# Store packages by tagset
-	push(@{$ts{$ts}}, $p);
-
-	if ($ts eq $curts) {
-		push @curpkgs, $p
-	} else {
-		push @subpkgs, $p;
+		# Compute tagset statistics
+		my $ts = join(',', sort map{$_->name} $p->tags);
+		# Store packages by tagset
+		push(@{$ts{$ts}}, $p);
+
+		if ($ts eq $curts) {
+			push @curpkgs, $p
+		} else {
+			$sub{$p->name} = 1;
+		}
 	}
-}
 
-#msg "Found %d packages: %s\n", scalar(@pkgs), join(', ', map { $_->{name} } @pkgs);
+	# Add more packages if:
+	#  - there are less then $packages_limit packages to display
+	#  - there are subgroups of less than $subgroup_limit
 
-#printf STDERR "Start: %d packages\n", scalar(@pkgs);
+	@pkgs = @curpkgs;
+	for my $pkgs ( sort { scalar(@$a) <=> scalar(@$b) } values %ts )
+	{
+		last if @pkgs > $packages_limit && @$pkgs > $subgroup_limit;
+		for my $p (@$pkgs)
+		{
+			push @pkgs, $p;
+			delete $sub{$p->name};
+		}
+	}
+
+	@subpkgs = Engine::package(keys %sub);
+} else {
+	@subpkgs = grep { $_->tags() } Engine::packages();
+}
 
 ##
-## Building navigation
+## Building statistics for packages in subgroups
 ##
 
-# we now try to build a reasonable set of tags to choose from
-
-my %seen = map { $_->name => 1 } @sel_tags;
-
-# Select the child tags
-my @tag_newtags = Engine::tag(grep { !$seen{$_} } keys %tag_counts);
-
-# If the packages in the current level are just a few, add from the less
-# crowded tagsets
-my @pkgs = @curpkgs;
-if (@pkgs < $packages_limit)
+# Compute tag statistics
+my %tag_counts;
+for my $p (@subpkgs)
 {
-	for my $pkgs ( sort { scalar(@$a) <=> scalar(@$b) } values %ts )
+	foreach my $t ($p->tags())
 	{
-		last if @pkgs > $packages_limit;
-		push @pkgs, @$pkgs;
+		$tag_counts{$t->name()} += 1;
 	}
 }
 
+# Select the child tags
+my %seen = map { $_->name => 1 } @sel_tags;
+my @tag_newtags = Engine::tag(grep { !$seen{$_} } keys %tag_counts);
+
+
 ##
 ## Output results
 ##
@@ -286,6 +295,8 @@
 $template->param(HAVETAGS => \@ht_seltags);
 $template->param(NEWFACETS => \@ht_newfacets);
 $template->param(NUMPACKAGES => scalar(@pkgs));
+$template->param(SUBPACKAGES => scalar(@subpkgs));
+$template->param(TOTPACKAGES => scalar(@pkgs) + scalar(@subpkgs));
 $template->param(PACKAGES => \@ht_pkgs);
 $template->param(CURTAGS => join(',', map{$_->name} @sel_tags));
 $template->param(CURWORDS => join(' ', at sel_words));



More information about the Debtags-commits mailing list