5 my $mw_username = 'ivan';
6 chomp( my $mw_password = `cat .mw-password` );
8 my $site_perl = "./FS";
9 #my $html = "Freeside:1.7:Documentation:Developer";
10 my $html = "Freeside:1.9:Documentation:Developer";
14 map "$html/$_", qw( bin FS FS/UI FS/part_export FS/part_pkg
15 FS/part_event FS/part_event/Condition FS/part_event/Action
16 FS/ClientAPI FS/Cron FS/Misc FS/Report FS/Report/Table
21 -d $dir or mkdir $dir;
26 die "Can't find $site_perl" unless -d $site_perl;
27 #die "Can't find $catman" unless -d $catman;
28 -d $html or mkdir $html;
32 #make some useless links
34 glob("$site_perl/bin/freeside-*"),
36 next if $file =~ /\.pod$/;
37 #symlink $file, "$file.pod"; # or die "link $file to $file.pod: $!";
38 #system("cp $file $file.pod");
39 -e "$file.pod" or system("cp $file $file.pod");
42 #just for filename_to_pagename for now
43 use WWW::Mediawiki::Client;
44 my $mvs = WWW::Mediawiki::Client->new(
45 'host' => 'www.freeside.biz',
46 'wiki_path' => 'mediawiki/index.php',
47 'username' => $mw_username,
48 'password' => $mw_password,
49 #'commit_message' => 'import from POD'
55 my $c = MediaWiki->new;
56 # $is_ok = $c->setup("config.ini");
58 'bot' => { 'user' => $mw_username, 'pass' => $mw_password },
60 'host' => 'www.freeside.biz',
61 'path' => 'mediawiki',
65 }) or die "Mediawiki->setup failed";
72 glob("$site_perl/*.pm"),
73 glob("$site_perl/*/*.pm"),
74 glob("$site_perl/*/*/*.pm"),
75 glob("$site_perl/*/*/*/*.pm"),
76 glob("$site_perl/bin/*.pod"),
77 glob("./fs_selfservice/FS-SelfService/*.pm"),
78 glob("./fs_selfservice/FS-SelfService/*/*.pm"),
83 foreach my $file (@files) {
84 next if $file =~ /(^|\/)blib\//;
85 next if $file =~ /(^|\/)CVS\//;
86 #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file";
88 if ( $file =~ /fs_\w+\/FS\-\w+\/(.*)\.pm$/ ) {
90 } elsif ( $file =~ /$site_perl\/(.*)\.(pm|pod)$/ ) {
93 die "oops file $file";
96 #exit if $count++ == 10;
98 my $htmlroot = join('/', map '..',1..(scalar($file =~ tr/\///)-2)) || '.';
100 system "pod2wiki --style mediawiki $file >$html/$name.rawwiki";
102 if ( -e "$html/$name.rawwiki" ) {
103 print "processing $name\n";
105 print "skipping $name\n";
109 # $mvs->do_update("$html/$name.wiki");
113 open(RAW, "<$html/$name.rawwiki") or die $!;
115 s/\[\[([^#p][^\]]*)\]\]/"[[$html\/". w_e($1). "|$1]]"/ge;
120 my $pagename = $mvs->filename_to_pagename("$html/$name.wiki");
121 #print " uploading to $pagename\n";
123 $c->text( $pagename, $text );
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");