[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Proposed devel/wnpp patch



Hi.

I've reworked the generation of the devel/wnpp pages. My first intention
was to remove the need to access the bts2ldap gateway for each language.
My version generates one wnpp.data file which is then included by the
individual pages. You can also translate all strings in the page (the
time statements have been non-translatable so far).

I have also splitted the monolithic wnpp.wml which
fixes Bug#242764 ("include language list at bottom of wnpp pages") in
a very simple way.

Attached you find a patch against wnpp.pl and the Makefile, the wnpp.wml
file that now resides in english/templates/debian and the splitted
output files. (not included are the patches from po/)

Comments welcome.

Gruesse,
-- 
Frank Lichtenheld <djpig@debian.org>
www: http://www.djpig.de/
Index: Makefile
===================================================================
RCS file: /cvs/webwml/webwml/english/devel/wnpp/Makefile,v
retrieving revision 1.11
diff -u -r1.11 Makefile
--- Makefile	14 Jun 2003 16:11:06 -0000	1.11
+++ Makefile	15 Jun 2004 20:32:15 -0000
@@ -6,39 +6,20 @@
 CUR_DIR=devel/wnpp
 SUBS=
 
-NOGENERICINSTDEP := true
+NOGENERICDEP = true
 include $(WMLBASE)/Make.lang
 
-ifneq "$(wildcard wnpp.wml)" ""
-WNPP_FILES := being_adopted.$(LANGUAGE).html being_packaged.$(LANGUAGE).html orphaned.$(LANGUAGE).html \
-	prospective.$(LANGUAGE).html requested.$(LANGUAGE).html rfa_bymaint.$(LANGUAGE).html \
-	rfa_bypackage.$(LANGUAGE).html work_needing.$(LANGUAGE).html
-endif
-
-$(HTMLDIR)/%.$(LANGUAGE).html: %.$(LANGUAGE).html
-	@test -d $(HTMLDIR) || mkdir -m g+w -p $(HTMLDIR)
-	@echo copying $*.$(LANGUAGE).html to $(HTMLDIR)
-	-@install -m 664 -p $*.$(LANGUAGE).html $(HTMLDIR)
-ifeq ($(LANGUAGE),en)
-	@echo making a link $(HTMLDIR)/$*.html -\> $*.$(LANGUAGE).html
-	@ln -sf $*.$(LANGUAGE).html $(HTMLDIR)/$*.html
-endif
+DATADIR = $(ENGLISHSRCDIR)/$(CUR_DIR)
 
-# There is no wnpp.XY.html destination. This will be run every time,
-# which is what we want
-wnpp.$(LANGUAGE).html: wnpp.wml
-	wml -q $(WMLPROLOG) wnpp.wml
-ifeq "$(LANGUAGE)" "ja"
-	$(foreach file,$(WNPP_FILES),$(WMLBASE)/convert $(file) $(file).tmp;)
-endif
+%.$(LANGUAGE).html: %.wml $(TEMPLDIR)/template.wml $(TEMPLDIR)/languages.wml \
+  $(WMLBASE)/../.wmlrc $(WMLBASE)/.wmlrc $(DATADIR)/wnpp.data \
+  $(GETTEXTDEP)
+	$(WML) $(<F)
 
-$(HTMLDIR)/wnpp.$(LANGUAGE).html: wnpp.$(LANGUAGE).html
-	@:
-
-install:: $(WNPP_FILES)
-ifneq "$(WNPP_FILES)" ""
-	install -m 664 -p $(WNPP_FILES) $(HTMLDIR)
 ifeq "$(LANGUAGE)" "en"
-	$(foreach file,$(WNPP_FILES),ln -sf $(file) $(HTMLDIR)/$(basename $(basename $(file))).html;)
-endif
+$(DATADIR)/wnpp.data:
+	$(WML) $(DATADIR)/wnpp.pl
 endif
+
+.PHONY: $(DATADIR)/wnpp.data
+.DELETE_ON_ERROR: $(DATADIR)/wnpp.data
Index: wnpp.pl
===================================================================
RCS file: /cvs/webwml/webwml/english/devel/wnpp/wnpp.pl,v
retrieving revision 1.30
diff -u -r1.30 wnpp.pl
--- wnpp.pl	1 Apr 2004 22:02:41 -0000	1.30
+++ wnpp.pl	15 Jun 2004 20:32:15 -0000
@@ -1,4 +1,6 @@
 # originally written by Marcello Magallon
+# for <perl>
+#use wml::std::tags
 
 <perl>
 
@@ -7,14 +9,15 @@
 
 use Net::LDAP;
 use Date::Parse;
+use HTML::Entities;
 
 # this is ok this way.  It says which server to query, on which port and what
 # to fetch from it.  The attribs array could be reduced.
 
-$server = "bugs.debian.org";
-$port = "10101";
-$base   = "dc=current,dc=bugs,dc=debian,dc=org";
-$attrs  = [
+my $server = "bugs.debian.org";
+my $port = "10101";
+my $base   = "dc=current,dc=bugs,dc=debian,dc=org";
+my $attrs  = [
     'debbugsID',
     'debbugsTitle',
     'debbugsSubmitter',
@@ -26,74 +29,66 @@
     'debbugsMergedWith',
 ];
 
-sub htmlsanit {
-    %escape = ('<' => 'lt', '>' => 'gt', '&' => 'amp', '"' => 'quot');
-    my $in = shift;
-    my $out;
-    while ($in =~ m/^(.*?)([<>&"])(.*)$/s) { #"
-        $out .= $1.'&'.$escape{$2}.';';
-        $in=$3;
-    }
-    return $out . $in;
-}
-
 # The maintainers flat database
-$MAINTAINERS = "$(ENGLISHDIR)/devel/wnpp/Maintainers";
+my $maintainers_file = "$(ENGLISHDIR)/devel/wnpp/Maintainers";
 
-open MAINTAINERS or die "Can't find $MAINTAINERS file at $host: $!\n";
+my %maintainer;
+open MAINTAINERS, $maintainers_file or die "Can't find $maintainers_file file at $host: $!\n";
 while (<MAINTAINERS>) {
     if (/^(\S+)\s+(.*)$/) {
-      $pack = $1;
-		$maint = $2;
-		$maint =~ s/</&lt;/;
-		$maint =~ s/>/&gt;/;
-		$maintainer{$pack} = $maint;
+        my $pack = $1;
+        my $maint = $2;
+        $maint =~ s/</&lt;/;
+        $maint =~ s/>/&gt;/;
+        $maintainer{$pack} = $maint;
     }
 }
 close MAINTAINERS;
 
-$ldap = Net::LDAP->new($server, 'port' => $port) or die "Couldn't make connection to ldap server: $@";
+my $ldap = Net::LDAP->new($server, 'port' => $port) or die "Couldn't make connection to ldap server: $@";
 $ldap->bind;
-$mesg = $ldap->search('base' => $base,
+my $mesg = $ldap->search('base' => $base,
                       'filter' => "(debbugsPackage=wnpp)",
                       'attrs' => $attrs) or die;
 
-$curdate = time;
+my $curdate = time;
 
-ALLPKG: foreach $entry ($mesg->entries) {
-    use integer;
-    my $bugid = @{$entry->get('debbugsID')}[0];
-    next if @{$entry->get('debbugsState')}[0] eq 'done';
-    my $subject = @{$entry->get('debbugsTitle')}[0];
-    # If a bug is merged with another, then only consider the youngest
-    # bug and throw the others away.  This will weed out duplicates.
-    my @mergedwith = @{$entry->get('debbugsMergedWith')};
-    foreach my $merged (@mergedwith) {
-        next ALLPKG if int($merged) < int($bugid);
-    }
-    $age{$bugid} = ($curdate - @{$entry->get('debbugsDate')}[0])/86400;    
-    chomp $subject;
-    $subject = htmlsanit($subject);    
-    # Make order out of chaos    
-    if ($subject =~ m/^(?:ITO|RFA):\s*(\S+)(?:\s+-+\s+)?(.*)$/) {
-        $rfa{$bugid} = $1 . ($2?": ":"") . $2;
-	if (defined($maintainer{$1})) {
-	    push @{$rfabymaint{$maintainer{$1}}}, $bugid;
-	} else {
-	    push @{$rfabymaint{"Unknown"}}, $bugid;
-	}
-    } elsif ($subject =~ m/^O:\s*(\S+)(?:\s+-+\s+)?(.*)$/) {
-        $orphaned{$bugid} = $1 . ($2?": ":"") . $2;
-    } elsif ($subject =~ m/^ITA:(?:\s*(?:ITO|RFA|O|W):)?\s*(\S+)(?:\s+-+\s+)?(.*)$/) {
-        $ita{$bugid} = $1 . ($2?": ":"") . $2;
-    } elsif ($subject =~ m/^ITP:(?:\s*RFP:)?\s*(.*)/) {
-        $itp{$bugid} = join(": ", split(/\s+-+\s+/, $1,2));
-    } elsif ($subject =~ m/^RFP:\s*(.*)/) {
-        $rfp{$bugid} = join(": ", split(/\s+-+\s+/, $1,2)); 
-    } else {
-    	print STDERR "What is this ($bugid): $subject\n" if ( $host ne "klecker.debian.org" );
-    }
-}
+my ( %rfa, %orphaned, %rfabymaint, %rfp, %ita, %itp, %age );
+ ALLPKG: foreach my $entry ($mesg->entries) {
+     use integer;
+     my $bugid = @{$entry->get('debbugsID')}[0];
+     next if @{$entry->get('debbugsState')}[0] eq 'done';
+     my $subject = @{$entry->get('debbugsTitle')}[0];
+     # If a bug is merged with another, then only consider the youngest
+     # bug and throw the others away.  This will weed out duplicates.
+     my @mergedwith = ();
+     @mergedwith = @{$entry->get('debbugsMergedWith')} if $entry->get('debbugsMergedWith');
+     foreach my $merged (@mergedwith) {
+         next ALLPKG if int($merged) < int($bugid);
+     }
+     $age{$bugid} = ($curdate - @{$entry->get('debbugsDate')}[0])/86400;    
+     chomp $subject;
+     $subject = encode_entities($subject);    
+     # Make order out of chaos    
+     if ($subject =~ m/^(?:ITO|RFA):\s*(\S+)(?:\s+-+\s+)?(.*)$/) {
+         $rfa{$bugid} = $1 . ($2?": ":"") . $2;
+         if (defined($maintainer{$1})) {
+             push @{$rfabymaint{$maintainer{$1}}}, $bugid;
+         } else {
+             push @{$rfabymaint{"Unknown"}}, $bugid;
+         }
+     } elsif ($subject =~ m/^O:\s*(\S+)(?:\s+-+\s+)?(.*)$/) {
+         $orphaned{$bugid} = $1 . ($2?": ":"") . $2;
+     } elsif ($subject =~ m/^ITA:(?:\s*(?:ITO|RFA|O|W):)?\s*(\S+)(?:\s+-+\s+)?(.*)$/) {
+         $ita{$bugid} = $1 . ($2?": ":"") . $2;
+     } elsif ($subject =~ m/^ITP:(?:\s*RFP:)?\s*(.*)/) {
+         $itp{$bugid} = join(": ", split(/\s+-+\s+/, $1,2));
+     } elsif ($subject =~ m/^RFP:\s*(.*)/) {
+         $rfp{$bugid} = join(": ", split(/\s+-+\s+/, $1,2)); 
+     } else {
+#         print STDERR "What is this ($bugid): $subject\n" if ( $host ne "klecker.debian.org" );
+     }
+ }
 
 $ldap->unbind;
 
@@ -101,67 +96,75 @@
 my (@being_adopted_html, @being_packaged_html, @requested_html);
 
 foreach my $bug (sort { $rfa{$a} cmp $rfa{$b} } keys %rfa) {
-    push @rfa_bypackage_html, "\n<li><a href=\"http://bugs.debian.org/$bug\";>$rfa{$bug}</a>";
+    push @rfa_bypackage_html, "\n<li><btsurl bugnr=\"$bug\">$rfa{$bug}</btsurl>";
     (my $pkg = $rfa{$bug}) =~ s/^(.+):\s+.*$/$1/;
-    push @rfa_bypackage_html, " (<a href=\"http://packages.debian.org/$pkg\";>package info</a>)";
-    push @rfa_bypackage_html, "\n";
+    push @rfa_bypackage_html, " <pdolink \"$pkg\" />";
+    push @rfa_bypackage_html, "</li>\n";
 }
-if ($#rfa_bypackage_html == -1) { @rfa_bypackage_html = ('<li>No requests for adoption') }
+if ($#rfa_bypackage_html == -1) { @rfa_bypackage_html = ('<li><norfa /></li>') }
 
-foreach $maint (sort keys %rfabymaint) {
+foreach my $maint (sort keys %rfabymaint) {
     push @rfa_bymaint_html, "<li>$maint";
     push @rfa_bymaint_html, "<ul>";
     foreach my $bug (sort { $rfa{$a} cmp $rfa{$b} } @{$rfabymaint{$maint}}) {
-        push @rfa_bymaint_html, "<li><a href=\"http://bugs.debian.org/$bug\";>$rfa{$bug}</a>";
+        push @rfa_bymaint_html, "<li><btsurl bugnr=\"$bug\">$rfa{$bug}</btsurl>";
         (my $pkg = $rfa{$bug}) =~ s/^(.+):\s+.*$/$1/;
-        push @rfa_bymaint_html, " (<a href=\"http://packages.debian.org/$pkg\";>package info</a>)";
+        push @rfa_bymaint_html, " <pdolink \"$pkg\" /></li>\n";
     }
     push @rfa_bymaint_html, "</ul>";
-    push @rfa_bymaint_html, "\n";
+    push @rfa_bymaint_html, "</li>\n";
 }
-if ($#rfa_bymaint_html == -1) { @rfa_bymaint_html = ('<li>No requests for adoption') }
+if ($#rfa_bymaint_html == -1) { @rfa_bymaint_html = ('<li><norfa /></li>') }
 
 foreach my $bug (sort { $orphaned{$a} cmp $orphaned{$b} } keys %orphaned) {
-    push @orphaned_html, "<li><a href=\"http://bugs.debian.org/$bug\";>$orphaned{$bug}</a>";
+    push @orphaned_html, "<li><btsurl bugnr=\"$bug\">$orphaned{$bug}</btsurl>";
     (my $pkg = $orphaned{$bug}) =~ s/^(.+):\s+.*$/$1/;
-    push @orphaned_html, " (<a href=\"http://packages.debian.org/$pkg\";>package info</a>)";
-    push @orphaned_html, "\n";
+    push @orphaned_html, " <pdolink \"$pkg\" />";
+    push @orphaned_html, "</li>\n";
 }
-if ($#orphaned_html == -1) { @orphaned_html = ('<li>No orphaned packages') }
+if ($#orphaned_html == -1) { @orphaned_html = ('<li><noo /></li>') }
 
 foreach my $bug (sort { $ita{$a} cmp $ita{$b} } keys %ita) {
     (my $pkg = $ita{$bug}) =~ s/^(.+):\s+.*$/$1/;
     push @being_adopted_html, 
-         "<li><a href=\"http://bugs.debian.org/$bug\";>$ita{$bug}</a>";
+         "<li><btsurl bugnr=\"$bug\">$ita{$bug}</btsurl>";
     push @being_adopted_html,
-         " (<a href=\"http://packages.debian.org/$pkg\";>package info</a>), ";
-    if ( $age{$bug} == 0 ) { push @being_adopted_html, "in adoption since today." }
-    elsif ( $age{$bug} == 1 ) { push @being_adopted_html, "in adoption since yesterday." }
-    else { push @being_adopted_html, "$age{$bug} days in adoption." };
-         "$age{$bug} days in adoption\n";
-    push @being_adopted_html, "\n";
+         " <pdolink \"$pkg\" />, ";
+    if ( $age{$bug} == 0 ) { push @being_adopted_html, '<adoption-today />' }
+    elsif ( $age{$bug} == 1 ) { push @being_adopted_html, '<adoption-yesterday />' }
+    else { push @being_adopted_html, "<adoption-days \"$age{$bug}\" />" };
+    push @being_adopted_html, "</li>\n";
 }
-if ($#being_adopted_html == -1) { @being_adopted_html = ('<li>No packages waiting to be adopted') }
+if ($#being_adopted_html == -1) { @being_adopted_html = ('<li><noita /></li>') }
 
 foreach (sort { $itp{$a} cmp $itp{$b} } keys %itp) {
     push @being_packaged_html, 
-         "<li><a href=\"http://bugs.debian.org/$_\";>$itp{$_}</a>, ";
-    if ( $age{$_} == 0 ) { push @being_packaged_html, "in preparation since today." }
-    elsif ( $age{$_} == 1 ) { push @being_packaged_html, "in preparation since yesterday." }
-    else { push @being_packaged_html, "$age{$_} days in preparation." };
-         "$age{$_} days in preparation\n";
-    push @being_packaged_html, "\n";
+         "<li><btsurl bugnr=\"$_\">$itp{$_}</btsurl>, ";
+    if ( $age{$_} == 0 ) { push @being_packaged_html, '<prep-today />' }
+    elsif ( $age{$_} == 1 ) { push @being_packaged_html, '<prep-yesterday />' }
+    else { push @being_packaged_html, "<prep-days \"$age{$_}\" />" };
+    push @being_packaged_html, "</li>\n";
 }
-if ($#being_packaged_html == -1) { @being_packaged_html = ('<li>No packages waiting to be packaged') }
+if ($#being_packaged_html == -1) { @being_packaged_html = ('<li><noitp /></li>') }
 
 foreach (sort { $rfp{$a} cmp $rfp{$b} } keys %rfp) {
     push @requested_html, 
-         "<li><a href=\"http://bugs.debian.org/$_\";>$rfp{$_}</a>, ";
-    if ( $age{$_} == 0 ) { push @requested_html, "requested today." }
-    elsif ( $age{$_} == 1 ) { push @requested_html, "requested yesterday." }
-    else { push @requested_html, "requested $age{$_} days ago.\n" };
-    push @requested_html, "\n";
-}
-if ($#requested_html == -1) { @requested_html = ('<li>No Requested packages') }
+         "<li><btsurl bugnr=\"$_\">$rfp{$_}</btsurl>, ";
+    if ( $age{$_} == 0 ) { push @requested_html, '<req-today />' }
+    elsif ( $age{$_} == 1 ) { push @requested_html, '<req-yesterday />' }
+    else { push @requested_html, "<req-days \"$age{$_}\" />" };
+    push @requested_html, "</li>\n";
+}
+if ($#requested_html == -1) { @requested_html = ('<li><norfp /></li>') }
+
+<protect pass="2">
+print "\\#use wml::debian::wnpp\n";
+print "<define-tag rfa_bypackage><ul>@rfa_bypackage_html</ul></define-tag>\n";
+print "<define-tag rfa_bymaint><ul>@rfa_bymaint_html</ul></define-tag>\n";
+print "<define-tag orphaned><ul>@orphaned_html</ul></define-tag>\n";
+print "<define-tag being_adopted><ul>@being_adopted_html</ul></define-tag>\n";
+print "<define-tag being_packaged><ul>@being_packaged_html</ul></define-tag>\n";
+print "<define-tag requested><ul>@requested_html</ul></define-tag>\n";
+</protect>
 
 </perl>
# for gettext
#use wml::debian::common_tags

# define messages for empty lists
<bind-gettext-domain domain="templates">

<define-tag norfa whitespace="delete">
<gettext domain="templates">No requests for adoption</gettext>
</define-tag>

<define-tag noo whitespace="delete">
<gettext domain="templates">No orphaned packages</gettext>
</define-tag>

<define-tag noita whitespace="delete">
<gettext domain="templates">No packages waiting to be adopted</gettext>
</define-tag>

<define-tag noitp whitespace="delete">
<gettext domain="templates">No packages waiting to be packaged</gettext>
</define-tag>

<define-tag norfp whitespace="delete">
<gettext domain="templates">No Requested packages</gettext>
</define-tag>


# define messages for timespans
<define-tag adoption-today>
<gettext domain="templates">in adoption since today.</gettext>
</define-tag>

<define-tag adoption-yesterday>
<gettext domain="templates">in adoption since yesterday.</gettext>
</define-tag>

<define-tag adoption-days>
<gettext domain="templates">%0 days in adoption.</gettext>
</define-tag>

<define-tag prep-today>
<gettext domain="templates">in preparation since today.</gettext>
</define-tag>

<define-tag prep-yesterday>
<gettext domain="templates">in preparation since yesterday.</gettext>
</define-tag>

<define-tag prep-days>
<gettext domain="templates">%0 days in in preparation.</gettext>
</define-tag>

<define-tag req-today>
<gettext domain="templates">requested today.</gettext>
</define-tag>

<define-tag req-yesterday>
<gettext domain="templates">requested yesterday.</gettext>
</define-tag>

<define-tag req-days>
<gettext domain="templates">requested %0 days ago.</gettext>
</define-tag>

# define tags for BTS and p.d.o links

<define-tag btsurl whitespace="delete" endtag="required">
<preserve bugnr />
<set-var %attributes />
<a href="http://bugs.debian.org/<get-var bugnr />">%body</a>
<restore bugnr />
</define-tag>

<define-tag pdolink whitespace="delete">
(<a href="http://packages.debian.org/%0";>\
<gettext domain="templates">package info</gettext>\
</a>)
</define-tag>
#use wml::debian::template title="Packages currently being adopted" GEN_TIME="true"

#include "$(ENGLISHDIR)/devel/wnpp/wnpp.data"

<being_adopted />
#use wml::debian::template title="Packages being worked on" GEN_TIME="true"

#include "$(ENGLISHDIR)/devel/wnpp/wnpp.data"

<being_packaged />
#use wml::debian::template title="Orphaned packages" GEN_TIME="true"

#include "$(ENGLISHDIR)/devel/wnpp/wnpp.data"

<orphaned />
#use wml::debian::template title="Prospective packages" GEN_TIME="true"

#include "$(ENGLISHDIR)/devel/wnpp/wnpp.data"

<h3>Packages being worked on</h3>
<being_packaged />

<h3>Requested packages</h3>
<requested />
#use wml::debian::template title="Requested packages" GEN_TIME="true"

#include "$(ENGLISHDIR)/devel/wnpp/wnpp.data"

<requested />
#use wml::debian::template title="Packages up for adoption, by maintainer" GEN_TIME="true"

#include "$(ENGLISHDIR)/devel/wnpp/wnpp.data"

<rfa_bymaint />
#use wml::debian::template title="Packages up for adoption" GEN_TIME="true"

#include "$(ENGLISHDIR)/devel/wnpp/wnpp.data"

<rfa_bypackage />
#use wml::debian::template title="Packages in need of a new maintainer" GEN_TIME="true"

#include "$(ENGLISHDIR)/devel/wnpp/wnpp.data"

<h3>Packages up for adoption</h3>
<rfa_bypackage />

<h3>Packages up for adoption, by maintainer</h3>
<rfa_bymaint />

<h3>Orphaned packages</h3>
<orphaned />

Reply to: