line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Nopaste::Service::Hpaste; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created: 西元2011年02月15日 19時51分40秒 |
4
|
|
|
|
|
|
|
# Last Edit: 2013 Nov 19, 05:15:30 PM |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Hpaste.pm - Paste to http://hpaste.org, the Haskell paste site |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
2274320
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
14
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
nopaste -s Hpaste -l haskell -n "Dr Bean" -d "Category theory" paste.txt |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
hpaste requires a title, an author, and the paste. The default language is 'haskell.' No, it's 'perl', but it should be 'haskell'. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
6
|
use base 'App::Nopaste::Service'; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
688
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $code; |
31
|
|
|
|
|
|
|
my %Langs = ( |
32
|
|
|
|
|
|
|
"" => "", |
33
|
|
|
|
|
|
|
"Haskell" => "haskell", |
34
|
|
|
|
|
|
|
"Agda" => "agda", |
35
|
|
|
|
|
|
|
"Bash/shell" => "bash", |
36
|
|
|
|
|
|
|
"C" => "c", |
37
|
|
|
|
|
|
|
"C++" => "cpp", |
38
|
|
|
|
|
|
|
"Common Lisp" => "lisp", |
39
|
|
|
|
|
|
|
"D" => "d", |
40
|
|
|
|
|
|
|
"Diff" => "diff", |
41
|
|
|
|
|
|
|
"Elisp" => "elisp", |
42
|
|
|
|
|
|
|
"Erlang" => "erlang", |
43
|
|
|
|
|
|
|
"Java" => "java", |
44
|
|
|
|
|
|
|
"JavaScript" => "javascript", |
45
|
|
|
|
|
|
|
"Literate Haskell" => "literatehaskell", |
46
|
|
|
|
|
|
|
"Lua" => "lua", |
47
|
|
|
|
|
|
|
"Objective-C" => "objectivec", |
48
|
|
|
|
|
|
|
"OCaml" => "ocaml", |
49
|
|
|
|
|
|
|
"Perl" => "perl", |
50
|
|
|
|
|
|
|
"Prolog" => "prolog", |
51
|
|
|
|
|
|
|
"Python" => "python", |
52
|
|
|
|
|
|
|
"Ruby" => "ruby", |
53
|
|
|
|
|
|
|
"Scala" => "scala", |
54
|
|
|
|
|
|
|
"SQL" => "sql", |
55
|
|
|
|
|
|
|
"TeX" => "tex", |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
my %langs = map { lc($_) => $Langs{$_} } keys %Langs; |
58
|
|
|
|
|
|
|
$code->{lang} = \%langs; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$code->{chan} = { |
61
|
|
|
|
|
|
|
"" => "", |
62
|
|
|
|
|
|
|
"haskell" => "#haskell", |
63
|
|
|
|
|
|
|
"xmonad" => "#xmonad", |
64
|
|
|
|
|
|
|
"javascript" => "#javascript", |
65
|
|
|
|
|
|
|
"python" => "#python", |
66
|
|
|
|
|
|
|
"ruby" => "#ruby", |
67
|
|
|
|
|
|
|
"lisp" => "#lisp", |
68
|
|
|
|
|
|
|
"scala" => "#scala", |
69
|
|
|
|
|
|
|
"agda" => "#agda", |
70
|
|
|
|
|
|
|
"coffeescript" => "#coffeescript", |
71
|
|
|
|
|
|
|
"arc" => "#arc", |
72
|
|
|
|
|
|
|
"c" => "##c", |
73
|
|
|
|
|
|
|
"clojure" => "#clojure", |
74
|
|
|
|
|
|
|
"scheme" => "#scheme", |
75
|
|
|
|
|
|
|
"prolog" => "##prolog", |
76
|
|
|
|
|
|
|
"emacs" => "#emacs", |
77
|
|
|
|
|
|
|
"hpaste" => "#hpaste", |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
1
|
|
sub uri { "http://lpaste.net/" } |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub fill_form { |
83
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
84
|
0
|
|
|
|
|
|
my $mech = shift; |
85
|
0
|
|
|
|
|
|
my %args = @_; |
86
|
0
|
|
|
|
|
|
my $title; |
87
|
0
|
0
|
|
|
|
|
if ( $args{desc} ) { |
88
|
0
|
|
|
|
|
|
$title = $args{desc}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
else { |
91
|
0
|
|
|
|
|
|
my ($line, $remains) = split "\n", $args{text}; |
92
|
0
|
|
|
|
|
|
$title = substr( $line, 0, 30 ); |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
0
|
|
|
|
my $lang = $code->{lang}->{ (lc $args{lang}) || "haskell" }; |
95
|
0
|
|
0
|
|
|
|
my $chan = $code->{chan}->{ $args{chan} || "" }; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$mech->field( 'title' => $title ); |
98
|
0
|
|
|
|
|
|
$mech->field( 'author' => $args{nick} ); |
99
|
0
|
|
|
|
|
|
$mech->field( 'language' => $lang ); |
100
|
0
|
|
|
|
|
|
$mech->field( 'channel' => $chan ); |
101
|
0
|
|
|
|
|
|
$mech->field( 'paste' => $args{text} ); |
102
|
0
|
|
|
|
|
|
$mech->click(); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub return { |
106
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
107
|
0
|
|
|
|
|
|
my $mech = shift; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $link = $mech->uri(); |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
return (0, "No link to paste.") unless $link; |
112
|
0
|
|
|
|
|
|
return (1, $link); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Dr Bean C<< >> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 BUGS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
126
|
|
|
|
|
|
|
C, or through the web interface at |
127
|
|
|
|
|
|
|
L. |
128
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
129
|
|
|
|
|
|
|
your bug as I make changes. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SUPPORT |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
perldoc /home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
You can also look for information at: |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * CPAN Ratings |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * Search CPAN |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Copyright 2011 Dr Bean, all rights reserved. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
166
|
|
|
|
|
|
|
under the same terms as Perl itself. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; # End of /home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# vim: set ts=8 sts=4 sw=4 noet: |
173
|
|
|
|
|
|
|
|