4 use WWW::Mediawiki::Client;
5 #sub WWW::Mediawiki::Client::pagename_to_url {
6 # my ($self, $name, $action) = @_;
7 # WWW::Mediawiki::Client::URLConstructionException->throw(
8 # error => 'No action supplied.',
10 # WWW::Mediawiki::Client::URLConstructionException->throw(
11 # error => "Page name $name ends with '.wiki'.",
12 # ) if $name =~ /.wiki$/;
13 # my $char = $self->space_substitute;
14 # $name =~ s/ /$char/;
15 # my $lang = $self->language_code;
16 # my $host = $self->host;
17 # $host =~ s/__LANG__/$lang/g;
18 # my $wiki_path = $self->wiki_path;
19 # $wiki_path =~ s/__LANG__/$lang/g;
20 # my $protocol = $self->protocol;
21 # return "$protocol://$host/$wiki_path?" . ACTION . "=$action&" . TITLE . "=$name" . '&wpRecreate=1';
24 my $mw_username = 'ivan';
25 chomp( my $mw_password = `cat .mw-password` );
27 my $site_perl = "./FS";
28 my $html = "Freeside:1.7:Documentation:Developer";
32 map "$html/$_", qw( bin FS FS/UI FS/part_export FS/part_pkg
33 FS/ClientAPI FS/Cron FS/Misc FS/Report FS/Report/Table
38 -d $dir or mkdir $dir;
43 die "Can't find $site_perl" unless -d $site_perl;
44 #die "Can't find $catman" unless -d $catman;
45 -d $html or mkdir $html;
49 #make some useless links
51 glob("$site_perl/bin/freeside-*"),
53 next if $file =~ /\.pod$/;
54 #symlink $file, "$file.pod"; # or die "link $file to $file.pod: $!";
55 #system("cp $file $file.pod");
56 -e "$file.pod" or system("cp $file $file.pod");
59 my $mvs = WWW::Mediawiki::Client->new(
60 'host' => 'www.freeside.biz',
61 'wiki_path' => 'mediawiki/index.php',
62 'username' => $mw_username,
63 'password' => $mw_password,
64 #'commit_message' => 'import from POD'
74 glob("$site_perl/*.pm"),
75 glob("$site_perl/*/*.pm"),
76 glob("$site_perl/*/*/*.pm"),
77 glob("$site_perl/*/*/*/*.pm"),
78 glob("$site_perl/bin/*.pod"),
79 glob("./fs_selfservice/FS-SelfService/*.pm"),
80 glob("./fs_selfservice/FS-SelfService/*/*.pm"),
84 foreach my $file (@files) {
85 next if $file =~ /(^|\/)blib\//;
86 next if $file =~ /(^|\/)CVS\//;
87 #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file";
89 if ( $file =~ /fs_\w+\/FS\-\w+\/(.*)\.pm$/ ) {
91 } elsif ( $file =~ /$site_perl\/(.*)\.(pm|pod)$/ ) {
94 die "oops file $file";
97 #exit if $count++ == 10;
99 my $htmlroot = join('/', map '..',1..(scalar($file =~ tr/\///)-2)) || '.';
101 system "pod2wiki --style mediawiki $file >$html/$name.rawwiki";
103 if ( -e "$html/$name.rawwiki" ) {
104 print "processing $name\n";
106 print "skipping $name\n";
110 $mvs->do_update("$html/$name.wiki");
112 open(RAW, "<$html/$name.rawwiki") or die $!;
113 open(WIKI,">$html/$name.wiki" ) or die $!;
115 s/\[\[([^#p][^\]]*)\]\]/"[[$html\/". w_e($1). "|$1]]"/ge;
121 print " uploading to ". $mvs->filename_to_pagename("$html/$name.wiki"). "\n";
122 $mvs->commit_message( 'import from POD' );
123 $mvs->do_commit("$html/$name.wiki");
131 $s =~ s/^freeside-/bin\/freeside-/g;
136 ## system "pod2text $file >$catman/$name.txt";
138 # system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:.:./bin --norecurse --htmlroot=$htmlroot $file >$html/$name.html";
139 # #system "pod2html --podroot=$site_perl --htmlroot=$htmlroot $file >$html/$name.html";
140 ## system "pod2html $file >$html/$name.html";
143 #remove the useless links
144 unlink glob("$site_perl/bin/*.pod");