2 # Common functions for HTML/XHTML output generation
3 # Copyright (C) 2003 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; exactly version 2 of June 1991 is required
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway
21 our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
30 our @ISA=qw(My::Web Exporter);
33 sub ENTRIES { return top_dir_disk()."/project/CVS/Entries"; }
34 sub ENTRIES_LOG { return top_dir_disk()."/project/CVS/Entries.Log"; }
39 my($class,$ListItem)=@_;
41 print "<h1>".$W->{"title"}."</h1>\n";
42 print $ListItem->{"description"};
45 {"key"=>"summary","text"=>"Summary"},
46 {"key"=>"license","text"=>"License","format"=>sub ($) {
48 "PD"=>"Public Domain",
49 "GPL"=>a_href("http://www.gnu.org/licenses/gpl.html","GNU General Public License"),
50 "LGPL"=>a_href("http://www.gnu.org/licenses/lgpl.html","GNU Lesser General Public License"),
55 {"key"=>"maintenance","text"=>"State","format"=>sub ($) {
57 "active"=>"Ready to use. Project is now actively developed.",
58 "ready"=>"Ready to use. Maintained.",
59 "pending"=>"Patch is ready to be applied to the mainstream.",
60 "dead"=>"Dead code, no longer supported.",
61 "merge"=>"Functions belong to existing other project.",
62 "obsolete"=>"Obsoleted.",
63 "update"=>"Package needs updating to recent software.",
64 "accepted"=>"This patch got already integrated by the original package maintainer.",
68 for ($known{($_[0]=~/^([^-]*)-?/)[0] || ""}) {
74 {"key"=>"aminet","text"=>a_href('http://www.aminet.net/','Aminet'),"format"=>sub ($) {
76 a_href('http://www.aminet.net/'.$_[0].".lha",$_[0].".lha"),
77 "(".a_href('http://www.aminet.net/'.$_[0].".readme","readme").")");
79 {"key"=>qr(^download\b),"text"=>sub ($) {
82 return "Download".$_[0];
85 return a_href($_[0],CGI::escapeHTML(File::Basename::basename($_[0])));
87 {"key"=>qr(^link\b),"text"=>sub ($) {
92 return($_[0]=~/^<a\b/ ? $_[0] : a_href($_[0],CGI::escapeHTML($_[0])));
94 {"key"=>qr(^cvs\b),"text"=>sub ($) {
104 $branch=$1 if $val=~s/:(.*)//;
105 return join("<br />\n\t\t",
106 CGI::escapeHTML("cvs -d ".$W->{"pserver"}.":".$W->{"pserver_path"}." -z3"
107 ." checkout".(!$branch ? "" : " -r $branch -kk")
108 .($val!~m#/# ? "" : " -d ".File::Basename::basename($val))
111 map({ a_href($_->[1],$_->[0]); }
112 ["ViewCVS CVS repository",$W->{"project_viewcvs"}.$val."/".(!$branch ? "" : '?only_with_tag='.$branch)],
113 ["Download CVS snapshot" ,
114 $W->{"project_viewcvs"}.$val."/".File::Basename::basename($val).".tar.gz?tarball=1"
115 .(!$branch ? "" : '&only_with_tag='.$branch)],
116 ["CVS ChangeLog" ,top_dir()."/project/ChangeLog.txt.pl?cvs=$val"])));
118 {"key"=>"ownership","text"=>"Ownership"},
119 {"key"=>"sponsorship","text"=>"Sponsorship"},
120 {"key"=>"language","text"=>"Programming language","format"=>sub ($) {
121 return a_href("http://java.sun.com/",CGI::escapeHTML($_[0]))
123 return a_href("http://www.php.net/",CGI::escapeHTML($_[0]))
131 my($tableit,$val,$key,$ListItem)=@_;
133 delete $ListItem->{$key};
136 if ($tableit->{"text"}) {
138 $r.=(!ref $_ ? $_ : &{$_}($key)) for ($tableit->{"text"});
141 if ($tableit->{"format"}) {
142 do { $val=$_ if defined $_; } for (&{$tableit->{"format"}}($val,$key));
144 return join("",map("<tr><td>".$_->[0]."</td><td>".$_->[1]."</td></tr>\n",@$val))
150 print '<table border="0" class="print_project">'."\n";
151 for my $tableit (@table) {
152 if (!ref $tableit->{"key"}) {
153 print tableit_func($tableit,$ListItem->{$tableit->{"key"}},$tableit->{"key"},$ListItem)
154 if $ListItem->{$tableit->{"key"}};
157 for my $key (@{$ListItem->{"keys_array"}}) {
158 my $keyregex=$tableit->{"key"};
159 next if $key!~/$keyregex/;
160 print tableit_func($tableit,$ListItem->{$key},$key,$ListItem);
168 sub project_arr_to_hash (@)
174 "keys_array"=>[ My::Web::arr_keys(@arr) ],
178 # $args{"ListItem"}=\%...;
179 sub init_project ($%)
183 my $ListItem={ project_arr_to_hash(@{$args{"ListItem"}}) };
185 "title"=>$ListItem->{"name"}.": ".$ListItem->{"summary"},
187 "head_css"=>($args{"head_css"} || "")."
188 table.print_project td { vertical-align: top; }
190 "WebConfig::heading_novskip"=>1,
193 print $class->platforms($ListItem->{"platform"});
194 $class->print_project({ %$ListItem });
198 sub item_hash_read ()
201 for my $ENTRIES (ENTRIES(),ENTRIES_LOG()) {
203 next if !open E,$ENTRIES;
206 do { $dirs{$1}=1; next; } if m#^(?:A )?D/([^/]*)/#;
207 next if m#^/([^/]*)/# ;
209 warn "File $ENTRIES contains invalid line \"$_\": $!";
215 for my $dir (keys(%dirs)) {
216 Wrequire "project::${dir}::ListItem";
217 my $item=eval('\@project::'.$dir.'::ListItem::ListItem');
218 do { warn "Broken project/$dir/ListItem.pm"; next; } if !defined $item;
219 $item{$dir}={ My::Project::project_arr_to_hash(@$item) };
225 "unixuser"=>"GNU/Linux",
226 "unixdevel"=>"GNU/Linux Development",
236 my($class,$view_selected)=@_;
240 my($current,$href,$content)=@_;
242 return a_href($href,$content) if $current ne $view_selected;
243 return "<b>".$content."</b> (current)";
247 <h1>Project List of @{[ a_href 'http://www.jankratochvil.net/','Jan Kratochvil' ]}</h1>
250 <li>@{[ &{$view}('Detailed' ,top_dir().'/project/','Detailed project listing per platform') ]}</li>
251 <li>@{[ &{$view}('BriefPlatform',top_dir().'/project/List.html.pl?platform=platform',
252 'Brief project listing per platform') ]}</li>
253 <li>@{[ &{$view}('BriefUnified' ,top_dir().'/project/List.html.pl',
254 'Unified brief project listing') ]}</li>
262 my($class,$platform_selected)=@_;
265 $r.='<table border="0" align="center"><tr>'."\n";
266 $r.='<td>Projects: </td>';
268 $r.='<table border="1" align="center" style="border-collapse: collapse; border-style: solid;">'."\n";
270 my @platforms=@platforms;
272 my $platform_sym =shift @platforms;
273 my $platform_name=shift @platforms;
274 my $chosen=($platform_selected && $platform_selected eq $platform_sym);
275 $r.='<td style="padding: 5px;">';
276 $r.=a_href((!$platform_selected ? "" : top_dir()."/project/").'#'.$platform_sym,$platform_name,
278 ? 'style="text-decoration: underline; font-weight: bold;"'
279 : 'style="text-decoration: inherit; /* revoke underline */"'));
285 $r.='</tr></table>'."\n";