User:Keller999/projects/gamepageupdate: Difference between revisions

m
no edit summary
(Game Page Update project, lots of minor edits from me on the way)
 
mNo edit summary
Line 6: Line 6:
* Update pages to conform to the standard game page -- Problems, Configuration, Version Compatibility, Testing, Gameplay Videos
* Update pages to conform to the standard game page -- Problems, Configuration, Version Compatibility, Testing, Gameplay Videos
* Remove existing non-used config variables if they are present in the page
* Remove existing non-used config variables if they are present in the page
===Scripts===
Takes a Wikipedia Infobox and first paragraph and turns it into an acceptable format for our wiki.  Paste in the info from Wikipedia, then enter -1 to show that you're done.  Still requires a little bit of manual eye-balling for other system's information, but greatly speeds the whole process.  Also removes platforms that aren't in Dolphin, removes all references, citations, and wiki brackets.
<pre>
#!/usr/bin/perl
my $line;
my @devices;
my $imageLine;
if (($#ARGV + 1) eq 1) {
        $imageLine = $ARGV[0];
$imageLine =~ s/\ {2,}/\ /g;
}
system('clear');
while ($line ne "-1") {
        $line = <STDIN>;
        chomp($line);
        if (($line ne "-1") and ($line ne "")) {
                push (@devices,$line);
        }
}
$foundInfobox = 0;
my $categories;
system('clear');
foreach (@devices) {
$newLine = $_;
$platforms  = "\|platforms \= ";
$platformAltered = 0;
$skip = 0;
if ($newLine =~ /^\{\{\ *Infobox.*/gi) {
$newLine =~ s/^\{\{\ *Infobox.*/\{\{Infobox\ VG/gi;
$foundInfobox = 1;
}
#Platforms
if ($newLine =~ /\|\ *platforms/gi) {
#Wii
if ($newLine =~ /.*Wii.*/i) {
$platforms .= '[[Wii]] ';
$categories .= "[[Category:Wii games]]\n";
$platformAltered = 1;
}
#GameCube
                if ($newLine =~ /GameCube/i) {
$platforms .= '[[GameCube]] ';
$categories .= "[[Category:GameCube games]]\n";
$platformAltered = 1;
      }
#WiiWare
                if ($newLine =~ /WiiWare/i) {
              $platforms .= '[[WiiWare]] ';
$categories .= "[[Category:WiiWare games]]\n";
$platformAltered = 1;
      }
#TriForce
                if ($newLine =~ /TriForce/i) {
              $platforms .= '[[Triforce]] ';
$categories .= "[[Category:Triforce games]]\n";
$platformAltered = 1;
        }
}
#Purge un-used parameters
if ($newLine =~ /^\|/) {
if ($newLine =~ /\|\ *(title|developer|publisher|distributor|director|producer|designer|programmer|artist|composer|license|series|engine|resolution|released|genre|mode|ratings|input|size|fps|dspcode|dtkadpcm|channeltype|image|mode|modes)\ *=\ * .+/gi) {
$skip = 0;
} else {
$skip = 1;
}
}
#Replace image name, if necessary
if (($newLine =~ /^\|\ *image/) and ($imageLine ne "")) {
$skip = 1;
print "$imageLine\n";
}
#Un-wiki-fy everything
        if (($newLine =~ /^\|\ *image/ eq "") and ($platformAltered eq 0)) {
$newLine =~ s/\<ref.+?\/.{0,3}\>//gi; # remove citations references
$newLine =~ s/\{\{cite.*?\}\}//gi; # remove references
$newLine =~ s/\[\[(([.]|[^\|])+?)\]\]/$1/g; # un-wiki-fy wiki links in the format [[link]]
                $newLine =~ s/\[\[.+?\|(.+?)\]\]/$1/g; # un-wiki-fy wiki links in the format [[link|name]]
        }
#Set genre categories
if ($newLine =~ /^\|\ *genre/ ne "") {
$genreLine = $newLine;
$genreLine =~ s/^\|\ *genre\ *\=\ *//i;
@genres = split (/\,/,$genreLine);
foreach (@genres) {
$line = $_;
$line =~ s/^\ *//;
$line =~ s/\ +$//;
$categories .= "\[\[Category:" . $line . " games\]\]\n";
}
}
#Set mode categories
if ($foundInfobox eq 1) {
if (($platformAltered eq 0) and ($skip eq 0)) {
print $newLine . "\n";
} elsif ($platformAltered eq 1) {
print $platforms . "\n";
}
}
}
print "\n\n\n";
print $categories;
print "\n\n\n";
</pre>
Script that takes existing [[Template:test entry]] entries and converts them to [[Template:testing/entry]] entries.
<pre>
#!/usr/bin/perl
my $line;
my @input;
my @result;
system('clear');
while ($line ne "-1") {
        $line = <STDIN>;
        chomp($line);
        if (($line ne "-1") and ($line ne "")) {
                push (@input,$line);
        }
}
push (@result, "\=\= Testing \=\=");
push (@result, "\{\{testing\/start\}\}");
push (@result, "\<!--Use this template for test entries\: \{\{testing\/entry\|revision=\|OS=\|CPU=\|GPU=\|result=\|tester=\[\[User:YourUserName\|YourUserName\]\]-->");
system('clear');
foreach (@input) {
$newLine = $_;
$newLine =~ s/^\{\{test entry/\{\{testing\/entry/gi;
if ($newLine =~ /^\{\{testing\/entry/gi) {
push (@result,  $newLine);
}
}
push (@result, "\{\{testing\/end\}\}");
foreach (@result) {
print $_ . "\n";
}
</pre>
I might need to combine all of this into one mega script that you can drop an existing page into and have it spit out a properly-formatted one...
1,411

edits