]> git.deb.at Git - deb/packages.git/blobdiff - lib/Packages/HTML.pm
Big CSS cleanup, move all style definitions to CSS files.
[deb/packages.git] / lib / Packages / HTML.pm
index a291a0028b6285d15e76880f35c9e1dfead4af1b..d6d194b5d35e1eaf5d16fc8702b18408a71457d2 100644 (file)
@@ -52,7 +52,7 @@ sub title {
 }
 
 sub marker {
-    return "[<span class=\"pred\">$_[0]</span>]";
+    return "[<strong class=\"pmarker\">$_[0]</strong>]";
 }
 
 sub pdesc {
@@ -69,7 +69,7 @@ sub pdesc {
 }
 
 sub pdeplegend {
-    my $str = "<table border=\"1\" summary=\"legend\"><tr>\n";
+    my $str = "<table id=\"pdeplegend\" summary=\"legend\"><tr>\n";
 
     foreach my $entry (@_) {
        $str .= "<td><img src=\"$ROOT/Pics/$entry->[0].gif\" alt=\"[$entry->[0]]\" width=\"16\" height=\"16\">= $entry->[1]</td>";
@@ -81,14 +81,15 @@ sub pdeplegend {
 
 sub pkg_list {
     my ( $packages, $opts, $pkgs, $lang ) = @_;
+    my $suite = $opts->{suite}[0];
 
     my $str = "";
     foreach my $p ( @$pkgs ) {
 
-       my $short_desc = (read_entry_simple( $packages, $p, $opts->{h_archives}, $opts->{suite}))->[-1];
+       my $short_desc = (read_entry_simple( $packages, $p, $opts->{h_archives}, $suite))->[-1];
 
        if ( $short_desc ) {
-           $str .= "<dt><a href=\"$ROOT/$opts->{suite}/$p\">$p</a></dt>\n".
+           $str .= "<dt><a href=\"$ROOT/$suite/$p\">$p</a></dt>\n".
                    "\t<dd>$short_desc</dd>\n";
        } else {
            $str .= "<dt>$p</dt>\n\t<dd>".gettext("Not available")."</dd>\n";
@@ -109,6 +110,7 @@ sub pmoreinfo {
     my $opts = $info{opts} or return;
     my $page = $info{data} or return;
     my $is_source = $info{is_source};
+    my $suite = $opts->{suite}[0];
 
     my $str = "<div id=\"pmoreinfo\">";
     $str .= sprintf( "<h2>".gettext( "More Information on %s" )."</h2>",
@@ -126,17 +128,17 @@ sub pmoreinfo {
     if ($info{sourcedownload}) {
        my $files = $page->get_src( 'files' );
        my $path = (@{$opts->{archive}} >1) ?
-           $opts->{suite} :
-           "$opts->{suite}/$opts->{archive}[0]";
+           $suite :
+           "$suite/$opts->{archive}[0]";
        $str .= gettext( "Source Package:" );
-       $str .= " <a href=\"/$path/source/$source\">$source</a>, ".
+       $str .= " <a href=\"$ROOT/$path/source/$source\">$source</a>, ".
            gettext( "Download" ).":\n";
 
        unless (defined($files) and @$files) {
            $str .= gettext( "Not found" );
        } else {
            foreach( @$files ) {
-               my ($src_file_md5, $src_file_size, $src_file_name) = @$_;
+               my ($src_file_md5, $src_file_size, $src_file_name) = split /\s/o, $_;
                for ($page->get_newest('archive')) {
                    /security/o && do {
                        $str .= "<a href=\"$env->{security}/$src_dir/$src_file_name\">["; last };
@@ -206,8 +208,9 @@ sub pmoreinfo {
 
     if ($info{search}) {
        my $encodedname = uri_escape( $name );
-       my $search_url = $is_source ? $SRC_SEARCH_URL : $SEARCH_URL;
-       $str .= "<p>".sprintf( gettext( "Search for <a href=\"%s\">other versions of %s</a>" ), $search_url.$encodedname, $name )."</p>\n";
+       my $search_url = $is_source ? "$ROOT/source" : $ROOT;
+       $str .= "<p>".sprintf( gettext( "Search for <a href=\"%s\">other versions of %s</a>" ),
+           "$search_url/$encodedname", $name )."</p>\n";
     }
 
     $str .= "</div> <!-- end pmoreinfo -->\n";
@@ -240,9 +243,12 @@ sub dep_item {
 sub print_deps {
     my ( $packages, $opts, $pkg, $relations, $type) = @_;
     my %dep_type = ('depends' => 'dep', 'recommends' => 'rec', 
-                   'suggests' => 'sug');
+                   'suggests' => 'sug', 'build-depends' => 'adep',
+                   'build-depends-indep' => 'idep' );
     my $res = "<ul class=\"ul$dep_type{$type}\">\n";
     my $first = 1;
+    my $suite = $opts->{suite}[0];
+    my $one_archive = @{$opts->{archive}} > 1 ? '': $opts->{archive}[0];
 
 #    use Data::Dumper;
 #    debug( "print_deps called:\n".Dumper( $pkg, $relations, \$type ), 3 );
@@ -268,27 +274,42 @@ sub print_deps {
            my ( $p_name, $pkg_version, $arch_neg,
                 $arch_str, $subsection, $available ) = @$rel_alt;
 
-           if ($arch_str) {
+           if ($arch_str ||= '') {
                if ($arch_neg) {
                    $arch_str = " [".gettext("not")." $arch_str]";
                } else {
                    $arch_str = " [$arch_str]";
                }
            }
-           $pkg_version = "($pkg_version)" if $pkg_version;
+           $pkg_version = "($pkg_version)" if $pkg_version ||= '';
            
            my @results;
-           my %short_descs;
-           my $short_desc = $short_descs{$p_name} ||
-               (read_entry_simple( $packages, $p_name, $opts->{h_archives}, $opts->{suite}))->[-1];
+           my %entries;
+           my $entry = $entries{$p_name} ||
+               read_entry_simple( $packages, $p_name, $opts->{h_archives}, $suite);
+           my $short_desc = $entry->[-1];
+           my $arch = $entry->[2];
+           my $archive = $entry->[0];
            if ( $short_desc ) {
+               my $path = $one_archive eq $archive ? "$suite/$archive" :
+                   $suite;
                if ( $is_old_pkgs ) {
-                   push @res_pkgs, dep_item( "/$opts->{suite}/$p_name",
+                   push @res_pkgs, dep_item( "$ROOT/$path/$p_name",
                                              $p_name, "$pkg_version$arch_str" );
+               } elsif ($arch eq 'virtual') {
+                   my @provided_by = split /\s/, $short_desc;
+                   $short_desc = "virtual package provided by ";
+                   if (@provided_by < 10) {
+                       $short_desc .= join( ', ',map { "<a href=\"$ROOT/$path/$_\">$_</a>" } @provided_by);
+                   } else {
+                       $short_desc .= scalar(@provided_by)." packages";
+                   }
+                   push @res_pkgs, dep_item( "$ROOT/$path/$p_name",
+                                             $p_name, "$pkg_version$arch_str", $short_desc );
                } else {
-                   $short_descs{$p_name} ||= $short_desc;
+                   $entries{$p_name} ||= $entry;
                    $short_desc = encode_entities( $short_desc, "<>&\"" );
-                   push @res_pkgs, dep_item( "/$opts->{suite}/$p_name",
+                   push @res_pkgs, dep_item( "$ROOT/$path/$p_name",
                                              $p_name, "$pkg_version$arch_str", $short_desc );
                }
            } elsif ( $is_old_pkgs ) {
@@ -311,50 +332,6 @@ sub print_deps {
     return $res;
 } # end print_deps
 
-sub print_src_deps {
-    my ( $packages, $opts, $pkg, $relations, $type) = @_;
-    my %dep_type = ('build-depends' => 'adep', 'build-depends-indep' => 'idep' );
-    my $res = "<ul class=\"ul$dep_type{$type}\">\n";
-    foreach my $dep (@$relations) {
-       my @res_pkgs;
-       $res .= "<li><dl><dt><img class=\"hidecss\" src=\"$ROOT/Pics/$dep_type{$type}.gif\" alt=\"[$dep_type{$type}]\"> ";
-       foreach my $or_dep ( @$dep ) {
-           my $p_name = $or_dep->[0];
-           my $p_version = $or_dep->[1] ? "(".encode_entities( $or_dep->[1] ).
-               " $or_dep->[2]) " : "";
-           my $not = gettext( "not" );
-           my $arch_str = '';
-           if ($or_dep->[3] && @{$or_dep->[3]}) {
-               # as either all or no archs have to be prepended with
-               # exlamation marks, convert the first and delete the others
-               if ($or_dep->[3][0] =~ /^!/) {
-                   $arch_str = "$not ";
-                   foreach (@{$or_dep->[3]}) {
-                       $_ =~ s/^!//go;
-                   }
-               }
-               $arch_str = " [${arch_str}@{$or_dep->[3]}]";
-           }
-           my $short_desc = (read_entry_simple( $packages, $p_name, $opts->{h_archives}, $opts->{suite}))->[-1];
-           if ( $short_desc ) {
-               $short_desc = encode_entities( $short_desc, "<>&\"" );
-               push @res_pkgs, dep_item( "/$opts->{suite}/$p_name", $p_name, "$p_version$arch_str", $short_desc );
-           } else {
-               $short_desc = gettext( "Package not available" );
-               push @res_pkgs, dep_item( undef, $p_name, "$p_version$arch_str", $short_desc );
-           }
-       }
-       $res .= "\n".join( "<dt>\n".gettext( "or" )." ", @res_pkgs )."</dl></li>\n";
-    }
-    if (@$relations) {
-        $res .= "\n</ul>";
-    } else {
-        $res = "";
-    }
-       return $res;
-} # end print_src_deps
-
-
 my $ds_begin = '<dl>';
 my $ds_item_desc  = '<dt>';
 my $ds_item = ':</dt><dd>';
@@ -393,42 +370,39 @@ sub header {
     my $page_title = $params{page_title} || $params{title} || '';
     my $meta = $params{meta} || '';
 
-    if ($params{print_title_above}) {
-       $title_in_header = "<h1>$title_in_header</h1>";
-    } else {
-       $title_in_header = '';
-    }
-
     my $search_in_header = '';
     $params{print_search_field} ||= "";
     if ($params{print_search_field} eq 'packages') {
        my %values = %{$params{search_field_values}};
        my %checked_searchon = ( names => "",
                                 all => "",
-                                sourcenames => "", );
+                                sourcenames => "",
+                                contents => "");
        $checked_searchon{$values{searchon}} = "checked=\"checked\"";
+       $checked_searchon{names} = "checked=\"checked\""
+               if $values{searchon} eq 'default';
        $search_in_header = <<MENU;
 <form method="GET" action="$SEARCH_CGI">
 <div id="hpacketsearch">
 <input type="hidden" name="debug" value="$values{debug}">
 <input type="hidden" name="suite" value="$values{suite}">
-<input type="hidden" name="subword" value="$values{subword}">
 <input type="hidden" name="exact" value="$values{exact}">
 <input type="hidden" name="arch" value="$values{arch}">
 <input type="hidden" name="section" value="$values{section}">
-<input type="hidden" name="case" value="$values{case}">
 <input type="text" size="30" name="keywords" value="$values{keywords}" id="kw">
 <input type="submit" value="Search">
 <span style="font-size: 60%"><a href="$SEARCH_PAGE#search_packages">Full options</a></span>
 <br>
 <div style="font-size: 80%">Search on:
 <input type="radio" name="searchon" value="names" id="onlynames" $checked_searchon{names}>
-<label for="onlynames">Package names only</label>&nbsp;&nbsp;
+<label for="onlynames">Package names</label>&nbsp;&nbsp;
 <input type="radio" name="searchon" value="all" id="descs" $checked_searchon{all}>
 <label for="descs">Descriptions</label>
 <br>
 <input type="radio" name="searchon" value="sourcenames" id="src" $checked_searchon{sourcenames}>
 <label for="src">Source package names</label>
+<input type="radio" name="searchon" value="contents" id="conts" $checked_searchon{contents}>
+<label for="conts">Package contents</label>
 </div>
 </div> <!-- end hpacketsearch -->
 </form>
@@ -486,6 +460,7 @@ $KEYWORDS_LINE
 $DESC_LINE
 $meta
 <link href="$ROOT/debian.css" rel="stylesheet" type="text/css" media="all">
+<link href="$ROOT/packages.css" rel="stylesheet" type="text/css" media="all">
 </head>
 <body>
 <div id="header">
@@ -509,7 +484,6 @@ $search_in_header
 
 NAVBEGIN
 ;
-# $title_in_header
     $txt .= "<p class=\"hidecss\"><a href=\"\#inner\">" . gettext("Skip Site Navigation")."</a></p>\n";
     $txt .= "<div id=\"navbar\">\n<ul>".
        "<li><a href=\"$HOME/intro/about\">".gettext( "About&nbsp;Debian" )."</a></li>\n".
@@ -531,10 +505,7 @@ ENDNAV
 
 BEGINCONTENT
 ;
-    if ($params{print_title_above}) {
-       $txt .= "<h1>$page_title</h1>\n";
-    }
-    if ($params{print_title_below}) {
+    if ($params{print_title}) {
        $txt .= "<h1>$page_title</h1>\n";
     }