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',
63 }) or die "Mediawiki->setup failed";
65 #Also, the 'wiki' section may specify the 'ssl' key (boolean 0/1) if the server uses an SSL connection. Section 'tmp' and key 'msgcache' specify path to the MediaWiki messages cache.
66 #Options 'has_query' and 'has_filepath' in 'wiki' section enable experimental optimized interfaces. Set has_query to 1 if there is query.php extension (this should reduce traffic usage and servers load). Set has_filepath to 1 if there is Special:Filepath page in target wiki (affects only filepath() and download() functions).
73 glob("$site_perl/*.pm"),
74 glob("$site_perl/*/*.pm"),
75 glob("$site_perl/*/*/*.pm"),
76 glob("$site_perl/*/*/*/*.pm"),
77 glob("$site_perl/bin/*.pod"),
78 glob("./fs_selfservice/FS-SelfService/*.pm"),
79 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");
114 open(RAW, "<$html/$name.rawwiki") or die $!;
116 s/\[\[([^#p][^\]]*)\]\]/"[[$html\/". w_e($1). "|$1]]"/ge;
121 my $pagename = $mvs->filename_to_pagename("$html/$name.wiki");
122 #print " uploading to $pagename\n";
124 $c->text( $pagename, $text );
132 $s =~ s/^freeside-/bin\/freeside-/g;
137 ## system "pod2text $file >$catman/$name.txt";
139 # system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:.:./bin --norecurse --htmlroot=$htmlroot $file >$html/$name.html";
140 # #system "pod2html --podroot=$site_perl --htmlroot=$htmlroot $file >$html/$name.html";
141 ## system "pod2html $file >$html/$name.html";
144 #remove the useless links
145 unlink glob("$site_perl/bin/*.pod");