Navigation Menu

Skip to content

Commit

Permalink
initial revision
Browse files Browse the repository at this point in the history
  • Loading branch information
Danijel Tasov committed Feb 25, 2010
0 parents commit e8d877f
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Build.PL
@@ -0,0 +1,25 @@
use strict;
use warnings;
use Module::Build;

my $builder = Module::Build->new(
module_name => 'App::Nopaste::Service::Pastedance',
license => 'perl',
dist_author => q{Danijel Tasov <data@cpan.org>},
dist_version_from => 'lib/App/Nopaste/Service/Pastedance.pm',
dist_abstract => 'Add Pastedance service to App::Nopaste',
build_requires => {
'Test::More' => 0,
},
requires => {
'App::Nopaste' => 0,
},
add_to_cleanup => [ 'App-Nopaste-*' ],
meta_merge => {
resources => {
#repository => 'http://github.com/datamuc/WWW-Shorten-URLchen',
},
},
);

$builder->create_build_script();
103 changes: 103 additions & 0 deletions lib/App/Nopaste/Service/Pastedance.pm
@@ -0,0 +1,103 @@
package App::Nopaste::Service::Pastedance;

use warnings;
use strict;
use Scalar::Util 'blessed';

our $VERSION = '0.01';

use base q[App::Nopaste::Service];

sub uri { return 'http://pb.rbfh.de/' }


sub fill_form {
my ($self, $mech) = (shift, shift);
my %args = @_;

my $content = {
code => $args{text},
subject => $args{desc},
lang => exists( $self->FORMATS->{ $args{lang} } )
? $self->FORMATS->{ $args{lang} }
: 'txt',
};

$mech->agent_alias('Linux Mozilla');
my $form = $mech->form_number(1) || return;

# do not follow redirect please
@{$mech->requests_redirectable} = ();

my $paste = HTML::Form::Input->new(
type => 'text',
value => 'Send',
name => 'paste'
)->add_to_form($form);

return $mech->submit_form( form_number => 1, fields => $content );
}

sub return {
my $self = shift;
my $mech = shift;
my $response = $mech->response;
if($response->is_redirect) {
return (1,$response->header("Location"));
} else {
return (0, "Cannot find URL");
}
}

sub FORMATS {
{
ada => "Ada",
applescript => "Applescript",
asm => "Assembler",
bib => "Bib",
yacc => "Bison",
shell => "Bourne Shell",
c => "C",
csharp => "C#",
'c++' => "C++",
caml => "CAML",
changelog => "changelog",
cobol => "COBOL",
conf => "conf",
css => "CSS",
d => "D",
diff => "diff",
bat => "DOS Batch",
erl => "Erlang",
flex => "Flex",
f77 => "Fortran (Fixed)",
f90 => "Fortran (Free)",
glsl => "GLSL",
haskell => "Haskell",
html => "HTML",
ini => "INI",
java => "Java",
js => "Javascript",
latex => "LaTeX",
ldif => "LDIF",
lua => "Lua",
m4 => "m4",
make => "Makefile",
pascal => "Pascal",
perl => "Perl",
php => "PHP",
ps => "Postscript",
python => "Python",
ruby => "Ruby",
scala => "Scala",
slang => "Slang",
sql => "SQL",
txt => "txt",
tcl => "tcl/tk",
vb => "VB Script",
xml => "XML",
xorg => "Xorg",
};
}

__END__

0 comments on commit e8d877f

Please sign in to comment.