line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
72920
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
60
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
114
|
|
3
|
|
|
|
|
|
|
package App::Nopaste::Service::Pastie; |
4
|
|
|
|
|
|
|
# ABSTRACT: Service provider for Pastie - pastie.org |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.011'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
347
|
use parent 'App::Nopaste::Service'; |
|
2
|
|
|
|
|
328
|
|
|
2
|
|
|
|
|
12
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my %languages = ( |
11
|
|
|
|
|
|
|
"bash" => "13", |
12
|
|
|
|
|
|
|
"c#" => "20", |
13
|
|
|
|
|
|
|
"c/c++" => "7", |
14
|
|
|
|
|
|
|
"css" => "8", |
15
|
|
|
|
|
|
|
"diff" => "5", |
16
|
|
|
|
|
|
|
"go" => "21", |
17
|
|
|
|
|
|
|
"html (erb / rails)" => "12", |
18
|
|
|
|
|
|
|
"html / xml" => "11", |
19
|
|
|
|
|
|
|
"java" => "9", |
20
|
|
|
|
|
|
|
"javascript" => "10", |
21
|
|
|
|
|
|
|
"objective-c/c++" => "1", |
22
|
|
|
|
|
|
|
"perl" => "18", |
23
|
|
|
|
|
|
|
"php" => "15", |
24
|
|
|
|
|
|
|
"plain text" => "6", |
25
|
|
|
|
|
|
|
"python" => "16", |
26
|
|
|
|
|
|
|
"ruby" => "3", |
27
|
|
|
|
|
|
|
"ruby on rails" => "4", |
28
|
|
|
|
|
|
|
"sql" => "14", |
29
|
|
|
|
|
|
|
# hidden |
30
|
|
|
|
|
|
|
"apache" => "22", |
31
|
|
|
|
|
|
|
"clojure" => "38", |
32
|
|
|
|
|
|
|
"d" => "26", |
33
|
|
|
|
|
|
|
"erlang" => "27", |
34
|
|
|
|
|
|
|
"fortran" => "28", |
35
|
|
|
|
|
|
|
"haskell" => "29", |
36
|
|
|
|
|
|
|
"ini" => "35", |
37
|
|
|
|
|
|
|
"io" => "24", |
38
|
|
|
|
|
|
|
"lisp" => "25", |
39
|
|
|
|
|
|
|
"lua" => "23", |
40
|
|
|
|
|
|
|
"makefile" => "31", |
41
|
|
|
|
|
|
|
"nu" => "36", |
42
|
|
|
|
|
|
|
"pascal" => "17", |
43
|
|
|
|
|
|
|
"puppet" => "39", |
44
|
|
|
|
|
|
|
"scala" => "32", |
45
|
|
|
|
|
|
|
"scheme" => "33", |
46
|
|
|
|
|
|
|
"smarty" => "34", |
47
|
|
|
|
|
|
|
"tex" => "37", |
48
|
|
|
|
|
|
|
# aliases |
49
|
|
|
|
|
|
|
"sh" => "13", |
50
|
|
|
|
|
|
|
"c" => "7", |
51
|
|
|
|
|
|
|
"c++" => "7", |
52
|
|
|
|
|
|
|
"objective-C" => "1", |
53
|
|
|
|
|
|
|
"objective-C++" => "1", |
54
|
|
|
|
|
|
|
"plain" => "6", |
55
|
|
|
|
|
|
|
"raw" => "6", |
56
|
|
|
|
|
|
|
"rails" => "4", |
57
|
|
|
|
|
|
|
"html" => "11", |
58
|
|
|
|
|
|
|
"xml" => "11", |
59
|
|
|
|
|
|
|
"js" => "10", |
60
|
|
|
|
|
|
|
"make" => "31", |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
1
|
100
|
sub uri { 'http://pastie.org/' } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub fill_form { |
66
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
67
|
0
|
|
|
|
|
|
my $mech = shift; |
68
|
0
|
|
|
|
|
|
my %args = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $lang_id = $languages{"plain text"}; |
71
|
|
|
|
|
|
|
$lang_id = $languages{lc($args{lang})} |
72
|
0
|
0
|
0
|
|
|
|
if (exists $args{lang} && exists $languages{lc($args{lang})}); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$mech->submit_form( |
75
|
|
|
|
|
|
|
fields => { |
76
|
|
|
|
|
|
|
"paste[body]" => $args{text}, |
77
|
|
|
|
|
|
|
"paste[authorization]" => 'burger', # set with JS to avoid bots |
78
|
|
|
|
|
|
|
"paste[restricted]" => $args{private}, |
79
|
0
|
|
|
|
|
|
"paste[parser_id]" => $lang_id, |
80
|
|
|
|
|
|
|
}, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub return { |
85
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
86
|
0
|
|
|
|
|
|
my $mech = shift; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $prefix =''; |
89
|
0
|
|
|
|
|
|
my ($id) = $mech->title =~ /\#(\d+)/; |
90
|
0
|
0
|
|
|
|
|
if (!$id) { |
91
|
0
|
|
|
|
|
|
($id) = $mech->content =~ m{http://pastie.org/\d+/wrap\?key=([a-z0-9]+)}; |
92
|
0
|
|
|
|
|
|
$prefix = 'private/'; |
93
|
|
|
|
|
|
|
} |
94
|
0
|
0
|
|
|
|
|
return (0, "Could not construct paste link.") if !$id; |
95
|
0
|
|
|
|
|
|
return (1, "http://pastie.org/$prefix$id"); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |