Refactor modality

main
parent 670eec71b2
commit 881bf72342
  1. 43
      wiki-tile.pl

@ -277,36 +277,19 @@ foreach my $site_page_ref (values %{$site_query_results->{query}{pages}})
if($html_document) open (my $fh, "> $outfile") or croak "Couldn't open $outfile for writing: $!";
say $fh ($html_document ? wrap_in_html($grid) : $grid->render);
close $fh;
if($regiondir)
{ {
open (my $fh, "> $outfile") or croak "Couldn't open $outfile for writing: $!"; chdir $regiondir || croak "Couldn't chdir to $regiondir: $!";
say $fh wrap_in_html($grid); my $extension = $html_document ? 'html' : 'svg';
close $fh; while(my ($region, $region_grid) = each %region_grids)
if($regiondir)
{
chdir $regiondir || croak "Couldn't chdir to $regiondir: $!";
while(my ($region, $region_grid) = each %region_grids)
{
open (my $region_fh, "> $region.html") or croak "Couldn't open $region.html for writing: $!";
say $region_fh wrap_in_html($region_grid);
close $region_fh;
}
}
}
else
{
open (my $fh, "> $outfile") or croak "Couldn't open $outfile for writing: $!";
say $fh $grid->render;
close $fh;
if($regiondir)
{ {
chdir $regiondir || croak "Couldn't chdir to $regiondir: $!"; open (my $region_fh, "> $region.$extension")
while(my ($region, $region_grid) = each %region_grids) or croak "Couldn't open $region.extension for writing: $!";
{ say $region_fh ($html_document ? wrap_in_html($region_grid) : $region_grid->render);
open (my $region_fh, "> $region.svg") or croak "Couldn't open $region.svg for writing: $!"; close $region_fh;
say $region_fh $region_grid->render;
close $region_fh;
}
} }
} }
@ -323,10 +306,6 @@ sub wrap_in_html($grid)
</script> </script>
EOS EOS
$html_builder .= "\n" . $grid->render; $html_builder .= "\n" . $grid->render;
# if ($regiondir)
# {
# $html_builder .= "\n" . $_->render for values %region_grids;
# }
$html_builder .= "\n</body>\n</html>"; $html_builder .= "\n</body>\n</html>";
return $html_builder; return $html_builder;
} }

Loading…
Cancel
Save