Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tidied bin/xml.

Added html_entity filter to src/groups/group.html.
  • Loading branch information...
commit 93f798f50cf67b1e5e878b02df1e770158cb279d 1 parent e0d0b77
dave authored
Showing with 40 additions and 40 deletions.
  1. +39 −39 perlmongers/bin/xml
  2. +1 −1  perlmongers/src/groups/group.html
View
78 perlmongers/bin/xml
@@ -6,28 +6,30 @@ use Image::WorldMap;
use Template;
use XML::LibXML;
+my $src_file = shift || './perl_mongers.xml';
+
my %ids;
my %colours = (
- 'africa' => [64,255,64],
- 'asia' => [255,255,0],
- 'europe' => [128,128,255],
- 'north_america' => [255,0,0],
- 'central_america' => [0,255,0],
- 'south_america' => [255,0,255],
- 'oceania' => [0,255,255],
+ africa => [64,255,64],
+ asia => [255,255,0],
+ europe => [128,128,255],
+ north_america => [255,0,0],
+ central_america => [0,255,0],
+ south_america => [255,0,255],
+ oceania => [0,255,255],
);
$| = 1;
my $tt = Template->new({
- POST_CHOMP => 1,
- PRE_CHOMP => 1,
- TRIM => 1,
- EVAL_PERL => 1 ,
- INCLUDE_PATH => ['.', 'lib', 'src'],
- PROCESS => 'layout',
-});
+ POST_CHOMP => 1,
+ PRE_CHOMP => 1,
+ TRIM => 1,
+ EVAL_PERL => 1 ,
+ INCLUDE_PATH => ['.', 'lib', 'src'],
+ PROCESS => 'layout',
+ });
my %allgroups;
@@ -38,7 +40,7 @@ mkdir "www/groups/graphics";
my $worldmap = Image::WorldMap->new("titchy.png");
my $xml = XML::LibXML->new();
-my $doc = $xml->parse_file("./perl_mongers.xml");
+my $doc = $xml->parse_file($src_file);
foreach my $g ($doc->findnodes("//group")) {
my $id = $g->getAttribute("id");
my $status = $g->getAttribute("status") || 'not-specified-in-xml-file';
@@ -77,8 +79,7 @@ foreach my $g ($doc->findnodes("//group")) {
die "$name has no country\n" unless $country;
# joined up city, state, region, country, continent
- my $location = join ", ",
- grep { $_ }
+ my $location = join ', ', grep { $_ }
($city, $state, $region, $country, $continent);
if ($longitude && $latitude) {
@@ -90,7 +91,7 @@ foreach my $g ($doc->findnodes("//group")) {
$worldmap->add($longitude, $latitude, 'group', $colour);
# have we drawn the single-country map already?
- if (!-f "www/groups/graphics/$id.png") {
+ unless (-f "www/groups/graphics/$id.png") {
my $map = Image::WorldMap->new("titchy.png");
$map->add($longitude, $latitude, 'group', $colour);
$map->draw("foo.png");
@@ -98,29 +99,29 @@ foreach my $g ($doc->findnodes("//group")) {
$image = "graphics/$id.png";
}
} else {
- print "Group $name in $location missing location\n";
+ warn "Group $name in $location missing location\n";
}
$tsaremail =~ s/@/ at /g;
my $group = {
- continent => $continent,
- id => $id,
- image => $image,
- latitude => $latitude,
- location => $location,
- longitude => $longitude,
- name => $name,
- tsar => $tsar,
- tsaremail => $tsaremail,
- status => $status,
- web => $web,
- };
+ continent => $continent,
+ id => $id,
+ image => $image,
+ latitude => $latitude,
+ location => $location,
+ longitude => $longitude,
+ name => $name,
+ tsar => $tsar,
+ tsaremail => $tsaremail,
+ status => $status,
+ web => $web,
+ };
$allgroups{$name} = $group;
push @{$groups{$continent}->{$country}}, $group;
- if (!-f "www/groups/$id.html") {
+ unless (-f "www/groups/$id.html") {
$tt->process('src/groups/group.html', $group, "www/groups/$id.html")
|| die $tt->error();
}
@@ -129,10 +130,9 @@ foreach my $g ($doc->findnodes("//group")) {
copy("./perl_mongers.xml", "www/groups/perl_mongers.xml");
copy("./perl_mongers.dtd", "www/groups/perl_mongers.dtd");
-my @continents = (
- "Africa", "Asia", "Europe", "North America", "Central America",
- "South America", "Oceania", "Non-geographical",
-);
+my @continents = ('Africa', 'Asia', 'Europe', 'North America',
+ 'Central America', 'South America', 'Oceania',
+ 'Non-geographical');
foreach my $continent (@continents) {
my $name = lc $continent;
@@ -159,9 +159,9 @@ foreach my $continent (@continents) {
$map->draw("foo.png");
system("pngtopnm foo.png | ppmquant 127 2>/dev/null | pnmtopng -compression 9 > www/groups/graphics/$name.png");
my $conf = {
- groups => $groups,
- continent => $continent,
- };
+ groups => $groups,
+ continent => $continent,
+ };
$conf->{image} = "graphics/$name.png" unless $name eq 'non_geographical';
$tt->process('src/groups/continent.html', $conf, $file)
View
2  perlmongers/src/groups/group.html
@@ -10,7 +10,7 @@
<b>[% name | html_entity %]</b> ([% location | html_entity %])<br>
[% END %]
-[% tsar %] &lt;[% tsaremail %]&gt;<br>
+[% tsar | html_entity %] &lt;[% tsaremail %]&gt;<br>
Please sign in to comment.
Something went wrong with that request. Please try again.