X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fpod2x;h=64ccf882e7a91b09371cbf96791f06c51491b87b;hp=46ccc7743d83ad1842ac4aee25b0fc128c85dabe;hb=3f2a7b01b59902faed5767d81e2959e131bdbdfd;hpb=0ebeec96313dd7edfca340f01f8fbbbac1f4aa1d diff --git a/bin/pod2x b/bin/pod2x index 46ccc7743..64ccf882e 100755 --- a/bin/pod2x +++ b/bin/pod2x @@ -1,19 +1,34 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w -#use Pod::Text; -#$Pod::Text::termcap=1; +use strict; + +my $mw_username = 'ivan'; +chomp( my $mw_password = `cat .mw-password` ); my $site_perl = "./FS"; -#my $catman = "./catman"; -#my $catman = "./htdocs/docs/man"; -#my $html = "./htdocs/docs/man"; -my $html = "./httemplate/docs/man"; +my $html = "Freeside:5:Documentation:Developer"; + +foreach my $dir ( + $html, + map "$html/$_", qw( bin FS + FS/cdr FS/cust_main FS/cust_pkg FS/detail_format + FS/part_event FS/part_event/Condition FS/part_event/Action + FS/part_export FS/part_pkg FS/pay_batch + FS/ClientAPI FS/Cron FS/Misc FS/Report FS/Report/Table + FS/TicketSystem FS/UI + FS/SelfService + ) +) { + -d $dir or mkdir $dir; +} $|=1; die "Can't find $site_perl" unless -d $site_perl; #die "Can't find $catman" unless -d $catman; -die "Can't find $html" unless -d $html; +-d $html or mkdir $html; + +my $count = 0; #make some useless links foreach my $file ( @@ -21,19 +36,55 @@ foreach my $file ( ) { next if $file =~ /\.pod$/; #symlink $file, "$file.pod"; # or die "link $file to $file.pod: $!"; - system("cp $file $file.pod"); + #system("cp $file $file.pod"); + -e "$file.pod" or system("cp $file $file.pod"); } -foreach my $file ( - glob("$site_perl/*.pm"), - glob("$site_perl/*/*.pm"), - glob("$site_perl/*/*/*.pm"), - glob("$site_perl/bin/*.pod"), - glob("./fs_sesmon/FS-SessionClient/*.pm"), - glob("./fs_signup/FS-SignupClient/*.pm"), - glob("./fs_selfadmin/FS-MailAdminServer/*.pm"), -) { +#just for filename_to_pagename for now +use WWW::Mediawiki::Client; +my $mvs = WWW::Mediawiki::Client->new( + 'host' => 'www.freeside.biz', + 'protocol' => 'https', + 'wiki_path' => 'mediawiki/index.php', + 'username' => $mw_username, + 'password' => $mw_password, + #'commit_message' => 'import from POD' + ); +#$mvs->do_login; + +use MediaWiki; + +my $c = MediaWiki->new; +# $is_ok = $c->setup("config.ini"); +$c->setup({ + 'bot' => { 'user' => $mw_username, 'pass' => $mw_password }, + 'wiki' => { + 'host' => 'www.freeside.biz', + 'path' => 'mediawiki', + #'has_query' => 1, + + } +}) or die "Mediawiki->setup failed"; + +my @files; +if ( @ARGV ) { + @files = @ARGV; +} else { + @files = ( + glob("$site_perl/*.pm"), + glob("$site_perl/*/*.pm"), + glob("$site_perl/*/*/*.pm"), + glob("$site_perl/*/*/*/*.pm"), + glob("$site_perl/bin/*.pod"), + glob("./fs_selfservice/FS-SelfService/*.pm"), + glob("./fs_selfservice/FS-SelfService/*/*.pm"), + ); + +} + +foreach my $file (@files) { next if $file =~ /(^|\/)blib\//; + next if $file =~ /(^|\/)CVS\//; #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file"; my $name; if ( $file =~ /fs_\w+\/FS\-\w+\/(.*)\.pm$/ ) { @@ -43,14 +94,54 @@ foreach my $file ( } else { die "oops file $file"; } - print "$name\n"; + + #exit if $count++ == 10; + my $htmlroot = join('/', map '..',1..(scalar($file =~ tr/\///)-2)) || '.'; -# system "pod2text $file >$catman/$name.txt"; - system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:.:./bin --norecurse --htmlroot=$htmlroot $file >$html/$name.html"; - #system "pod2html --podroot=$site_perl --htmlroot=$htmlroot $file >$html/$name.html"; -# system "pod2html $file >$html/$name.html"; + + system "pod2wiki --style mediawiki $file >$html/$name.rawwiki"; + + if ( -e "$html/$name.rawwiki" ) { + print "processing $name\n"; + } else { + print "skipping $name\n"; + next; + }; + +# $mvs->do_update("$html/$name.wiki"); + + + my $text = ''; + open(RAW, "<$html/$name.rawwiki") or die $!; + while () { + s/\[\[([^#p][^\]]*)\]\]/"[[$html\/". w_e($1). "|$1]]"/ge; + $text .= $_; + } + close RAW; + + my $pagename = $mvs->filename_to_pagename("$html/$name.wiki"); + #print " uploading to $pagename\n"; + + $c->text( $pagename, $text ); + } +sub w_e { + my $s = shift; + $s =~ s/_/ /g; + $s =~ s/::/\//g; + $s =~ s/^freeside-/bin\/freeside-/g; + $s; +} + + +## system "pod2text $file >$catman/$name.txt"; +## +# system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:.:./bin --norecurse --htmlroot=$htmlroot $file >$html/$name.html"; +# #system "pod2html --podroot=$site_perl --htmlroot=$htmlroot $file >$html/$name.html"; +## system "pod2html $file >$html/$name.html"; +## + #remove the useless links unlink glob("$site_perl/bin/*.pod");