App-org2wp

 view release on metacpan or  search on metacpan

script/org2wp  view on Meta::CPAN

#!perl

# Note: This script is a CLI for Riap function /App/org2wp/org2wp
# and generated automatically using Perinci::CmdLine::Gen version 0.501

use 5.010001;
use strict;
use warnings;
use Log::ger;

use Perinci::CmdLine::Any;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2022-05-02'; # DATE
our $DIST = 'App-org2wp'; # DIST
our $VERSION = '0.013'; # VERSION

my $cmdline = Perinci::CmdLine::Any->new(
    url => "/App/org2wp/org2wp",
    program_name => "org2wp",
    log => 1,
);

$cmdline->run;

# ABSTRACT: Publish Org document (or heading) to WordPress as blog post
# PODNAME: org2wp

__END__

=pod

=encoding UTF-8

=head1 NAME

org2wp - Publish Org document (or heading) to WordPress as blog post

=head1 VERSION

This document describes version 0.013 of org2wp (from Perl distribution App-org2wp), released on 2022-05-02.

=head1 SYNOPSIS

Usage:

% B<org2wp> [B<--comment-status>=I<str>] [B<--config-path>=I<path>|B<-c>|B<--no-config>|B<-C>] [B<--config-profile>=I<profile>|B<-P>] [B<--debug>|B<--log-level>=I<level>|B<--quiet>|B<--trace>|B<--verbose>] [B<--dry-run>|B<-n>] [(B<--exclude-heading-t...

=head1 DESCRIPTION

This is originally a quick hack because I couldn't make
LL<https://github.com/punchagan/org2blog> on my Emacs installation to
work after some update. C<org2wp> uses the same format as C<org2blog>, but instead
of being an Emacs package, it is a CLI script written in Perl.

First, create C<~/org2wp.conf> containing the API credentials, e.g.:

 ; use INI (IOD) format for this file
 proxy=https://YOURBLOGNAME.wordpress.com/xmlrpc.php
 username=YOURUSERNAME
 password=YOURPASSWORD

Note that C<proxy> is the endpoint URL of your WordPress instance's XML-RPC
server, which can be hosted on C<wordpress.com> or on other server, including
your own. It has nothing to do with HTTP/HTTPS proxy; the term "proxy" is used
by the L<XMLRPC::Lite> and L<SOAP::Lite> Perl libraries and C<org2wp> simply
uses the same terminology.

You can also put multiple credentials in the configuration file using profile
sections, e.g.:

 ; use INI (IOD) format for this file
 [profile=blog1]
 proxy=https://YOURBLOG1NAME.wordpress.com/xmlrpc.php
 username=YOURUSERNAME
 password=YOURPASSWORD
 
 [profile=blog2]
 proxy=https://YOURBLOG2NAME.wordpress.com/xmlrpc.php
 username=YOURUSERNAME
 password=YOURPASSWORD

and specify which profile you want using command-line option e.g.
C<--config-profile blog1>.

=head3 Document mode

You can use the whole Org document file as a blog post (document mode) or a
single heading as a blog post (heading mode). The default is document mode. To
create a blog post, write your Org document (e.g. in C<post1.org>) using this
format:

 #+TITLE: Blog post title
 #+CATEGORY: cat1, cat2
 #+TAGS: tag1,tag2,tag3
 
 Text of your post ...
 ...

then:

 % org2wp post1.org

this will create a draft post. To publish directly:

 % org2wp --publish post1.org

Note that this will also modify your Org file and insert this setting line at
the top:

 #+POSTID: 1234
 #+POSTTIME: [2020-09-16 Wed 11:51]

where 1234 is the post ID retrieved from the server when creating the post, and
post time will be set to the current local time.

After the post is created, you can update using the same command:

 % org2wp post1.org

You can use C<--publish> to publish the post, or C<--no-publish> to revert it to
draft.

To set more attributes:

 % org2wp post1.org --comment-status open \
     --extra-attr ping_status=closed --extra-attr sticky=1

Another example, to schedule a post in the future:



( run in 2.400 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )