"Clean up code, more style compatible (for as far as that is possible

with Perl code)"

PR:		www/124055
Submitted by:	edwin
This commit is contained in:
Remko Lodder 2008-05-30 15:22:01 +00:00
parent b8b3963f25
commit b79cea38a1
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/www/; revision=32089

View file

@ -1,7 +1,7 @@
#!/usr/bin/perl -w
#
# $Id: multimedia.pl,v 1.1 2007-05-15 21:30:41 keramida Exp $
# $Id: multimedia.pl,v 1.2 2008-05-30 15:22:01 remko Exp $
# $FreeBSD$
#
@ -73,6 +73,11 @@ sub xml_start {
$sid = $values[$treeindex]{id};
$sources{$values[$treeindex]{id}} = ();
}
if ($element eq "url"
&& $treeindex == 5) {
$items[$ci]{fc}++;
}
}
sub xml_end {
@ -97,7 +102,8 @@ sub xml_char {
return if ($treeindex == 2);
if ($tree[3] eq "title") {
$items[$ci]{title}=$value;
$items[$ci]{title} = "" if (!defined $items[$ci]{title});
$items[$ci]{title} .= $value;
return;
}
if ($tree[3] eq "desc") {
@ -106,11 +112,13 @@ sub xml_char {
return;
}
if ($tree[3] eq "overview") {
$items[$ci]{overview}=$value;
$items[$ci]{overview} = "" if (!defined $items[$ci]{desc});
$items[$ci]{overview} .= $value;
return;
}
if ($tree[3] eq "link") {
$items[$ci]{link}=$value;
$items[$ci]{link} = "" if (!defined $items[$ci]{link});
$items[$ci]{link} .= $value;
return;
}
if ($tree[3] eq "tags") {
@ -132,20 +140,28 @@ sub xml_char {
return if ($treeindex == 4);
if ($tree[5] eq "url") {
$items[$ci]{fc}++;
$items[$ci]{files}{$items[$ci]{fc}}{url}=$value;
# Note that $items[$ci]{fc} gets incremented in xml_start
$items[$ci]{files}{$items[$ci]{fc}}{url} = ""
if (!defined $items[$ci]{files}{$items[$ci]{fc}}{url});
$items[$ci]{files}{$items[$ci]{fc}}{url} .= $value;
return;
}
if ($tree[5] eq "size") {
$items[$ci]{files}{$items[$ci]{fc}}{size}=$value;
$items[$ci]{files}{$items[$ci]{fc}}{size} = ""
if (!defined $items[$ci]{files}{$items[$ci]{fc}}{size});
$items[$ci]{files}{$items[$ci]{fc}}{size} .= $value;
return;
}
if ($tree[5] eq "length") {
$items[$ci]{files}{$items[$ci]{fc}}{length}=$value;
$items[$ci]{files}{$items[$ci]{fc}}{length} = ""
if (!defined $items[$ci]{files}{$items[$ci]{fc}}{length});
$items[$ci]{files}{$items[$ci]{fc}}{length} .= $value;
return;
}
if ($tree[5] eq "desc") {
$items[$ci]{files}{$items[$ci]{fc}}{desc}=$value;
$items[$ci]{files}{$items[$ci]{fc}}{desc} = ""
if (!defined $items[$ci]{files}{$items[$ci]{fc}}{desc});
$items[$ci]{files}{$items[$ci]{fc}}{desc} .= $value;
return;
}
if ($tree[5] eq "tags") {
@ -249,8 +265,27 @@ sub print_htmlitem {
print FOUT ")";
}
}
print FOUT "<br>Source: <a href=\"",$source{url},"\">",$source{name},"</a><br>\n";
print FOUT "Tags: ",join(", ",@{$item{tags}}),"<br>\n";
print FOUT "<br>Source: <a href=\"", $source{url}, "\">",
$source{name}, "</a><br>\n";
print FOUT "Added: ",
substr($item{added}, 6, 2), " ",
$months[substr($item{added}, 4, 2)], " ",
substr($item{added}, 0, 4), "<br>\n";
print FOUT "Tags: ";
{
my $first = 1;
foreach my $t (@{$item{tags}}) {
print FOUT ", " if (!$first);
# join(", ", @{$item{$t}}), "<br>\n";
my $th = $t;
$th =~ s/ /_/g;
print FOUT "<a href=\"multimedia-tag-$th.html\">$t</a>";
$first = 0;
}
}
print FOUT "<br>\n";
if (defined $item{overview} && defined $item{files}) {
my $c = 0;
foreach my $m (keys(%{$item{files}})) {
@ -530,10 +565,11 @@ sub print_htmlitem {
my %file = %{$file};
my $date = POSIX::strftime("%a, %d %b %Y %H:%M:%S %Z",
0,0,0,substr($item{added},6,2),substr($item{added},4,2)-1,substr($item{added},0,4)-1900);
0, 0, 0, substr($item{added}, 6, 2),
substr($item{added}, 4, 2)-1, substr($item{added}, 0, 4)-1900);
my $tags = join(", ", @{$item{tags}});
for my $tag (@{$file{tags}}) {
foreach my $tag (@{$file{tags}}) {
$tags .= ", $tag";
}