X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=bin%2Fpod2x;h=ecb7f913b76348deb5c7e45c41c02a739902fcfe;hb=246c311ac0ca7c41c571cfbc434bafd7c5d2768c;hp=741b78460413a39d9fc094246e5703a21830468b;hpb=003b2d1320abf9ec909f9bbabe7737328fe8fcb2;p=freeside.git diff --git a/bin/pod2x b/bin/pod2x index 741b78460..ecb7f913b 100755 --- a/bin/pod2x +++ b/bin/pod2x @@ -1,25 +1,6 @@ #!/usr/bin/perl -w use strict; -use WWW::Mediawiki::Client; -#sub WWW::Mediawiki::Client::pagename_to_url { -# my ($self, $name, $action) = @_; -# WWW::Mediawiki::Client::URLConstructionException->throw( -# error => 'No action supplied.', -# ) unless $action; -# WWW::Mediawiki::Client::URLConstructionException->throw( -# error => "Page name $name ends with '.wiki'.", -# ) if $name =~ /.wiki$/; -# my $char = $self->space_substitute; -# $name =~ s/ /$char/; -# my $lang = $self->language_code; -# my $host = $self->host; -# $host =~ s/__LANG__/$lang/g; -# my $wiki_path = $self->wiki_path; -# $wiki_path =~ s/__LANG__/$lang/g; -# my $protocol = $self->protocol; -# return "$protocol://$host/$wiki_path?" . ACTION . "=$action&" . TITLE . "=$name" . '&wpRecreate=1'; -#} my $mw_username = 'ivan'; chomp( my $mw_password = `cat .mw-password` ); @@ -58,21 +39,36 @@ foreach my $file ( -e "$file.pod" or system("cp $file $file.pod"); } +#just for filename_to_pagename for now +use WWW::Mediawiki::Client; my $mvs = WWW::Mediawiki::Client->new( - 'host' => 'www.sisd.com', + 'host' => 'www.freeside.biz', 'wiki_path' => 'mediawiki/index.php', 'username' => $mw_username, 'password' => $mw_password, #'commit_message' => 'import from POD' ); +#$mvs->do_login; + +use MediaWiki; + +my $c = MediaWiki->new; +# $is_ok = $c->setup("config.ini"); +$c->setup({ + 'bot' => { 'user' => $mw_username, 'pass' => $mw_password }, + 'wiki' => { + 'host' => 'www.freeside.biz', + 'path' => 'mediawiki', + #'has_query' => 1, -$mvs->do_login; + } +}) or die "Mediawiki->setup failed"; my @files; if ( @ARGV ) { @files = @ARGV; } else { - @files = + @files = ( glob("$site_perl/*.pm"), glob("$site_perl/*/*.pm"), glob("$site_perl/*/*/*.pm"), @@ -80,7 +76,8 @@ if ( @ARGV ) { glob("$site_perl/bin/*.pod"), glob("./fs_selfservice/FS-SelfService/*.pm"), glob("./fs_selfservice/FS-SelfService/*/*.pm"), - ; + ); + } foreach my $file (@files) { @@ -109,20 +106,21 @@ foreach my $file (@files) { next; }; - $mvs->do_update("$html/$name.wiki"); +# $mvs->do_update("$html/$name.wiki"); + + my $text = ''; open(RAW, "<$html/$name.rawwiki") or die $!; - open(WIKI,">$html/$name.wiki" ) or die $!; while () { s/\[\[([^#p][^\]]*)\]\]/"[[$html\/". w_e($1). "|$1]]"/ge; - print WIKI $_; + $text .= $_; } close RAW; - close WIKI; - print " uploading to ". $mvs->filename_to_pagename("$html/$name.wiki"). "\n"; - $mvs->commit_message( 'import from POD' ); - $mvs->do_commit("$html/$name.wiki"); + my $pagename = $mvs->filename_to_pagename("$html/$name.wiki"); + #print " uploading to $pagename\n"; + + $c->text( $pagename, $text ); }