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";
13 map "$html/$_", qw( bin FS FS/UI FS/part_export FS/part_pkg
14 FS/ClientAPI FS/Cron FS/Misc FS/Report FS/Report/Table
19 -d $dir or mkdir $dir;
24 die "Can't find $site_perl" unless -d $site_perl;
25 #die "Can't find $catman" unless -d $catman;
26 -d $html or mkdir $html;
30 #make some useless links
32 glob("$site_perl/bin/freeside-*"),
34 next if $file =~ /\.pod$/;
35 #symlink $file, "$file.pod"; # or die "link $file to $file.pod: $!";
36 #system("cp $file $file.pod");
37 -e "$file.pod" or system("cp $file $file.pod");
40 #just for filename_to_pagename for now
41 use WWW::Mediawiki::Client;
42 my $mvs = WWW::Mediawiki::Client->new(
43 'host' => 'www.freeside.biz',
44 'wiki_path' => 'mediawiki/index.php',
45 'username' => $mw_username,
46 'password' => $mw_password,
47 #'commit_message' => 'import from POD'
53 my $c = MediaWiki->new;
54 # $is_ok = $c->setup("config.ini");
56 'bot' => { 'user' => $mw_username, 'pass' => $mw_password },
58 'host' => 'www.freeside.biz',
59 'path' => 'mediawiki',
63 }) or die "Mediawiki->setup failed";
70 glob("$site_perl/*.pm"),
71 glob("$site_perl/*/*.pm"),
72 glob("$site_perl/*/*/*.pm"),
73 glob("$site_perl/*/*/*/*.pm"),
74 glob("$site_perl/bin/*.pod"),
75 glob("./fs_selfservice/FS-SelfService/*.pm"),
76 glob("./fs_selfservice/FS-SelfService/*/*.pm"),
80 foreach my $file (@files) {
81 next if $file =~ /(^|\/)blib\//;
82 next if $file =~ /(^|\/)CVS\//;
83 #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file";
85 if ( $file =~ /fs_\w+\/FS\-\w+\/(.*)\.pm$/ ) {
87 } elsif ( $file =~ /$site_perl\/(.*)\.(pm|pod)$/ ) {
90 die "oops file $file";
93 #exit if $count++ == 10;
95 my $htmlroot = join('/', map '..',1..(scalar($file =~ tr/\///)-2)) || '.';
97 system "pod2wiki --style mediawiki $file >$html/$name.rawwiki";
99 if ( -e "$html/$name.rawwiki" ) {
100 print "processing $name\n";
102 print "skipping $name\n";
106 # $mvs->do_update("$html/$name.wiki");
110 open(RAW, "<$html/$name.rawwiki") or die $!;
112 s/\[\[([^#p][^\]]*)\]\]/"[[$html\/". w_e($1). "|$1]]"/ge;
117 my $pagename = $mvs->filename_to_pagename("$html/$name.wiki");
118 #print " uploading to $pagename\n";
120 $c->text( $pagename, $text );
128 $s =~ s/^freeside-/bin\/freeside-/g;
133 ## system "pod2text $file >$catman/$name.txt";
135 # system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:.:./bin --norecurse --htmlroot=$htmlroot $file >$html/$name.html";
136 # #system "pod2html --podroot=$site_perl --htmlroot=$htmlroot $file >$html/$name.html";
137 ## system "pod2html $file >$html/$name.html";
140 #remove the useless links
141 unlink glob("$site_perl/bin/*.pod");