4 # List of projects Perl template.
5 # Copyright (C) 2003 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; exactly version 2 of June 1991 is required
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 package project::Index;
22 require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway
23 our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
28 BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,<F>)[0]]}; eval "use lib '$top_dir'"; close F; }
31 Wrequire 'My::Project';
35 "__PACKAGE__"=>__PACKAGE__,
36 "title"=>'Project List',
43 <h1>Project List of <a href="mailto:web-www.jankratochvil.net@jankratochvil.net">Jan Kratochvil</a></h1>
45 <form action="Index.html.pl" method="get"><p>
46 <select name="description_opt" onchange="this.form.submit();">
48 print '<option value="0"'.(!$CGI->param("description_opt") ? ' selected="selected"' : '').'>only list</option>'."\n";
49 print '<option value="1"'.( $CGI->param("description_opt") ? ' selected="selected"' : '').'>incl. descriptions</option>'."\n";
52 <input type="submit" value="Update" />
56 my %item=( My::Project::item_hash_read() );
58 # $col{"name"}{"show"}=1
59 # $col{"name"}{"format"}=sub { "<".$_[0].">"; }
60 # $col{"name"}{""}="Project name";
63 my @row_order=qw(-priority);
64 my @col_order=qw(name summary license maintenance language);
67 sub format_url ($) { return (!$_[0] ? "" : '<a href="'.$_[0].'">X</a>'); }
69 $col{"name"}{"format"}=sub {
70 $_[0]=~s#<a\s[^>]*>([^<]*)</a>#$1#g;
71 return "<a href=\"".$_[1]."/\">".$_[0]."</a>";
74 $col{"license"}{"format"}=sub {
76 "PD"=>"<a href=\"http://www.gnu.org/philosophy/categories.html#PublicDomainSoftware\">PD</a>",
77 "GPL"=>"<a href=\"http://www.gnu.org/licenses/gpl.html\">GPL</a>",
78 "LGPL"=>"<a href=\"http://www.gnu.org/licenses/lgpl.html\">LGPL</a>",
80 return $known{$_[0]} if $known{$_[0]};
84 $col{"maintenance"}{"format"}=sub {
85 return ($_[0]=~/^([^-]*)/)[0];
88 $col{"online-demo"}{"format"}=\&format_url;
89 $col{"download"}{"format"}=\&format_url;
90 $col{"name"}{""}="Project Name";
91 $col{"summary"}{""}="Abstract";
92 $col{"license"}{""}="Copying";
93 $col{"maintenance"}{""}="State";
94 $col{"language"}{""}="Language";
96 # Fill in cols not contained in @col_order
98 my %col_order=map(($_=>1),@col_order);
99 push @col_order,map({ ($col_order{$_} ? () : $_); } keys(%{{ map(($_=>1),map((keys(%{$item{$_}})),keys(%item)))}}));
102 print '<table border="1">'."\n";
104 for my $col (@col_order) {
105 next if defined $col{$col}{"show"} && !$col{$col}{"show"};
106 print '<th>'.($col{$col}{""} || "[$col]").'</th>';
109 my @rows_ordered=sort {
110 for my $order_by (@row_order,"name") {
111 my $order_by=$order_by;
112 my $minus=($order_by=~s/^(-)//)[0];
113 my $r=($item{$a}{$order_by} cmp $item{$b}{$order_by});
119 for my $row (@rows_ordered) {
121 for my $col (@col_order) {
122 next if defined $col{$col}{"show"} && !$col{$col}{"show"};
124 if (!$col{$col}{"format"}) {
125 print(($item{$row}{$col} || ""));
128 print(&{$col{$col}{"format"}}($item{$row}{$col},$row));
133 if ($CGI->param("description_opt")) {
134 print '<tr><td style="border: none;"></td>';
135 print '<td colspan="'.(scalar(@col_order)-1).'"><blockquote>'.$item{$row}{"description"}.'</blockquote></td>';
137 print '<tr><td style="border: none;" colspan="'.scalar(@col_order).'"> </td></tr>'."\n";
140 print '</table>'."\n";