Dokuwiki-RPC-XML-Client

 view release on metacpan or  search on metacpan

lib/Dokuwiki/RPC/XML/Client.pm  view on Meta::CPAN

    use Dokuwiki::RPC::XML::Client;
    use Modern::Perl;
    use Net::Netrc;
    my $base = 'https://example.com/';
    my $host = 'company';

    my $wiki =
        Dokuwiki::RPC::XML::Client 
        -> reach('https://wiki.example.com/');

    my $credentials = Net::Netrc->lookup($host)
        or die "please add a fake $host machine in your ~/.netrc";

    my ( $l, $p ) = $credentials->lpa;

    $wiki->login( $l, $p )->value 
        or die "can't authenticate with $l";

    say $wiki->getVersion->value;

=head1 FUTURE

i'm still experimenting to make my mind up about the right way to do it. it would
be nice to have both a raw C<RPC::XML::Client> as a singleton. then we could have

scripts/dokuwiki-client  view on Meta::CPAN

   
    dokuwiki-client show getPageHTML page:in:your:namespace 
    # show the rendered version of page:in:your:namespace 
    
    dokuwiki-client ls your:namespace
    # list the ids of pages in your:namespace 

=head1 Configure

configure a machine (the name isn't related to the dokuwiki base url) to store
the credentials 

    machine personnal.wiki
        login me
        password Ih4v3S3cr3ts

then, setup 2 environement variables

    export DOKUWIKI_CLIENT_BASE=http://my.wiki.example.com
    export DOKUWIKI_CLIENT_MACHINE=personal.wiki

=head1 Available subcommand

=cut

my $wiki = Dokuwiki::RPC::XML::Client->reach( $ENV{DOKUWIKI_CLIENT_BASE} || die );
my $credentials = Net::Netrc->lookup( $ENV{DOKUWIKI_CLIENT_MACHINE} || die  )
    or die "please add a fake $ENV{DW_MACHINE} machine in your ~/.netrc"; 
my ( $l, $p ) = $credentials->lpa; 
$wiki->login( $l, $p ) or die;

=head2 call

call an XML::RPC method and dump the result as a YAML in stdout

    dokuwiki-client call getPagelist your:namespace

=cut



( run in 0.277 second using v1.01-cache-2.11-cpan-4d50c553e7e )