|
|
|
@ -134,52 +134,7 @@ foreach my $page (values %{$subregion_query_results->{query}{pages}}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
say STDERR "Getting Background image pages"; |
|
|
|
|
my $background_query_results = $mw->api({ action => 'query', |
|
|
|
|
prop => 'imageinfo', |
|
|
|
|
titles => join('|', keys %background_pages), |
|
|
|
|
iiprop => 'url' |
|
|
|
|
}) || carp $mw->{error}->{code} . ': ' . $mw->{error}->{details}; |
|
|
|
|
|
|
|
|
|
foreach my $page (values %{$background_query_results->{query}{pages}}) |
|
|
|
|
{ |
|
|
|
|
if($page->{imageinfo}) |
|
|
|
|
{ |
|
|
|
|
say STDERR "Processing image: $page->{title}"; |
|
|
|
|
foreach my $region (@{$background_pages{$page->{title}}}) |
|
|
|
|
{ |
|
|
|
|
$region->{defaults}{image} = $page->{imageinfo}[0]{url}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
say STDERR "Getting Tile pages"; |
|
|
|
|
my $tile_query_results = $mw->api |
|
|
|
|
( { |
|
|
|
|
action => 'query', |
|
|
|
|
titles => join('|', @tile_pages), |
|
|
|
|
prop => 'revisions', |
|
|
|
|
rvprop => 'content', |
|
|
|
|
} ) || croak $mw->{error}->{code} . ': ' . $mw->{error}->{details}; |
|
|
|
|
|
|
|
|
|
foreach my $page (values %{$tile_query_results->{query}{pages}}) |
|
|
|
|
{ |
|
|
|
|
my $content = $page->{revisions}[0]{'*'}; |
|
|
|
|
my ($region_name) = $page->{title} =~ /(.*)\/Tiles/; |
|
|
|
|
say STDERR "Processing tiles for: $region_name"; |
|
|
|
|
my $region = $grid->{regions}{$region_name}; |
|
|
|
|
foreach my $coords (split /;/, $content) |
|
|
|
|
{ |
|
|
|
|
do { carp "Skipping bad spec: $coords"; next; } |
|
|
|
|
unless $coords =~ $coords_regex; |
|
|
|
|
$region->make_tile_at($1,$2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my @location_continuations; |
|
|
|
|
say STDERR "Getting Location pages"; |
|
|
|
|
my $location_query_results = $mw->api |
|
|
|
|
( { |
|
|
|
@ -200,10 +155,19 @@ foreach my $page (values %{$location_query_results->{query}{pages}}) |
|
|
|
|
say STDERR "Processing location: $page->{title}"; |
|
|
|
|
my $location = $grid->make_region($page->{title}); |
|
|
|
|
$location->{defaults}{colour} = $parsed_template->{named_params}{colour}; |
|
|
|
|
|
|
|
|
|
my $location_with_context; |
|
|
|
|
push @{$background_pages{"File:$parsed_template->{named_params}{background}"}}, $location; |
|
|
|
|
push @location_continuations, sub |
|
|
|
|
{ |
|
|
|
|
return unless $parsed_template->{positional_params}[0] =~ $coords_regex; |
|
|
|
|
my ($nw, $sw) = ($1, $2); |
|
|
|
|
$location->make_tile_at($nw, $sw); |
|
|
|
|
my $region_name = $parsed_template->{positional_params}[1]; |
|
|
|
|
$region_grids{$region_name}->add_region($location); |
|
|
|
|
if($regiondir) |
|
|
|
|
{ |
|
|
|
|
my $region_name = $parsed_template->{positional_params}[1]; |
|
|
|
|
$region_grids{$region_name}->add_region($location); |
|
|
|
|
|
|
|
|
|
$region_grids{$location->{name}} = HexGrid->new |
|
|
|
|
( |
|
|
|
|
defaults => |
|
|
|
@ -214,37 +178,69 @@ foreach my $page (values %{$location_query_results->{query}{pages}}) |
|
|
|
|
height => 300, |
|
|
|
|
width => 300 |
|
|
|
|
); |
|
|
|
|
$location_with_context = $region_grids{$location->{name}}->make_region($location->{name}); |
|
|
|
|
|
|
|
|
|
$location_with_context->{defaults}{colour} = $location->{defaults}{colour}; |
|
|
|
|
my $location_with_context = $region_grids{$location->{name}}->make_region($location->{name}); |
|
|
|
|
$location_with_context->add_tile($grid->get_tile_at($nw, $sw)); |
|
|
|
|
foreach my $coords (split /;/, $parsed_template->{named_params}{context_tiles}) |
|
|
|
|
{ |
|
|
|
|
do { carp "Skipping bad spec: $coords"; next; } unless $coords =~ $coords_regex; |
|
|
|
|
$location_with_context->add_tile($grid->get_tile_at($1, $2)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($parsed_template->{positional_params}[0] =~ $coords_regex) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
say STDERR "Getting Background image pages"; |
|
|
|
|
my $background_query_results = $mw->api({ action => 'query', |
|
|
|
|
prop => 'imageinfo', |
|
|
|
|
titles => join('|', keys %background_pages), |
|
|
|
|
iiprop => 'url' |
|
|
|
|
}) || carp $mw->{error}->{code} . ': ' . $mw->{error}->{details}; |
|
|
|
|
|
|
|
|
|
foreach my $page (values %{$background_query_results->{query}{pages}}) |
|
|
|
|
{ |
|
|
|
|
$location->make_tile_at($1,$2); |
|
|
|
|
if($regiondir) |
|
|
|
|
if($page->{imageinfo}) |
|
|
|
|
{ |
|
|
|
|
$location_with_context->make_tile_at($1,$2); |
|
|
|
|
foreach my $coords (split /;/, $parsed_template->{named_params}{context_tiles}) |
|
|
|
|
say STDERR "Processing image: $page->{title}"; |
|
|
|
|
foreach my $region (@{$background_pages{$page->{title}}}) |
|
|
|
|
{ |
|
|
|
|
do { carp "Skipping bad spec: $coords"; next; } |
|
|
|
|
unless $coords =~ $coords_regex; |
|
|
|
|
$location_with_context->add_tile($grid->get_tile_at($1, $2)); |
|
|
|
|
$region->{defaults}{image} = $page->{imageinfo}[0]{url}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($regiondir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
say STDERR "Getting Tile pages"; |
|
|
|
|
my $tile_query_results = $mw->api |
|
|
|
|
( { |
|
|
|
|
action => 'query', |
|
|
|
|
titles => join('|', @tile_pages), |
|
|
|
|
prop => 'revisions', |
|
|
|
|
rvprop => 'content', |
|
|
|
|
} ) || croak $mw->{error}->{code} . ': ' . $mw->{error}->{details}; |
|
|
|
|
|
|
|
|
|
foreach my $page (values %{$tile_query_results->{query}{pages}}) |
|
|
|
|
{ |
|
|
|
|
my $region_name = $parsed_template->{positional_params}[1]; |
|
|
|
|
$region_grids{$region_name}->add_region($location); |
|
|
|
|
my $content = $page->{revisions}[0]{'*'}; |
|
|
|
|
my ($region_name) = $page->{title} =~ /(.*)\/Tiles/; |
|
|
|
|
say STDERR "Processing tiles for: $region_name"; |
|
|
|
|
my $region = $grid->{regions}{$region_name}; |
|
|
|
|
foreach my $coords (split /;/, $content) |
|
|
|
|
{ |
|
|
|
|
do { carp "Skipping bad spec: $coords"; next; } unless $coords =~ $coords_regex; |
|
|
|
|
$region->make_tile_at($1,$2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
push @{$background_pages{"File:$parsed_template->{named_params}{background}"}}, $location; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
say STDERR "Continuing Location processing"; |
|
|
|
|
$_->() for @location_continuations; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
say STDERR "Getting Site pages"; |
|
|
|
|
my $site_query_results = $mw->api |
|
|
|
|
( { |
|
|
|
|