User:Matt/makeXML

From wiki.occupyboston.org
Revision as of 16:46, 19 October 2011 by Matt (talk | contribs) (Created page with "<pre>#!/usr/bin/perl @files = <*>; $doc = <<EOF <mediawiki xml:lang="en" xmlns="http://www.mediawiki.org/xml/export-0.5/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xs...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#!/usr/bin/perl
@files = <*>;
$doc = <<EOF
<mediawiki xml:lang="en" xmlns="http://www.mediawiki.org/xml/export-0.5/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.5/ http://www.mediawiki.org/xml/export-0.5.xsd" version="0.5" >
EOF
;

foreach $file (@files)
{
	$doc.=makeXML($file);
}
$doc.="</mediawiki>\n";
print $doc;
sub makeXML()
{
	$fname = shift @_;
	
$template=<<EOF
<page>
      <title>User:Matt/@@title@@</title>
      <revision>
        <timestamp>2011-10-19T01:01:00Z</timestamp>
      <contributor>
        <username>Matt</username>
        <id>3</id>
      </contributor>

        <text xml:space="preserve">@@page@@</text>
      </revision>
</page>
EOF
;
$/=undef;
open FILE, "$fname" or die;
$page=<FILE>;
$template=~s/@@title@@/$fname/;
$page=~s/&/&/g;
$page=~s/\</</g;
$page=~s/\>/>/g;

$page.="\n-------\nBased on: [[http://occupyboston.wikispaces.com/$fname $fname at wikispaces]]\n";
#$page=~s/\<br\>/\<br \/\>/g;
$template=~s/@@page@@/$page/;
return $template;
};