From aa31f643447b3533675e6c169784048834ff9088 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Mon, 21 Apr 2008 19:31:08 +0200 Subject: [PATCH] [UBUNTU] Improve handling of maintainer fields, support original-maintainer Handle and display Original-Maintainer field contents. Also treat Uploaders as being related to Original-Maintainer if that exists since AFAICT Ubuntu doesn't use this field. Don't show the email addresses for Original-Maintainer, since they are usually not needed anyway. Add some helpful suggestions below maintainer email addresses to file bugs or questions in launchpad instead. Usually this should give a better response. With thanks to Colin Watson for nagging and suggestions. --- lib/Packages/DoShow.pm | 6 ++++- lib/Packages/Page.pm | 57 ++++++++++++++++++++++++++++------------ lib/Packages/SrcPage.pm | 17 +++--------- templates/html/show.tmpl | 45 ++++++++++++++++++++++++------- 4 files changed, 84 insertions(+), 41 deletions(-) diff --git a/lib/Packages/DoShow.pm b/lib/Packages/DoShow.pm index 13afcbc..00bc8cd 100644 --- a/lib/Packages/DoShow.pm +++ b/lib/Packages/DoShow.pm @@ -386,12 +386,16 @@ sub moreinfo { if ($info{maintainers}) { my $uploaders = $page->get_src( 'uploaders' ); + my $orig_uploaders = $page->get_src( 'orig_uploaders' ); if ($uploaders && @$uploaders) { my @maintainers = map { { name => $_->[0], mail => $_->[1] } } @$uploaders; $contents->{maintainers} = \@maintainers; } + if ($orig_uploaders && @$orig_uploaders) { + my @orig_maintainers = map { { name => $_->[0], mail => $_->[1] } } @$orig_uploaders; + $contents->{original_maintainers} = \@orig_maintainers; + } } - } sub providers { diff --git a/lib/Packages/Page.pm b/lib/Packages/Page.pm index b9c41ee..879e6a6 100644 --- a/lib/Packages/Page.pm +++ b/lib/Packages/Page.pm @@ -10,7 +10,7 @@ use Packages::CGI; use Packages::I18N::Locale; our @ISA = qw( Exporter ); -our @EXPORT_OK = qw( split_name_mail parse_deps ); +our @EXPORT_OK = qw( split_name_mail parse_deps handle_maintainer_fields); our %EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); our $ARCHIVE_DEFAULT = ''; @@ -51,6 +51,40 @@ sub split_name_mail { return ($name, $email); } +sub handle_maintainer_fields { + my ($data) = @_; + my (@uploaders, @orig_uploaders); + + if ($data->{'original-maintainer'}) { + push @orig_uploaders, [ split_name_mail( $data->{'original-maintainer'} ) ]; + + $data->{uploaders} ||= ''; + my @up_tmp = split( /\s*,\s*/, + $data->{uploaders} ); + foreach my $up (@up_tmp) { + push @orig_uploaders, [ split_name_mail( $up ) ]; + } + if ($data->{maintainer} ||= '') { + push @uploaders, [ split_name_mail( $data->{maintainer} ) ]; + } + } else { + if ($data->{maintainer} ||= '') { + push @uploaders, [ split_name_mail( $data->{maintainer} ) ]; + } + if ($data->{uploaders}) { + my @up_tmp = split( /\s*,\s*/, + $data->{uploaders} ); + foreach my $up (@up_tmp) { + if ($up ne $data->{maintainer}) { # weed out duplicates + push @uploaders, [ split_name_mail( $up ) ]; + } + } + } + } + + return (\@uploaders, \@orig_uploaders); +} + sub add_src_data { my ($self, $src, $data) = @_; @@ -63,20 +97,9 @@ sub add_src_data { $self->{src}{files} = \@files; } $self->{src}{directory} = $data{directory}; - my @uploaders; - if ($data{maintainer} ||= '') { - push @uploaders, [ split_name_mail( $data{maintainer} ) ]; - } - if ($data{uploaders}) { - my @up_tmp = split( /\s*,\s*/, - $data{uploaders} ); - foreach my $up (@up_tmp) { - if ($up ne $data{maintainer}) { # weed out duplicates - push @uploaders, [ split_name_mail( $up ) ]; - } - } - } - $self->{src}{uploaders} = \@uploaders; + my ($uploaders, $orig_uploaders) = handle_maintainer_fields(\%data); + $self->{src}{uploaders} = $uploaders; + $self->{src}{orig_uploaders} = $orig_uploaders if @$orig_uploaders; return 1; } @@ -95,7 +118,7 @@ sub is_virtual { } our @TAKE_NEWEST = qw( description description-md5 essential priority section subsection tag - archive source source-version homepage ); + archive source source-version homepage maintainer original-maintainer uploaders); our @STORE_ALL = qw( version source source-version installed-size size filename md5sum sha1 sha256 task origin bugs suite archive section ); @@ -133,7 +156,7 @@ sub merge_package { # packages from the central archive are preferred over all # others with the same version number but from other archives if ($is_newest = ($cmp > 0) - || (!$cmp && ($data->{archive} eq 'us') && ($self->{data}{archive} ne 'us'))) { + || (!$cmp && ($data->{archive} eq 'us') && ($self->{data}{archive} ne 'us'))) { $self->{newest} = $version; foreach my $key (@TAKE_NEWEST) { $self->{data}{$key} = $data->{$key}; diff --git a/lib/Packages/SrcPage.pm b/lib/Packages/SrcPage.pm index 62d96d0..47735cf 100644 --- a/lib/Packages/SrcPage.pm +++ b/lib/Packages/SrcPage.pm @@ -38,20 +38,9 @@ sub merge_package { $self->{data} = $data; - my @uploaders; - if ($data->{maintainer} ||= '') { - push @uploaders, [ split_name_mail( $data->{maintainer} ) ]; - } - if ($data->{uploaders}) { - my @up_tmp = split( /\s*,\s*/, - $data->{uploaders} ); - foreach my $up (@up_tmp) { - if ($up ne $data->{maintainer}) { # weed out duplicates - push @uploaders, [ split_name_mail( $up ) ]; - } - } - } - $self->{uploaders} = \@uploaders; + my ($uploaders, $orig_uploaders) = handle_maintainer_fields($data); + $self->{uploaders} = $uploaders; + $self->{orig_uploaders} = $orig_uploaders if @$orig_uploaders; if ($data->{files}) { my @files = split /\01/so, $data->{files}; diff --git a/templates/html/show.tmpl b/templates/html/show.tmpl index 8f76bb2..19c0f08 100644 --- a/templates/html/show.tmpl +++ b/templates/html/show.tmpl @@ -98,12 +98,7 @@ [% END %] [% END %] -[% IF maintainers.size == 1 -%] -

[% g('Maintainer:') %]

-[%- ELSE -%] -

[% g('Maintainers:') %]

-[%- END %] -[%- FOREACH maintainers; +[%- BLOCK handle_maintainer; mailarchiveurl = ''; IF (matches = mail.match('^(.*)@lists\.debian\.org$')); mailarchiveurl = 'http://lists.debian.org/' _ uri_escape(matches.0) _ '/'; @@ -112,11 +107,43 @@ ELSIF (matches = mail.match('^(.*)@lists\.ubuntu\.com$')); mailarchiveurl = 'http://lists.ubuntu.com/archives/' _ uri_escape(matches.0) _ '/'; END -%] - [%- '' IF loop.last -%] +[% END -%] + +[%- IF maintainers.size -%] +[% IF maintainers.size == 1 -%] +

[% g('Maintainer:') %]

+[%- ELSE -%] +

[% g('Maintainers:') %]

+[%- END %] +[%- FOREACH m IN maintainers; + '' IF loop.last; + END -%] +

[% g('Please consider filing a bug or asking a question via Launchpad before contacting the maintainer directly.', + "https://bugs.launchpad.net/ubuntu/+source/$src.pkg/+filebug", + "https://answers.launchpad.net/ubuntu/+source/$src.pkg/+addquestion") %]

+[%- END -%] + +[%- IF original_maintainers.size -%] +[% IF original_maintainers.size == 1 -%] +

[% g('Original Maintainer (usually from Debian):') %]

+[%- ELSE -%] +

[% g('Original Maintainers (usually from Debian):') %]

+[%- END %] +[%- FOREACH m IN original_maintainers; + '' IF loop.last; + END -%] +

[% g('It should generally not be necessary for users to contact the original maintainer.') %]

[%- END -%] [% url = page.get_newest('url'); -- 2.39.2