/[pxelator]/lib/PXElator/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

Diff of /lib/PXElator/html.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 315 by dpavlin, Thu Aug 27 19:58:18 2009 UTC revision 376 by dpavlin, Sun Aug 30 15:22:41 2009 UTC
# Line 1  Line 1 
1  package html;  package html;
2    
3  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
4    use amt;
5    
6  sub table {  sub table {
7          my $cols = shift;          my $cols = shift;
# Line 66  sub pre_dump { Line 67  sub pre_dump {
67          qq|<pre>$dump</pre>|;          qq|<pre>$dump</pre>|;
68  }  }
69    
70    sub conf {
71            my ($ip,$conf,$format) = @_;
72            my @editable = splice(@_,3);
73    
74            warn "# conf ",dump( $ip, $conf, $format, [ @editable ] );
75    
76            $format ||= 'inline';
77    
78            my @opts = map {
79                    my $name = $_;
80                    my $html = $conf->{$name};
81    
82                    if ( $format eq 'edit' && grep { m/^$name$/ } @editable ) {
83                            $size = length($html);
84                            ( $name, qq|<input name=$name value="$html" size=$size>| )
85                    } else {
86                            if ( $name eq 'amt' ) {
87                                    $html = qq|<a title="$html" href=http://$ip:16992/logon.htm>logon</a>|;
88    
89                                    $html .= qq| power: |
90                                            . ( amt::power_on($ip)
91                                                    ? qq|<a href=/amt/PowerDown/$ip title="turn off">on</a>|
92                                                    : qq|<a href=/amt/PowerUp/$ip   title="turn on" >off</a>|
93                                            ) if $format ne 'inline';
94                            } elsif ( $name eq 'ssh' ) {
95                                    $html =~ s{\s(\S{16}).+(\S{16})\s}{ $1..$2 };
96                                    chomp($html);
97                            }
98                            $html = qq|<pre style="display: inline">$html</pre>|
99                            unless
100                            $html =~ s{\b(\S+)\t(\S+)\t(\S+)\b}{<b title="$1/$2">$3</b> }gs;
101                    
102                            if ( $format =~ /edit|table/ ) {
103                                    ( $name, $html );
104                            } else {
105                                    qq|<em>$name</em> $html<br>|
106                            }
107                    }
108            } sort keys %$conf;
109    
110            $format eq 'inline' ? join("\n", @opts) : @opts;
111    }
112    
113  warn "loaded";  warn "loaded";
114    
115  1;  1;

Legend:
Removed from v.315  
changed lines
  Added in v.376

  ViewVC Help
Powered by ViewVC 1.1.26