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

Enrico Zini enrico at costa.debian.org
Mon Oct 31 16:52:48 UTC 2005


Author: enrico
Date: Mon Oct 31 16:52:47 2005
New Revision: 1455

Modified:
   central-database/branches/alioth/webfrontend/Engine.pm
   central-database/branches/alioth/webfrontend/edit.cgi
   central-database/branches/alioth/webfrontend/edittemplate.html
   central-database/branches/alioth/webfrontend/index.cgi
   central-database/branches/alioth/webfrontend/main.css
Log:
Implemented editing

Modified: central-database/branches/alioth/webfrontend/Engine.pm
==============================================================================
--- central-database/branches/alioth/webfrontend/Engine.pm	(original)
+++ central-database/branches/alioth/webfrontend/Engine.pm	Mon Oct 31 16:52:47 2005
@@ -5,6 +5,7 @@
 
 use GDBM_File;
 use Storable;
+use LockFile::Simple;
 use Carp;
 
 ##
@@ -12,6 +13,10 @@
 ##
 
 our $BASEDIR = ".";
+our $PACKAGES =	$BASEDIR.'/packages.gdbm';
+our $FACETS =	$BASEDIR.'/facets.gdbm';
+our $TAGS =		$BASEDIR.'/tags.gdbm';
+our $DEBTAGS =	$BASEDIR.'/debtags.store';
 
 ##
 ## Variables of the singleton module
@@ -223,10 +228,10 @@
 # Open the database in read-only mode
 sub openDB ()
 {
-	tie %packages, 'GDBM_File', $BASEDIR.'/packages.gdbm', &GDBM_READER, 0640;
-	tie %facets, 'GDBM_File', $BASEDIR.'/facets.gdbm', &GDBM_READER, 0640;
-	tie %tags, 'GDBM_File', $BASEDIR.'/tags.gdbm', &GDBM_READER, 0640;
-	$db = retrieve('debtags.store');
+	tie %packages, 'GDBM_File', $PACKAGES, &GDBM_READER, 0664;
+	tie %facets, 'GDBM_File', $FACETS, &GDBM_READER, 0664;
+	tie %tags, 'GDBM_File', $TAGS, &GDBM_READER, 0664;
+	$db = retrieve($DEBTAGS);
 	$tied = 1;
 }
 
@@ -255,10 +260,10 @@
 {
 	# Read everything in RAM
 	my (%p, %f, %t);
-	tie %p, 'GDBM_File', $BASEDIR.'/packages.gdbm', &GDBM_READER, 0640;
-	tie %f, 'GDBM_File', $BASEDIR.'/facets.gdbm', &GDBM_READER, 0640;
-	tie %t, 'GDBM_File', $BASEDIR.'/tags.gdbm', &GDBM_READER, 0640;
-	$db = retrieve('debtags.store') if -r 'debtags.store';
+	tie %p, 'GDBM_File', $PACKAGES, &GDBM_READER, 0664;
+	tie %f, 'GDBM_File', $FACETS, &GDBM_READER, 0664;
+	tie %t, 'GDBM_File', $TAGS, &GDBM_READER, 0664;
+	$db = retrieve($DEBTAGS) if -r $DEBTAGS;
 
 	%packages = %p;
 	%facets = %f;
@@ -269,9 +274,9 @@
 {
 	my (%p, %f, %t);
 	# Write everything back
-	tie %p, 'GDBM_File', $BASEDIR.'/packages.gdbm', &GDBM_NEWDB, 0660;
-	tie %f, 'GDBM_File', $BASEDIR.'/facets.gdbm', &GDBM_NEWDB, 0660;
-	tie %t, 'GDBM_File', $BASEDIR.'/tags.gdbm', &GDBM_NEWDB, 0660;
+	tie %p, 'GDBM_File', $PACKAGES, &GDBM_NEWDB, 0664;
+	tie %f, 'GDBM_File', $FACETS, &GDBM_NEWDB, 0664;
+	tie %t, 'GDBM_File', $TAGS, &GDBM_NEWDB, 0664;
 
 	%p = %packages;
 	%f = %facets;
@@ -286,7 +291,7 @@
 	{
 		$t->{pkgs} = [ sort { $a->{name} cmp $b->{name} } @{$t->{pkgs}} ];
 	}
-	store $db, 'debtags.store';
+	store $db, $DEBTAGS;
 }
 
 ##
@@ -374,6 +379,60 @@
 }
 
 ##
