Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Danijel Tasov
committed
Feb 25, 2010
0 parents
commit e8d877f
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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__ |