Refactor modality

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

@ -277,38 +277,21 @@ 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 wrap_in_html($grid);
close $fh;
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: $!"; open (my $fh, "> $outfile") or croak "Couldn't open $outfile for writing: $!";
say $fh $grid->render; say $fh ($html_document ? wrap_in_html($grid) : $grid->render);
close $fh; close $fh;
if($regiondir) if($regiondir)
{ {
chdir $regiondir || croak "Couldn't chdir to $regiondir: $!"; chdir $regiondir || croak "Couldn't chdir to $regiondir: $!";
my $extension = $html_document ? 'html' : 'svg';
while(my ($region, $region_grid) = each %region_grids) while(my ($region, $region_grid) = each %region_grids)
{ {
open (my $region_fh, "> $region.svg") or croak "Couldn't open $region.svg for writing: $!"; open (my $region_fh, "> $region.$extension")
say $region_fh $region_grid->render; or croak "Couldn't open $region.extension for writing: $!";
say $region_fh ($html_document ? wrap_in_html($region_grid) : $region_grid->render);
close $region_fh; close $region_fh;
} }
} }
}
sub wrap_in_html($grid) sub wrap_in_html($grid)
{ {
@ -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