Better formatting.

This commit is contained in:
Bradley M. Kuhn 2014-01-01 15:53:55 -05:00
parent 94c6f646f5
commit c6c9f7095c

View file

@ -104,7 +104,10 @@ my $info = ReadRecentWeatherAlerts($DIR);
foreach my $location (keys %data) { foreach my $location (keys %data) {
die "Missing $location!" if (not defined $data{$location}{alerts}); die "Missing $location!" if (not defined $data{$location}{alerts});
next if $data{$location}{alerts} =~ /no\s*warning/i; next if $data{$location}{alerts} =~ /no\s*warning/i;
if ($output eq "") {
print "\${color5}\${font :size=20}WEATHER ALERT:\n"; print "\${color5}\${font :size=20}WEATHER ALERT:\n";
$vpos += 20 * $TEXT_LINE_OFFSET_VPOS_AMOUNT;
}
$data{$location}{updatetime} =~ s/\s*last\s*updated?\s*(at|on)\s*//i; $data{$location}{updatetime} =~ s/\s*last\s*updated?\s*(at|on)\s*//i;
my $datetime = ParseDate($data{$location}{updatetime}); my $datetime = ParseDate($data{$location}{updatetime});
@ -115,18 +118,21 @@ foreach my $location (keys %data) {
} else { } else {
$ago = $data{$location}{updatetime}; $ago = $data{$location}{updatetime};
} }
my $data = autoformat $data{$location}{alerts}, { justify => 'left', my $data = $data{$location}{alerts};
fill => 70}; my $conkyOut = autoformat(
my $numLines = $data =~ tr/\n/\n/; "\${font :size=10}For $data{$location}{swlocation}, as of $ago ago:\n$data",
print "\${font :size=10}For $data{$location}{swlocation}, ", { justify => 'left', fill => 1, right => 60 });
"as of $ago ago:\n$data\${color}\$hr\n"; my $numLines = $conkyOut =~ tr/\n/\n/;
print $conkyOut;
$output .= "For $data{$location}{swlocation}, as of $ago ago: $data\n"; $output .= "For $data{$location}{swlocation}, as of $ago ago: $data\n";
$record .= "For $data{$location}{swlocation}: $data"; $record .= "For $data{$location}{swlocation}: $data";
$vpos += (20 * $TEXT_LINE_OFFSET_VPOS_AMOUNT) $vpos += 10 * $TEXT_LINE_OFFSET_VPOS_AMOUNT * ($numLines);
+ (10 * $TEXT_LINE_OFFSET_VPOS_AMOUNT * ($numLines + 2)); }
if ($output ne "") {
print "\${color}\$hr\n";
$vpos += 10 * $TEXT_LINE_OFFSET_VPOS_AMOUNT;
} }
$record =~ s/\n/ /gm; $record =~ s/\n/ /gm;
if (keys(%data) > 0 and length($output) > 0) { if (keys(%data) > 0 and length($output) > 0) {
my $alreadyDone = 0; my $alreadyDone = 0;
foreach my $key (keys %$info) { foreach my $key (keys %$info) {