|
|
|
@ -134,6 +134,63 @@ foreach my $page (values %{$subregion_query_results->{query}{pages}}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my @location_continuations; |
|
|
|
|
say STDERR "Getting Location pages"; |
|
|
|
|
my $location_query_results = $mw->api |
|
|
|
|
( { |
|
|
|
|
action => 'query', |
|
|
|
|
generator => 'categorymembers', |
|
|
|
|
gcmtitle => 'Category:Locations', |
|
|
|
|
gcmlimit => 'max', |
|
|
|
|
prop => 'info|revisions', |
|
|
|
|
rvprop => 'content', |
|
|
|
|
inprop => 'url', |
|
|
|
|
} ) || croak $mw->{error}->{code} . ': ' . $mw->{error}->{details}; |
|
|
|
|
|
|
|
|
|
foreach my $page (values %{$location_query_results->{query}{pages}}) |
|
|
|
|
{ |
|
|
|
|
next if $page->{title} =~ /^Category:/; |
|
|
|
|
my $parsed_template = MWTemplate::Parse($page->{revisions}[0]{'*'}, $location_template_name); |
|
|
|
|
next unless $parsed_template; |
|
|
|
|
say STDERR "Processing location: $page->{title}"; |
|
|
|
|
my $location = $grid->make_region($page->{title}); |
|
|
|
|
$location->{defaults}{colour} = $parsed_template->{named_params}{colour}; |
|
|
|
|
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 => |
|
|
|
|
{ |
|
|
|
|
style => { 'stroke-width' => $border_width, stroke => $border_colour }, |
|
|
|
|
show_coords => $show_coords |
|
|
|
|
}, |
|
|
|
|
height => 300, |
|
|
|
|
width => 300 |
|
|
|
|
); |
|
|
|
|
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)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
say STDERR "Getting Background image pages"; |
|
|
|
|
my $background_query_results = $mw->api({ action => 'query', |
|
|
|
|
prop => 'imageinfo', |
|
|
|
@ -172,76 +229,15 @@ foreach my $page (values %{$tile_query_results->{query}{pages}}) |
|
|
|
|
my $region = $grid->{regions}{$region_name}; |
|
|
|
|
foreach my $coords (split /;/, $content) |
|
|
|
|
{ |
|
|
|
|
do { carp "Skipping bad spec: $coords"; next; } |
|
|
|
|
unless $coords =~ $coords_regex; |
|
|
|
|
do { carp "Skipping bad spec: $coords"; next; } unless $coords =~ $coords_regex; |
|
|
|
|
$region->make_tile_at($1,$2); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
say STDERR "Getting Location pages"; |
|
|
|
|
my $location_query_results = $mw->api |
|
|
|
|
( { |
|
|
|
|
action => 'query', |
|
|
|
|
generator => 'categorymembers', |
|
|
|
|
gcmtitle => 'Category:Locations', |
|
|
|
|
gcmlimit => 'max', |
|
|
|
|
prop => 'info|revisions', |
|
|
|
|
rvprop => 'content', |
|
|
|
|
inprop => 'url', |
|
|
|
|
} ) || croak $mw->{error}->{code} . ': ' . $mw->{error}->{details}; |
|
|
|
|
|
|
|
|
|
foreach my $page (values %{$location_query_results->{query}{pages}}) |
|
|
|
|
{ |
|
|
|
|
next if $page->{title} =~ /^Category:/; |
|
|
|
|
my $parsed_template = MWTemplate::Parse($page->{revisions}[0]{'*'}, $location_template_name); |
|
|
|
|
next unless $parsed_template; |
|
|
|
|
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; |
|
|
|
|
if($regiondir) |
|
|
|
|
{ |
|
|
|
|
$region_grids{$location->{name}} = HexGrid->new |
|
|
|
|
( |
|
|
|
|
defaults => |
|
|
|
|
{ |
|
|
|
|
style => { 'stroke-width' => $border_width, stroke => $border_colour }, |
|
|
|
|
show_coords => $show_coords |
|
|
|
|
}, |
|
|
|
|
height => 300, |
|
|
|
|
width => 300 |
|
|
|
|
); |
|
|
|
|
$location_with_context = $region_grids{$location->{name}}->make_region($location->{name}); |
|
|
|
|
|
|
|
|
|
$location_with_context->{defaults}{colour} = $location->{defaults}{colour}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($parsed_template->{positional_params}[0] =~ $coords_regex) |
|
|
|
|
{ |
|
|
|
|
$location->make_tile_at($1,$2); |
|
|
|
|
if($regiondir) |
|
|
|
|
{ |
|
|
|
|
$location_with_context->make_tile_at($1,$2); |
|
|
|
|
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($regiondir) |
|
|
|
|
{ |
|
|
|
|
my $region_name = $parsed_template->{positional_params}[1]; |
|
|
|
|
$region_grids{$region_name}->add_region($location); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
push @{$background_pages{"File:$parsed_template->{named_params}{background}"}}, $location; |
|
|
|
|
} |
|
|
|
|
say STDERR "Continuing Location processing"; |
|
|
|
|
$_->() for @location_continuations; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|