/[Sack]/trunk/lib/Sack/Server/HTML.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Sack/Server/HTML.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 218 - (show annotations)
Sun Nov 22 20:48:08 2009 UTC (14 years, 7 months ago) by dpavlin
File size: 1106 byte(s)
generate gnuplot graphs

1 package Sack::Server::HTML;
2
3 use warnings;
4 use strict;
5
6 use lib '/srv/Sack/lib';
7 use Sack::Server::Gnuplot;
8
9 sub send_out {
10 my ( $send, $out, $key, $param ) = @_;
11
12 my ( @x, @y );
13
14 my $sort = $param->{sort} || 'k';
15 my $order = $param->{order} || 'd';
16
17 my $o = $order eq 'u' ? 'd' : 'u';
18 my $s = $sort eq 'k' ? 'v' : 'k';
19
20 print $send qq|<h1>$key</h1>\n<table>\n<tr>|;
21
22 print $send map {
23 if ( $sort eq $_ ) {
24 qq|<th>$_ <a href="?sort=$_;order=$o">&${o}arr;</th>|
25 } else {
26 qq|<th><a href="?sort=$s;order=d">$_ &darr;</a></th>|
27 }
28 } ( 'k', 'v' );
29
30 print $send qq|</tr>\n|;
31
32 foreach my $name (
33 sort {
34 $sort eq 'k'
35 ? ( $order eq 'd' ? $a cmp $b : $b cmp $a )
36 : ( $order eq 'd' ? $out->{$key}->{$a} <=> $out->{$key}->{$b}
37 : $out->{$key}->{$b} <=> $out->{$key}->{$a} )
38 ;
39 }
40 keys %{ $out->{$key} }
41 ) {
42 my $v = $out->{$key}->{$name};
43 print $send qq|<tr><td>$name</td><td>$v</td></tr>\n|;
44
45 if ( $key =~ m/^date/ ) {
46 push @x, $name;
47 push @y, $v;
48 }
49 }
50 print $send qq|</table>|;
51
52 Sack::Server::Gnuplot::date( \@x, \@y, "/tmp/$key.png" ) if @x;
53 }
54
55 1;

  ViewVC Help
Powered by ViewVC 1.1.26