+make(1) locking by flock(1)
[www.jankratochvil.net.git] / project / List.html.pl
index 06dd078..76b1ec3 100755 (executable)
@@ -34,14 +34,16 @@ Wrequire 'My::Project';
 My::Web->init(
                "__PACKAGE__"=>__PACKAGE__,
                "title"=>'Project List',
+               "args_check"=>{
+                               "platform"=>'^(?:platform)?$',
+                               },
                );
 My::Web->heading();
 
 my $CGI=CGI->new();
 
-print <<"HERE";
-<h1>@{[ a_href './','Project List' ]} of @{[ a_href 'http://www.jankratochvil.net/','Jan Kratochvil' ]}</h1>
-HERE
+print My::Project->views(($W->{"args"}{"platform"} ? "BriefPlatform" : "BriefUnified"));
+print My::Project->platforms(undef()) if $W->{"args"}{"platform"};
 
 my %item=( My::Project::item_hash_read() );
 
@@ -58,7 +60,9 @@ sub format_url ($) { return (!$_[0] ? "" : '<a href="'.$_[0].'">X</a>'); }
 
 $col{"name"}{"format"}=sub {
                $_[0]=~s#<a\s[^>]*>([^<]*)</a>#$1#g;
-               return "<a href=\"".$_[1]."/\">".$_[0]."</a>";
+               return "<a href=\"".$_[1]."/\">"
+                               .$item{$_[1]}{"priority"}.":"   # debug
+                               .$_[0]."</a>";
                };
 
 $col{"license"}{"format"}=sub {
@@ -89,44 +93,66 @@ if (0) {
        push @col_order,map({ ($col_order{$_} ? () : $_); } keys(%{{ map(($_=>1),map((keys(%{$item{$_}})),keys(%item)))}}));
        }
 
-print '<table border="1">'."\n";
-       print '<tr>';
-               for my $col (@col_order) {
-                       next if defined $col{$col}{"show"} && !$col{$col}{"show"};
-                       print '<th>'.($col{$col}{""} || "[$col]").'</th>';
-                       }
-       print '</tr>'."\n";
-       my @rows_ordered=sort {
-                       for my $order_by (@row_order,"name") {
-                               my $order_by=$order_by;
-                               my $minus=($order_by=~s/^(-)//)[0];
-                               my $r=($item{$a}{$order_by} cmp $item{$b}{$order_by});
-                               $r=-$r if $minus;
-                               return $r if $r;
-                               }
-                       return 0;
-                       } keys(%item);
-       for my $row (@rows_ordered) {
+my $print_one_platform=sub ($)
+{
+my($platform)=@_;
+
+       print '<table border="1">'."\n";
                print '<tr>';
-               for my $col (@col_order) {
-                       next if defined $col{$col}{"show"} && !$col{$col}{"show"};
-                       print '<td>';
-                       if (!$col{$col}{"format"}) {
-                               print(($item{$row}{$col} || ""));
+                       for my $col (@col_order) {
+                               next if defined $col{$col}{"show"} && !$col{$col}{"show"};
+                               print '<th>'.($col{$col}{""} || "[$col]").'</th>';
                                }
-                       else {
-                               print(&{$col{$col}{"format"}}($item{$row}{$col},$row));
-                               }
-                       print '</td>';
-                       }
                print '</tr>'."\n";
-               if ($CGI->param("description_opt")) {
-                       print '<tr><td style="border: none;"></td>';
-                       print '<td colspan="'.(scalar(@col_order)-1).'"><blockquote>'.$item{$row}{"description"}.'</blockquote></td>';
+               my @rows_ordered=sort {
+                               for my $order_by (@row_order,"name") {
+                                       my $order_by=$order_by;
+                                       my $minus=($order_by=~s/^(-)//)[0];
+                                       my $r=($item{$a}{$order_by} cmp $item{$b}{$order_by});
+                                       $r=-$r if $minus;
+                                       return $r if $r;
+                                       }
+                               return 0;
+                               } map(($platform && $item{$_}{"platform"} ne $platform ? () : ($_)),keys(%item));
+               for my $row (@rows_ordered) {
+                       print '<tr>';
+                       for my $col (@col_order) {
+                               next if defined $col{$col}{"show"} && !$col{$col}{"show"};
+                               print '<td>';
+                               if (!$col{$col}{"format"}) {
+                                       print(($item{$row}{$col} || ""));
+                                       }
+                               else {
+                                       print(&{$col{$col}{"format"}}($item{$row}{$col},$row));
+                                       }
+                               print '</td>';
+                               }
                        print '</tr>'."\n";
-                       print '<tr><td style="border: none;" colspan="'.scalar(@col_order).'">&nbsp;</td></tr>'."\n";
+                       if ($CGI->param("description_opt")) {
+                               print '<tr><td style="border: none;"></td>';
+                               print '<td colspan="'.(scalar(@col_order)-1).'"><blockquote>'.$item{$row}{"description"}.'</blockquote></td>';
+                               print '</tr>'."\n";
+                               print '<tr><td style="border: none;" colspan="'.scalar(@col_order).'">&nbsp;</td></tr>'."\n";
+                               }
                        }
+       print '</table>'."\n";
+};
+
+
+if (!$W->{"args"}{"platform"}) {
+       &{$print_one_platform}(undef());
+       }
+else {
+       my @platforms=@My::Project::platforms;
+       while (@platforms) {
+               my $platform_sym =shift @platforms;
+               my $platform_name=shift @platforms;
+               print '<a name="'.$platform_sym.'">';
+               print "<h2>$platform_name</h2>";
+               print '</a>'."\n";
+               &{$print_one_platform}($platform_sym);
                }
-print '</table>'."\n";
+       }
+
 
 My::Web->footer();