+## Update functions
+##
+
+sub lockdb ()
+{
+	LockFile::Simple::lock($DEBTAGS) or die "Can't lock $DEBTAGS: $!";
+}
+
+sub unlockdb ()
+{
+	LockFile::Simple::unlock($DEBTAGS);
+}
+
+sub addTag ($@)
+{
+	my ($p, @tags) = @_;
+	@tags = grep { ! $p->hasTag($_) } @tags;
+	return if not @tags;
+
+	lockdb();
+	$db = retrieve($DEBTAGS);
+	for my $t (@tags)
+	{
+		$db->{pkgs}{$p->name}{tags} =
+			[ sort { $a->{name} cmp $b->{name} }
+				(@{$db->{pkgs}{$p->name}{tags}}, mkdbtag($t->name)) ];
+		$db->{tags}{$t->name}{pkgs} =
+			[ sort { $a->{name} cmp $b->{name} }
+				(@{$db->{tags}{$t->name}{pkgs}}, mkdbpkg($p->name)) ];
+	}
+	store $db, $DEBTAGS;
+	unlockdb();
+}
+
+sub removeTag ($@)
+{
+	my ($p, @tags) = @_;
+	@tags = grep { $p->hasTag($_) } @tags;
+	return if not @tags;
+
+	lockdb();
+	$db = retrieve($DEBTAGS);
+	for my $t (@tags)
+	{
+		$db->{pkgs}{$p->name}{tags} =
+			[ grep { $_->{name} ne $t->name } @{$db->{pkgs}{$p->name}{tags}} ];
+		$db->{tags}{$t->name}{pkgs} =
+			[ grep { $_->{name} ne $p->name } @{$db->{tags}{$t->name}{pkgs}} ];
+	}
+	store $db, $DEBTAGS;
+	unlockdb();
+}
+
+##
 ## DB maintainance functions
 ##
 
@@ -734,9 +793,9 @@
 	my $reopen = 1 if $tied == 1;
 	closeDB() if $tied == 1;
 
-	tie %packages, 'GDBM_File', $BASEDIR.'/packages.gdbm', &GDBM_WRITER, 0660;
-	tie %facets, 'GDBM_File', $BASEDIR.'/facets.gdbm', &GDBM_WRITER, 0660;
-	tie %tags, 'GDBM_File', $BASEDIR.'/tags.gdbm', &GDBM_WRITER, 0660;
+	tie %packages, 'GDBM_File', $PACKAGES, &GDBM_WRITER, 0664;
+	tie %facets, 'GDBM_File', $FACETS, &GDBM_WRITER, 0664;
+	tie %tags, 'GDBM_File', $TAGS, &GDBM_WRITER, 0664;
 
 	resyncPackages($pkgs);
 	resyncVocabulary($vocab);

Modified: central-database/branches/alioth/webfrontend/edit.cgi
==============================================================================
--- central-database/branches/alioth/webfrontend/edit.cgi	(original)
+++ central-database/branches/alioth/webfrontend/edit.cgi	Mon Oct 31 16:52:47 2005
@@ -12,210 +12,393 @@
 use CGI qw/:standard/;
 use HTML::Template;
 use URI::Escape;
-use DBI;
+use Engine;
 
-#### configuration options
-my $release="unstable";
-my $db_datasource='DBI:mysql:database=debpackages';
-my $db_user="";
-my $db_pass="";
-my $qry_pkg= "SELECT Package, Description, Section, Longdesc FROM packages".
-             " WHERE Package = ?";
-my $qry_deltag="DELETE FROM packagetags WHERE".
-               " Package = ? AND Tag = ?";
-my $qry_addtag="INSERT INTO packagetags (Package,Tag)".
-               " VALUES (?,?)";
-my $qry_tags="SELECT Tag FROM packagetags WHERE Package = ?";
-my $qry_taglist="SELECT Tag, Title, implies FROM tagsdesc ORDER BY Title";
+##
+## Configuration options
+##
+
+#my $release="unstable";
+#my $qry_pkg= "SELECT Package, Description, Section, Longdesc FROM packages".
+#             " WHERE Package = ?";
+#my $qry_deltag="DELETE FROM packagetags WHERE".
+#               " Package = ? AND Tag = ?";
+#my $qry_addtag="INSERT INTO packagetags (Package,Tag)".
+#               " VALUES (?,?)";
+#my $qry_tags="SELECT Tag FROM packagetags WHERE Package = ?";
+#my $qry_taglist="SELECT Tag, Title, implies FROM tagsdesc ORDER BY Title";
+
+##
+## Generic functions
+##
+
+my $log;
+# Log a message
+sub msg ($@)
+{
+	my ($format, @list) = @_;
+	$log .= sprintf($format, @list);
+	printf STDERR $format, @list;
+}
+
+sub format_ldesc ($)
+{
+	my ($desc) = @_;
+	$desc =~ s/\n+\s*\.\s*\n+/\n<\/p>\n<p>\n/mg;
+	return "<p>$desc</p>";
+}
+
+sub sanitize ($)
+{
+	return '' if not defined $_[0];
+	return '' if not $_[0] =~ /([0-9A-Za-z.+:-]+)/;
+	return $1;
+}
+
+sub linkself (@);
 
-# Predefinition
 sub array_index($$);
 
-#### open database connection
-my $dbh = DBI->connect($db_datasource,$db_user,$db_pass);
 
-#### load the template file
+##
+## Startup
+##
+
+# Open database connection
+Engine::openDB();
+
+# Load the template file
 my $template = HTML::Template->new(
 	filename => 'edittemplate.html',
 	die_on_bad_params => 0)
 || die "Could not open template";
 
-# Tags attached to the file
-my @pkg_tags;
-# Tag descriptions and implications
-my %tag_desc;
-my %tag_impl;
-# HTML::Template output structures
-my @ht_tags;
-my @ht_alltags;
-my $ht_message;
-
-my ($package,$description,$section,$longdesc,$packageurl);
-my $param=param("package");
-my $returnlink="index.cgi";
-my $seltags="";
-if (param("tags")) { $seltags = "&tags=".uri_escape(param("tags")); }
-if (param("tags")) { $returnlink .= "?tags=".uri_escape(param("tags")); }
-if ($param && $param =~ m/([a-z0-9\-\.\+]+)/) {
-	$package=$1;
-} else {
-	$ht_message .= "<P class=err>Invalid package name supplied</P>";
-}
-undef $param;
+# Parse input values
 
-# Check if the package is known.
-my $sth_pkg = $dbh->prepare($qry_pkg);
-if ($package) {
-	$sth_pkg->execute($package);
-	if ($sth_pkg->rows > 0) {
-		($package,$description,$section,$longdesc) = $sth_pkg->fetchrow_array;
-		$section =~ s"(non-free|contrib)/""i;
-		$packageurl .= "http://packages.debian.org/$release/".
-			lc($section)."/$package.html";
-		$longdesc =~ s/\n/<br>/g;
-		$longdesc =~ s%<br>\s*\.\s*<br>%</p><p>%sg;
+my $p;
+my %hidden_facets;
+my %has_tag;
+
+#($p) = Engine::package('debtags');
+#my ($t) = Engine::tag('game::toys');
+#die "socce" if not defined $p;
+#die "soccelo" if not defined $t;
+#Engine::addTag($p, $t);
+#Engine::removeTag($p, $t);
+
+($p) = Engine::package(sanitize(param('pkg')));
+
+if (not defined $p)
+{
+	my $parm = sanitize(param('pkg'));
+	if ($parm)
+	{
+		msg "%s does not match a valid package\n";
 	} else {
-		$ht_message .= "<P class=err>Package not found: ".$package."</P>";
-		undef $package;
+		msg "no package name was provided\n";
 	}
-	if ($sth_pkg->err) {
-		$ht_message .= "<P class=err>Package not found: ".$sth_pkg->errstr."</P>";
-		undef $package;
-	}
-	$sth_pkg->finish;
-}
-
-# Build a list of all known tags
-my $sth = $dbh->prepare($qry_taglist);
-$sth->execute();
-while (my $taginfo=$sth->fetchrow_arrayref) {
-	my ($tag,$desc,$implies) = @$taginfo;
-	$tag_desc{$tag} = $desc;
-	$tag_impl{$tag} = $implies;
-}
-$sth->finish;
-
-if ($package) {
-	# process add-tag command
-	my $param=param("add-tag");
-	if ($param && $param =~ m/([a-z0-9\-:\+]+)/i) {
-		add_tag($package,$1,\$ht_message);
-	}
-	undef $param;
-	# process remove-tag command
-	$param=param("remove-tag");
-	if ($param && $param =~ m/([a-z0-9\-:\+]+)/i) {
-		my $tag=$1;
-		if ($tag_desc{$tag}) {
-			my $sth_del = $dbh->prepare($qry_deltag);
-			$sth_del->execute($package,$tag);
-			if ($sth_del->err) {
-				$ht_message .= "<P>Error while deleting tag: ".$sth_del->errstr."</P>";
-			} elsif ($sth_del->rows == 0) {
-				$ht_message .= "<P>Tag was not attached.</p>";
+} else {
+	for my $par (param())
+	{
+#		msg "Testing: %s\n", $par;
+		if ($par eq 'hf') {
+			my $hf = param($par);
+			%hidden_facets =
+				map { $_ => 1 }
+					grep { Engine::hasFacet(sanitize($_)) }
+						split(',', $hf);
+		} elsif ($par eq 'add') {
+			my $tag = sanitize(param($par));
+			my ($t) = Engine::tag($tag);
+			if (not defined $t)
+			{
+				msg "$tag does not match a valid tag\n";
 			} else {
-				$ht_message .= "<P>Successfully removed tag.</p>";
+				Engine::addTag($p, $t);
+				msg "Added tag $tag\n";
+			}
+		} elsif ($par eq 'del') {
+			my $tag = sanitize(param($par));
+			my ($t) = Engine::tag($tag);
+			if (not defined $t)
+			{
+				msg "$tag does not match a valid tag\n";
+			} else {
+				Engine::removeTag($p, $t);
+				msg "Removed tag $tag\n";
+			}
+		} elsif ($par eq 'fhide') {
+			my $fac = sanitize(param($par));
+			my ($f) = Engine::facet($fac);
+			$hidden_facets{$f->name} = 1
+				if defined $f;
+		} elsif ($par eq 'fdel') {
+			my $fac = sanitize(param($par));
+			my ($f) = Engine::facet($fac);
+			if (defined $f)
+			{
+				my @tags = grep { $p->hasTag($_) } $f->tags;
+				Engine::removeTag($p, @tags);
+				for my $t (@tags)
+				{
+					msg "Removed tag %s\n", $t->name;
+				}
+				$hidden_facets{$f->name} = 1
 			}
-			$sth_del->finish;
-		} else {
-			$ht_message .= "<P class=err>Error while deleting tag: unknown tag</P>";
 		}
 	}
 }
 
-# query attached tags
-my $sth_tags = $dbh->prepare($qry_tags);
-$sth_tags->execute($package);
-my $qpkg_tags=$sth_tags->fetchall_arrayref;
-$sth_tags->finish;
-if (@$qpkg_tags) {
-	foreach my $atag (@$qpkg_tags) {
-		my ($tag) = @$atag;
-		push @pkg_tags,$tag;
-	}
+if (not defined $p)
+{
+	msg "I cannot understand what is the package that I should edit.\n";
+} else {
+	# Process commands
+#	my $param=param("add-tag");
+#	if ($param && $param =~ m/([a-z0-9\-:\+]+)/i) {
+#		add_tag($package,$1,\$ht_message);
+#	}
+#	undef $param;
+#	# process remove-tag command
+#	$param=param("remove-tag");
+#	if ($param && $param =~ m/([a-z0-9\-:\+]+)/i) {
+#		my $tag=$1;
+#		if ($tag_desc{$tag}) {
+#			my $sth_del = $dbh->prepare($qry_deltag);
+#			$sth_del->execute($package,$tag);
+#			if ($sth_del->err) {
+#				$ht_message .= "<P>Error while deleting tag: ".$sth_del->errstr."</P>";
+#			} elsif ($sth_del->rows == 0) {
+#				$ht_message .= "<P>Tag was not attached.</p>";
+#			} else {
+#				$ht_message .= "<P>Successfully removed tag.</p>";
+#			}
+#			$sth_del->finish;
+#		} else {
+#			$ht_message .= "<P class=err>Error while deleting tag: unknown tag</P>";
+#		}
+#	}
+	%has_tag = map { $_->{name} => 1 } $p->tags;
 }
 
-# Build HTML::Template data structures
-if (@pkg_tags) {
-	foreach my $tag (@pkg_tags) {
-		push @ht_tags, {
-			TAG => $tag,
-			TAGTITLE => $tag_desc{$tag},
-			URL => "edit.cgi?package=".uri_escape($package)."&remove-tag=".uri_escape($tag).$seltags
-		};
-	}
+sub linkself (@)
+{
+	return 'edit.cgi' if not defined $p;
+	return 'edit.cgi?'.join('&',
+					'pkg='.uri_escape($p->name),
+					'hf='.join(',', map { uri_escape($_) } keys %hidden_facets),
+					@_);
 }
-# Add add links.
-open(TAGLIST,"<taglist.txt");
-my $count=0;
-while(<TAGLIST>) { chomp;
-	next unless (m/((?:[\|\+] )*)\s*(.*)/);
-	my $tag=$2;
-	my $depth=int(length($1)/2);
-	my ($addurl,$remurl);
-	unless (&array_index(\@pkg_tags,$tag) >= 0) {
-		$addurl="edit.cgi?package=".uri_escape($package)."&add-tag=".uri_escape($tag).$seltags;
-	} else {
-		$remurl="edit.cgi?package=".uri_escape($package)."&remove-tag=".uri_escape($tag).$seltags;
+sub linkself_nohf (@)
+{
+	return 'edit.cgi' if not defined $p;
+	return 'edit.cgi?'.join('&',
+					'pkg='.uri_escape($p->name),
+					@_);
+}
+
+
+## Tags attached to the file
+#my @pkg_tags;
+## Tag descriptions and implications
+#my %tag_desc;
+#my %tag_impl;
+## HTML::Template output structures
+#my @ht_tags;
+#my @ht_alltags;
+#my $ht_message;
+#
+#my ($package,$description,$section,$longdesc,$packageurl);
+#my $returnlink="index.cgi";
+#my $seltags="";
+#if (param("tags")) { $seltags = "&tags=".uri_escape(param("tags")); }
+#if (param("tags")) { $returnlink .= "?tags=".uri_escape(param("tags")); }
+#undef $param;
+
+## Check if the package is known.
+#my $sth_pkg = $dbh->prepare($qry_pkg);
+#if ($package) {
+#	$sth_pkg->execute($package);
+#	if ($sth_pkg->rows > 0) {
+#		($package,$description,$section,$longdesc) = $sth_pkg->fetchrow_array;
+#		$section =~ s"(non-free|contrib)/""i;
+#		$packageurl .= "http://packages.debian.org/$release/".
+#			lc($section)."/$package.html";
+#		$longdesc =~ s/\n/<br>/g;
+#		$longdesc =~ s%<br>\s*\.\s*<br>%</p><p>%sg;
+#	} else {
+#		$ht_message .= "<P class=err>Package not found: ".$package."</P>";
+#		undef $package;
+#	}
+#	if ($sth_pkg->err) {
+#		$ht_message .= "<P class=err>Package not found: ".$sth_pkg->errstr."</P>";
+#		undef $package;
+#	}
+#	$sth_pkg->finish;
+#}
+
+## Build a list of all known tags
+#my $sth = $dbh->prepare($qry_taglist);
+#$sth->execute();
+#while (my $taginfo=$sth->fetchrow_arrayref) {
+#	my ($tag,$desc,$implies) = @$taginfo;
+#	$tag_desc{$tag} = $desc;
+#	$tag_impl{$tag} = $implies;
+#}
+#$sth->finish;
+
+# query attached tags
+#my $sth_tags = $dbh->prepare($qry_tags);
+#$sth_tags->execute($package);
+#my $qpkg_tags=$sth_tags->fetchall_arrayref;
+#$sth_tags->finish;
+#if (@$qpkg_tags) {
+#	foreach my $atag (@$qpkg_tags) {
+#		my ($tag) = @$atag;
+#		push @pkg_tags,$tag;
+#	}
+#}
+
+my @facets;
+
+for my $f (Engine::facets())
+{
+	my @hastags;
+	my @tags;
+	for my $t ($f->tags())
+	{
+		if ($has_tag{$t->name})
+		{
+			push @hastags, {
+				NAME => $t->name,
+				SDESC => $t->sdesc,
+				LDESC => format_ldesc($t->ldesc),
+				REMURL => linkself('del='.uri_escape($t->name)),
+			};
+		} else {
+			push @tags, {
+				NAME => $t->name,
+				SDESC => $t->sdesc,
+				LDESC => format_ldesc($t->ldesc),
+				ADDURL => linkself('add='.uri_escape($t->name)),
+			};
+		}
 	}
-	$count++;
-	push @ht_alltags, {
-		TAG => $tag,
-		TAGTITLE => $tag_desc{$tag},
-		ODDROW => ($count % 2),
-		DEPTH => "&nbsp; "x$depth,
-		ADDURL => $addurl,
-		REMURL => $remurl
+	#msg "%s %s\n", $f->name, $hidden_facets{$f->name} ? "hidden" : "not hidden";
+	push @facets, {
+		NAME => $f->name,
+		SDESC => $f->sdesc,
+		LDESC => format_ldesc($f->ldesc),
+		HASTAGS => \@hastags,
+		TAGS => \@tags,
+		HIDEURL => linkself('fhide='.uri_escape($f->name)),
+		DELURL => linkself('fdel='.uri_escape($f->name)),
+		HIDDEN => $hidden_facets{$f->name},
 	};
 }
-close(TAGLIST);
 
-sub tagsorter {
-	return ($tag_desc{$a} cmp $tag_desc{$b});
-}
+# Build HTML::Template data structures
+#if (@pkg_tags) {
+#	foreach my $tag (@pkg_tags) {
+#		push @ht_tags, {
+#			TAG => $tag,
+#			TAGTITLE => $tag_desc{$tag},
+#			URL => "edit.cgi?package=".uri_escape($package)."&remove-tag=".uri_escape($tag).$seltags
+#		};
+#	}
+#}
+
+## Add add links.
+#open(TAGLIST,"<taglist.txt");
+#my $count=0;
+#while(<TAGLIST>) { chomp;
+#	next unless (m/((?:[\|\+] )*)\s*(.*)/);
+#	my $tag=$2;
+#	my $depth=int(length($1)/2);
+#	my ($addurl,$remurl);
+#	unless (&array_index(\@pkg_tags,$tag) >= 0) {
+#		$addurl="edit.cgi?package=".uri_escape($package)."&add-tag=".uri_escape($tag).$seltags;
+#	} else {
+#		$remurl="edit.cgi?package=".uri_escape($package)."&remove-tag=".uri_escape($tag).$seltags;
+#	}
+#	$count++;
+#	push @ht_alltags, {
+#		TAG => $tag,
+#		TAGTITLE => $tag_desc{$tag},
+#		ODDROW => ($count % 2),
+#		DEPTH => "&nbsp; "x$depth,
+#		ADDURL => $addurl,
+#		REMURL => $remurl
+#	};
+#}
+#close(TAGLIST);
+
+#sub tagsorter {
+#	return ($tag_desc{$a} cmp $tag_desc{$b});
+#}
 
 # fill out the template
-$template->param(RETURNLINK => $returnlink);
-$template->param(PACKAGE => $package);
-$template->param(PACKAGETITLE => $description);
-$template->param(PACKAGEDESC => $longdesc);
-$template->param(PACKAGEURL => $packageurl);
-$template->param(MESSAGE => $ht_message);
-$template->param(TAGS => \@ht_tags);
-$template->param(ADDTAGS => \@ht_alltags);
+#$template->param(RETURNLINK => $returnlink);
+#$template->param(PACKAGE => $package);
+#$template->param(PACKAGETITLE => $description);
+#$template->param(PACKAGEDESC => $longdesc);
+#$template->param(PACKAGEURL => $packageurl);
+#$template->param(MESSAGE => $ht_message);
+#$template->param(TAGS => \@ht_tags);
+#$template->param(ADDTAGS => \@ht_alltags);
+
+$template->param(FACETS => \@facets);
+$template->param(UNHIDE => linkself_nohf());
+$template->param(COUNT_HIDDEN => scalar keys %hidden_facets);
+if (defined $p)
+{
+	$template->param(PKG_NAME => $p->name);
+	$template->param(PKG_SDESC => $p->sdesc);
+	$template->param(PKG_LDESC => format_ldesc($p->ldesc));
+	$template->param(COUNT_TAGS => scalar($p->tags));
+}
+
+if ($log)
+{
+	$log =~ s/\n/<br>/g;
+	$template->param(LOG => $log);
+}
+
 
 print "Content-Type: text/html\n\n";
 print $template->output();
 
-sub array_index($$) { my($haystack,$needle) = @_;
-	for my $i (0..$#$haystack) {
-		return $i if ($$haystack[$i] eq $needle);
-	}
-	return -1;
-}
+#sub array_index($$) { my($haystack,$needle) = @_;
+#	for my $i (0..$#$haystack) {
+#		return $i if ($$haystack[$i] eq $needle);
+#	}
+#	return -1;
+#}
+
+#sub add_tag { my ($package,$tag,$result) = @_;
+#	if ($tag_desc{$tag}) {
+#		my $sth_add = $dbh->prepare($qry_addtag);
+#		$sth_add->execute($package,$tag);
+#		if ($sth_add->err) {
+#			if ($sth_add->errstr =~ m/Duplicate/) {
+#				$$result .= "<div>Already has tag $tag.\n</div>";
+#			} else {
+#				$$result .= "<div class=err>Error while adding tag $tag:<br>";
+#				$$result .= "<tt>".$sth_add->errstr."</tt></div>";
+#			}
+#		} else {
+#			$$result .= "<div>Successfully added tag $tag.</div>";
+#			if ($tag_impl{$tag}) {
+#				my @impl = split(/,\s*/,$tag_impl{$tag});
+#				foreach my $impl (@impl) {
+#					add_tag($package,$impl,$result);
+#				}
+#			}
+#		}
+#		$sth_add->finish;
+#	} else {
+#		$$result .= "<div class=err>Error while adding tag: unknown tag</div>";
+#	}
+#}
 
-sub add_tag { my ($package,$tag,$result) = @_;
-	if ($tag_desc{$tag}) {
-		my $sth_add = $dbh->prepare($qry_addtag);
-		$sth_add->execute($package,$tag);
-		if ($sth_add->err) {
-			if ($sth_add->errstr =~ m/Duplicate/) {
-				$$result .= "<div>Already has tag $tag.\n</div>";
-			} else {
-				$$result .= "<div class=err>Error while adding tag $tag:<br>";
-				$$result .= "<tt>".$sth_add->errstr."</tt></div>";
-			}
-		} else {
-			$$result .= "<div>Successfully added tag $tag.</div>";
-			if ($tag_impl{$tag}) {
-				my @impl = split(/,\s*/,$tag_impl{$tag});
-				foreach my $impl (@impl) {
-					add_tag($package,$impl,$result);
-				}
-			}
-		}
-		$sth_add->finish;
-	} else {
-		$$result .= "<div class=err>Error while adding tag: unknown tag</div>";
-	}
-}
+# vim:set ts=4 sw=4:

Modified: central-database/branches/alioth/webfrontend/edittemplate.html
==============================================================================
--- central-database/branches/alioth/webfrontend/edittemplate.html	(original)
+++ central-database/branches/alioth/webfrontend/edittemplate.html	Mon Oct 31 16:52:47 2005
@@ -1,66 +1,125 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html lang="en">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>Debian Tag Browser</title>
-<meta name="Description" content="">
-<meta name="Language" content="English">
-<meta name="Author"    content="Erich Schubert, erich at debian.org">
-<meta name="Generator" content="packagebrowser">
-<link rev="made" href="mailto:erich at debian.org">
-<link href="main.css" rel="stylesheet" type="text/css">
+  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+  <title>Debian Tag Browser</title>
+  <meta name="Description" content="">
+  <meta name="Language" content="English">
+  <meta name="Author"    content="Erich Schubert, erich at debian.org">
+  <meta name="Generator" content="packagebrowser">
+  <link rev="made" href="mailto:erich at debian.org">
+  <link href="main.css" rel="stylesheet" type="text/css">
 </head>
-<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#800080" alink="#FF0000">
-<h1>Debian Package Browser - <em>Editor</em></h1>
-<TMPL_IF NAME="RETURNLINK">
-<p><a href="<TMPL_VAR NAME="RETURNLINK">">Return</a> to the package browser</p>
-</TMPL_IF>
-<p>Please <em>help</em> sorting the
-<a href="index.cgi?tags=special::not-yet-tagged">not yet tagged</a> packages.
-For more information (creating new tags etc.) visit the
-<a href="http://debtags.alioth.debian.org/">Debian Usability Project Homepage</a> at <a href="http://alioth.debian.org/">Alioth</a>.</p>
-<hr class="close">
-<p>Please don't forget to remove the "not-yet-tagged" Tags!</p>
-<h2>Edit Debian Package: <TMPL_VAR NAME="PACKAGE"></h2>
-<P><TMPL_VAR NAME="PACKAGETITLE"></P>
-<P><TMPL_VAR NAME="PACKAGEDESC"></P>
-<P><a href="<TMPL_VAR NAME=PACKAGEURL>">Go to the package info page at packages.debian.org</a></P>
-<TMPL_IF NAME="MESSAGE">
-  <TMPL_VAR NAME="MESSAGE">
-  <hr noshade width="100%" size=1>
-</TMPL_IF>
-<TMPL_IF NAME="TAGS">
-  <h2>Currently attached tags:</h2>
-  <table border=0>
-  <TMPL_LOOP NAME="TAGS">
-    <tr><td><TMPL_VAR NAME="TAGTITLE"></td>
-    <td><TMPL_IF URL><a href="<TMPL_VAR NAME="URL">" class="removelink">(remove)</a></td></TMPL_IF></tr>
-  </TMPL_LOOP>
-  </table>
-<TMPL_ELSE>
-  <h2>This package currently has no tags attached</h2>
-</TMPL_IF>
-<hr noshade width="100%" size="1">
-<TMPL_IF NAME="ADDTAGS">
-  <h2>Tags that can be attached to this package:</h2>
-  <table border=0>
-  <TMPL_LOOP NAME="ADDTAGS">
-    <TMPL_IF ODDROW><tr class="oddrow"><TMPL_ELSE><tr class="evenrow"></TMPL_IF>
-    <td><TMPL_VAR NAME="DEPTH"><TMPL_VAR NAME="TAGTITLE"></td>
-    <td><TMPL_IF NAME="ADDURL"><a href="<TMPL_VAR NAME="ADDURL">" class="addlink">(attach)</a></TMPL_IF><TMPL_IF NAME="REMURL"><a href="<TMPL_VAR NAME="REMURL">" class="removelink">(remove)</a></TMPL_IF></td></tr>
-  </TMPL_LOOP>
-  </table>
-</TMPL_IF>
-<table border="0" width="100%" class="close">
-<tr>
-  <td align="left" class="close">
-	[<a class="close" href="http://lists.alioth.debian.org/mailman/listinfo/debtags-devel">debtags-devel list</a>]
-	 - 
-	[<a class="close" href="http://alioth.debian.org/projects/debtags">Alioth project page</a>]
-  </td>
-  <td align="right" class="close">
-  	<a class="sign" href="mailto:erich at debian.org">Erich Schubert</a>
-  </td>
-</tr>
-</table>
+<body>
+  <h1><a href='<TMPL_VAR NAME="RETURNLINK">'>Debian Package Browser</a> - <em>Editor</em></h1>
+
+  <TMPL_IF NAME="RETURNLINK">
+    <p><a href="">Return</a> to the package browser</p>
+  </TMPL_IF>
+
+  <div id="log">
+    <TMPL_VAR NAME="LOG">
+  </div>
+
+  <div id="intro">
+    <p>Please <em>help</em> sorting the
+    <a href="index.cgi?tags=special::not-yet-tagged">not yet tagged</a> packages.
+    For more information (creating new tags etc.) visit the
+    <a href="http://debtags.alioth.debian.org/">Debtags Homepage</a> at <a href="http://alioth.debian.org/">Alioth</a>.</p>
+    <p>Please don't forget to remove the "not-yet-tagged" Tags!</p>
+  </div>
+
+  <TMPL_IF NAME="MESSAGE">
+    <TMPL_VAR NAME="MESSAGE">
+    <hr noshade width="100%" size=1>
+  </TMPL_IF>
+
+  <div id="curpackage">
+    <p><b><tmpl_var name="PKG_NAME"></b> - <b><tmpl_var name="PKG_SDESC"></b></p>
+    <div class="ldesc">
+      <tmpl_var name="PKG_LDESC">
+    </div>
+    <P><a href="<TMPL_VAR NAME=PACKAGEURL>">Go to the package info page at packages.debian.org</a></P>
+    <tmpl_if name="COUNT_HIDDEN">
+      <a href="<tmpl_var name='UNHIDE'>">[unhide <tmpl_var name="COUNT_HIDDEN"> facets]</a>
+    </tmpl_if>
+  </div>
+
+  <div id="curtags">
+  <tmpl_if name="COUNT_TAGS">
+    <p><b>Currently attached tags:</b>
+    <ul>
+      <tmpl_loop name="FACETS">
+        <tmpl_loop name="HASTAGS">
+          <li><tmpl_var name="SDESC"> <a href='<tmpl_var name="REMURL">'>[remove]</a></li>
+        </tmpl_loop>
+      </tmpl_loop>
+    </ul>
+    </p>
+  <tmpl_else>
+    <h2>This package currently has no tags attached</h2>
+  </tmpl_if>
+  </div>
+
+  <div style="clear: both"></div>
+
+  <tmpl_loop name="FACETS">
+  <tmpl_unless name="HIDDEN">
+  <div class="editfacet">
+    <div class="facetbuttons">
+      <a href='<tmpl_var name="HIDEURL">'>[done with this]</a>
+      <br>
+      <a href='<tmpl_var name="DELURL">'>[does not apply]</a>
+    </div>
+    <div class="intro">
+      <p><b><tmpl_var name="SDESC"></b></p>
+      <p><tmpl_var name="LDESC"></p>
+    </div>
+    <ul>
+      <tmpl_loop name="HASTAGS">
+        <li><b><tmpl_var name="SDESC"></b> <a href='<tmpl_var name="REMURL">'>[remove]</a></li>
+      </tmpl_loop>
+      <tmpl_loop name="TAGS">
+        <li><tmpl_var name="SDESC"> <a href='<tmpl_var name="ADDURL">'>[add]</a></li>
+      </tmpl_loop>
+    </ul>
+  </div>
+  </tmpl_unless>
+  </tmpl_loop>
+
+  
+
+  <TMPL_IF NAME="ADDTAGS">
+    <h2>Tags that can be attached to this package:</h2>
+    <table border=0>
+    <TMPL_LOOP NAME="ADDTAGS">
+      <TMPL_IF ODDROW>
+        <tr class="oddrow">
+      <TMPL_ELSE>
+        <tr class="evenrow">
+      </TMPL_IF>
+      <td><TMPL_VAR NAME="DEPTH"><TMPL_VAR NAME="TAGTITLE"></td>
+      <td>
+        <TMPL_IF NAME="ADDURL"><a href="<TMPL_VAR NAME="ADDURL">" class="addlink">(attach)</a></TMPL_IF>
+        <TMPL_IF NAME="REMURL"><a href="<TMPL_VAR NAME="REMURL">" class="removelink">(remove)</a></TMPL_IF>
+      </td>
+    </tr>
+    </TMPL_LOOP>
+    </table>
+  </TMPL_IF>
+
+  <div style="clear: both"></div>
+  <div id="close">
+    <div class="links">
+      [<a href="http://debtags.alioth.debian.org">Debtags</a>]
+      -
+      [<a href="http://lists.alioth.debian.org/mailman/listinfo/debtags-devel">debtags-devel list</a>]
+      - 
+      [<a href="http://alioth.debian.org/projects/debtags">Alioth project page</a>]
+    </div>
+    <div class="signature">
+      <a href="mailto:erich at debian.org">Erich Schubert</a>,
+      <a href="mailto:enrico at debian.org">Enrico Zini</a>,
+    </div>
+  </div>
 </body></html>

Modified: central-database/branches/alioth/webfrontend/index.cgi
==============================================================================
--- central-database/branches/alioth/webfrontend/index.cgi	(original)
+++ central-database/branches/alioth/webfrontend/index.cgi	Mon Oct 31 16:52:47 2005
@@ -276,7 +276,10 @@
 
 #msg "%d facets, %d pkgs, %d curpkgs, %d subpkgs\n", scalar(@ht_facets), scalar(@Navigation::pkgs), scalar(@ht_curpkgs), scalar @ht_subpkgs;
 
-# Fill in the template
+
+##
+## Compile template structures
+##
 
 $template->param(CURTAGS => join(',', map{$_->name} @sel_tags));
 $template->param(CURWORDS => join(' ', at sel_words));
@@ -355,14 +358,6 @@
 }
 $template->param(PKGS_INTRO => $curpkgs_intro);
 
-#$template->param(COUNT_SUBGROUPS => $subgroup_count);
-#$template->param(NUMGROUPS => $groups);
-#$template->param(NUMPACKAGES => scalar(@pkgs));
-#$template->param(CURPACKAGES => scalar(@ht_pkgs));
-#$template->param(SUBPACKAGES => scalar(@ht_subpkgs));
-#$template->param(TOTPACKAGES => scalar(@pkgs) + scalar(@subpkgs));
-#$template->param(PACKAGES => \@ht_pkgs);
-#$template->param(SPACKAGES => \@ht_subpkgs);
 if ($log)
 {
 	$log =~ s/\n/<br>/g;

Modified: central-database/branches/alioth/webfrontend/main.css
==============================================================================
--- central-database/branches/alioth/webfrontend/main.css	(original)
+++ central-database/branches/alioth/webfrontend/main.css	Mon Oct 31 16:52:47 2005
@@ -168,6 +168,37 @@
 text-decoration: none;
 }
 
+#curpackage {
+width: 58%;
+float: left;
+padding: 0.5em;
+}
+
+#curtags {
+width: 38%;
+float: left;
+padding: 0.5em;
+}
+
+.editfacet {
+width: 30%;
+float: left;
+border: 1pt solid black;
+margin: 0.5em;
+padding: 3pt;
+}
+
+.facetbuttons {
+float: right;
+margin-left: 1em;
+font-size: x-small;
+}
+
+.ldesc {
+font-size: small;
+}
+
+
 #close {
 padding-top: 2px;
 border-top: 1px brown solid;



More information about the Debtags-commits mailing list