Bug#134606: Patch for devel/people
tags 134606 + patch
thanks
Hi.
I recall that there was a discussion about this, but I can't find it
anymore, it is not recorded in the bug report.
Anyway, I've made a patch for the anchor problem in devel/people
It now generates three anchors: lastname, lastname_firstname, nickname.
Any of these is omitted if the anchor is previously defined.
As anchors must not be nested (per the W3C definition) I've splitted
them: the nickname anchor is an empty one, lastname is around the
lastname, lastname_firstname around the firstname. There is no real
need for this, just playing around :)
Patch attached.
Frank
--
*** Frank Lichtenheld <frank@lichtenheld.de> ***
*** http://www.djpig.de/ ***
see also: - http://www.usta.de/
- http://fachschaft.physik.uni-karlsruhe.de/
Index: people.pl
===================================================================
RCS file: /cvs/webwml/cron/people_scripts/people.pl,v
retrieving revision 1.7
diff -u -r1.7 people.pl
--- people.pl 30 Jan 2003 16:48:36 -0000 1.7
+++ people.pl 20 Apr 2003 20:07:29 -0000
@@ -9,7 +9,7 @@
# the global variables!
my ($firstname, $lastname, $email, $pname);
-my (%People, @nameslist, , $names, $file);
+my (%People, %used_anchors, @nameslist, , $names, $file);
my @special_maintainer = (
"Debian QA Group",
"Debian Install System Team",
@@ -33,9 +33,26 @@
sub print_maintainer {
my ($names) = @_;
- print "<dt><strong><a name=\"$lastname\">$lastname</a>";
+ my @anchors = ( "", "", "" );
+ my @endtags = ( "", "", "" );
+ $anchors[0] = lc $lastname unless exists $used_anchors{lc $lastname};
+ $anchors[1] = lc "$lastname\_$firstname"
+ unless exists $used_anchors{lc "$lastname\_$firstname"};
+ if (defined($People{$names}{nick})) {
+ $anchors[2] = lc "$People{$names}{nick}"
+ unless ( exists $used_anchors{lc $People{$names}{nick}}
+ || ( $anchors[0] eq lc $People{$names}{nick} ));
+ }
+ for (0..2) {
+ if ( $anchors[$_] ) {
+ $used_anchors{$anchors[$_]}++;
+ $anchors[$_] = "<a name=\"$anchors[$_]\">";
+ $endtags[$_] = "</a>";
+ }
+ }
+ print "<dt><strong>$anchors[2]$endtags[2]$anchors[0]$lastname$endtags[0]";
if ($lastname ne "Wookey") {
- if ($firstname) { print ", $firstname"; }
+ if ($firstname) { print ", $anchors[1]$firstname$endtags[1]"; }
}
print "</strong> ";
if ($People{$names}{email} ne "") {
@@ -374,6 +391,33 @@
sub duplicate_check {
}
+sub set_person_value {
+ my ( $ldap_sn, $ldap_cn, $key, $value ) = @_;
+ $has_package = 0;
+ foreach $person (keys %People) {
+ if ($person =~ /(.*):(.*)/) {
+ ($firstname,$lastname) = ($2,$1);
+ # the following looks wierd, but you really do need to check first
+ # names both ways
+ if ($lastname =~ /^$ldap_sn$/i and ($firstname =~ /$ldap_cn/i or $ldap_cn =~ /$firstname/i)) {
+ #warn "$person $ldap_sn $key $value\n";
+ $People{$person}{$key} = $value;
+ $has_package = 1;
+ last;
+ }
+ }
+ }
+ if (!$has_package) {
+ # for some reason, the debbugs user is in the LDAP database, and we don't need it
+ return if ($ldap_cn eq "Debian BTS");
+
+ # they don't seem to have any packages, but add them anyway
+ my $person = "$ldap_sn:$ldap_cn";
+ $People{$person}{email} = "";
+ $People{$person}{$key} = $value;
+ # warn "Adding $person even though they don't have any packages\n";
+ }
+}
sub process_homepages {
my $filename = @_;
@@ -384,16 +428,24 @@
# option -B required on potato, -P 2 -x on woody
foreach (`ldapsearch -P 2 -x -h db.debian.org -b dc=debian,dc=org uid=\* cn mn sn labeledurl`) {
chop; $line = $_;
- if ($line =~ /^(dn: )?uid=(.+),.+$/) { $name = $2; }
+ if ($line =~ /^(dn: )?uid=([^,]+),.+$/) { $name = $2; }
elsif ($line =~ /^cn(=|: )(.+)$/) { $ldap_cn = from_utf8_or_iso88591_to_sgml($2); }
elsif ($line =~ /^mn(=|: )(.+)$/) { next; }
- elsif ($line =~ /^sn(=|: )(.+)$/) { $ldap_sn = from_utf8_or_iso88591_to_sgml($2); }
+ elsif ($line =~ /^sn(=|: )(.+)$/) {
+ $ldap_sn = from_utf8_or_iso88591_to_sgml($2);
+ # this requires that sn: cames always after cn
+ set_person_value( $ldap_sn, $ldap_cn, "nick", $name );
+ }
elsif ($line =~ /^(\w+):: (.+)$/) {
use MIME::Base64;
my $namepart = $1;
my $worddata = from_utf8_or_iso88591_to_sgml(decode_base64($2));
if ($namepart eq "cn") { $ldap_cn = $worddata; }
- elsif ($namepart eq "sn") { $ldap_sn = $worddata; }
+ elsif ($namepart eq "sn") {
+ $ldap_sn = $worddata;
+ # this requires that sn: cames always after cn
+ set_person_value( $ldap_sn, $ldap_cn, "nick", $name );
+ }
elsif ($namepart ne "mn") {
die "something went wrong, a non-name field is BASE64 encoded";
}
@@ -403,30 +455,7 @@
$homepageurl = $2;
$homepageurl =~ s,^www,http://www,;
# warn $ldap_cn." ".$ldap_sn." ".$homepageurl."\n";
- $has_package = 0;
- foreach $person (keys %People) {
- if ($person =~ /(.*):(.*)/) {
- ($firstname,$lastname) = ($2,$1);
- # the following looks wierd, but you really do need to check first
- # names both ways
- if ($lastname =~ /^$ldap_sn$/i and ($firstname =~ /$ldap_cn/i or $ldap_cn =~ /$firstname/i)) {
- # warn $person." ".$ldap_sn." ".$homepageurl."\n";
- $People{$person}{homepage} = $homepageurl;
- $has_package = 1;
- last;
- }
- }
- }
- if (!$has_package) {
- # for some reason, the debbugs user is in the LDAP database, and we don't need it
- next if ($ldap_cn eq "Debian BTS");
-
- # they don't seem to have any packages, but add them anyway
- my $person = "$ldap_sn:$ldap_cn";
- $People{$person}{email} = "";
- $People{$person}{homepage} = $homepageurl;
- # warn "Adding $person even though they don't have any packages\n";
- }
+ set_person_value( $ldap_sn, $ldap_cn, "homepage", $homepageurl );
}
elsif ($line eq "" or $line =~ /^((version|search|result):|#)/) { next; }
else { die "Error: unknown format on line $.:\n$_\n"; }
Reply to: