WebService-NoPaste

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


----

NAME
        WebService::NoPaste - Post to Paste Web Pages

SYNOPSIS
        # Manually paste input, manually copy the result url:
        $ nopaste

        # Turbo mode: use clipboard as input, send, and then put the result
        # URL back into the clipboard:
        $ nopaste cp

        # Just take the input from the clipboard, but otherwise leave the
        # clipboard alone:
        $ nopaste c

        # Instantly upload your passwd file for the whole world to see, but
        # at least you'll have the result URL conveniently in your
        # clipboard.
        $ nopaste p < /etc/passwd 

DESCRIPTION
        When online chatting it is problematic to paste an entire 300 line
        file.  Yes paste?  No.  NoPaste!

        Posting to a paste host is preferred.  These servers are just web
        forms that accept input from a big text field, and temporarily house
        them as web pages.

lib/WebService/NoPaste.pm  view on Meta::CPAN


sub payload_urls {
    map { $self->{host} . $self->{payload_path} . '.' . $_ } qw(txt html)
}

sub read_from_stdin {
    print "Paste at will...\n" if -t STDIN;
    io('-')->all
}

sub read_from_clipboard { Clipboard->paste }

sub save_to_clipboard { Clipboard->copy($_[0]); }

my $PLEASE_EMAIL = "WebService::NoPaste has only been tested with 'pastebot' brand paste servers, and even then only to a limited extent.  If you got this error unexpectedly, please let me know - rking\@panopic.com.";
sub response_die {
    my ($r, $reason) = @_;
    die join "\n", $reason, $PLEASE_EMAIL, "The response was: " .  $r->as_string
}

1;

=head1 NAME 

    WebService::NoPaste - Post to Paste Web Pages

=head1 SYNOPSIS

    # Manually paste input, manually copy the result url:
    $ nopaste

    # Turbo mode: use clipboard as input, send, and then put the result
    # URL back into the clipboard:
    $ nopaste cp

    # Just take the input from the clipboard, but otherwise leave the
    # clipboard alone:
    $ nopaste c

    # Instantly upload your passwd file for the whole world to see, but
    # at least you'll have the result URL conveniently in your
    # clipboard.
    $ nopaste p < /etc/passwd 

=head1 DESCRIPTION

    When online chatting it is problematic to paste an entire 300 line
    file.  Yes paste?  No.  NoPaste!

    Posting to a paste host is preferred.  These servers are just web
    forms that accept input from a big text field, and temporarily house
    them as web pages.

nopaste  view on Meta::CPAN

    my $np = WebService::NoPaste->new(
        # These two are special...
        host => 'http://rafb.net',
        post_path => '/paste/paste.php',
        # ...and the rest are directly passed as POST variables:
        cvt_tabs => 'No',
        lang => 'Perl', # affects syntax highlighting in HTML view
        nick => $ENV{USER}, # shows up in "Recent pastes" list
        desc => '',
    );
    my $text = hasopt('c') ? $np->read_from_clipboard : $np->read_from_stdin;
    print "Sending to server...\n";
    $np->send($text);
    print "Paste successfully posted to:\n" . join "\n", $np->payload_urls;
    if (hasopt('p')) {
        $np->save_to_clipboard(($np->payload_urls)[-1]);
        print " <-- now in the clipboard.\n";
    } else {
        print "\n";
    }
}
if (hasopt('h')) {
    # this will need updating if we end up supporting more than just "xclip"
    print <<"...";
nopaste [cph]
    c  copies data from xclip instead of STDIN
    p  pastes result URL to xclip



( run in 1.531 second using v1.01-cache-2.11-cpan-84e82930d8c )