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";
11 my $html = "Freeside:3:Documentation:Developer";
15 map "$html/$_", qw( bin FS
16 FS/cdr FS/cust_main FS/cust_pkg FS/detail_format
17 FS/part_event FS/part_event/Condition FS/part_event/Action
18 FS/part_export FS/part_pkg FS/pay_batch
19 FS/ClientAPI FS/Cron FS/Misc FS/Report FS/Report/Table
24 -d $dir or mkdir $dir;
29 die "Can't find $site_perl" unless -d $site_perl;
30 #die "Can't find $catman" unless -d $catman;
31 -d $html or mkdir $html;
35 #make some useless links
37 glob("$site_perl/bin/freeside-*"),
39 next if $file =~ /\.pod$/;
40 #symlink $file, "$file.pod"; # or die "link $file to $file.pod: $!";
41 #system("cp $file $file.pod");
42 -e "$file.pod" or system("cp $file $file.pod");
45 #just for filename_to_pagename for now
46 use WWW::Mediawiki::Client;
47 my $mvs = WWW::Mediawiki::Client->new(
48 'host' => 'www.freeside.biz',
49 'protocol' => 'https',
50 'wiki_path' => 'mediawiki/index.php',
51 'username' => $mw_username,
52 'password' => $mw_password,
53 #'commit_message' => 'import from POD'
59 my $c = MediaWiki->new;
60 # $is_ok = $c->setup("config.ini");
62 'bot' => { 'user' => $mw_username, 'pass' => $mw_password },
64 'host' => 'www.freeside.biz',
65 'path' => 'mediawiki',
69 }) or die "Mediawiki->setup failed";
76 glob("$site_perl/*.pm"),
77 glob("$site_perl/*/*.pm"),
78 glob("$site_perl/*/*/*.pm"),
79 glob("$site_perl/*/*/*/*.pm"),
80 glob("$site_perl/bin/*.pod"),
81 glob("./fs_selfservice/FS-SelfService/*.pm"),
82 glob("./fs_selfservice/FS-SelfService/*/*.pm"),
87 foreach my $file (@files) {
88 next if $file =~ /(^|\/)blib\//;
89 next if $file =~ /(^|\/)CVS\//;
90 #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file";
92 if ( $file =~ /fs_\w+\/FS\-\w+\/(.*)\.pm$/ ) {
94 } elsif ( $file =~ /$site_perl\/(.*)\.(pm|pod)$/ ) {
97 die "oops file $file";
100 #exit if $count++ == 10;
102 my $htmlroot = join('/', map '..',1..(scalar($file =~ tr/\///)-2)) || '.';
104 system "pod2wiki --style mediawiki $file >$html/$name.rawwiki";
106 if ( -e "$html/$name.rawwiki" ) {
107 print "processing $name\n";
109 print "skipping $name\n";
113 # $mvs->do_update("$html/$name.wiki");
117 open(RAW, "<$html/$name.rawwiki") or die $!;
119 s/\[\[([^#p][^\]]*)\]\]/"[[$html\/". w_e($1). "|$1]]"/ge;
124 my $pagename = $mvs->filename_to_pagename("$html/$name.wiki");
125 #print " uploading to $pagename\n";
127 $c->text( $pagename, $text );
135 $s =~ s/^freeside-/bin\/freeside-/g;
140 ## system "pod2text $file >$catman/$name.txt";
142 # system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:.:./bin --norecurse --htmlroot=$htmlroot $file >$html/$name.html";
143 # #system "pod2html --podroot=$site_perl --htmlroot=$htmlroot $file >$html/$name.html";
144 ## system "pod2html $file >$html/$name.html";
147 #remove the useless links
148 unlink glob("$site_perl/bin/*.pod");