| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package VIM::Uploader; |
|
2
|
1
|
|
|
1
|
|
26451
|
use WWW::Mechanize; |
|
|
1
|
|
|
|
|
284224
|
|
|
|
1
|
|
|
|
|
45
|
|
|
3
|
1
|
|
|
1
|
|
13
|
use File::Spec; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
27
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
185
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
VIM::Uploader - upload your vim script to vim.org |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use VIM::Uploader; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $uploader = VIM::Uploader->new(); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$uploader->login( ) |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
or |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$uploader->login( |
|
26
|
|
|
|
|
|
|
user => 'xxx', |
|
27
|
|
|
|
|
|
|
pass => 'xxx', |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$uploader->upload_new( ... ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $ok = $uploader->upload( |
|
33
|
|
|
|
|
|
|
script_id => 1234, |
|
34
|
|
|
|
|
|
|
script_file => '/path/to/your/file', |
|
35
|
|
|
|
|
|
|
vim_version => '7.0', # valid values: 7.0 , 6.0 , 5.7 |
|
36
|
|
|
|
|
|
|
script_version => '0.2', # your vim script version |
|
37
|
|
|
|
|
|
|
version_comment => 'release note' # your vim script release note. |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
print "DONE" if $ok; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTIONS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
L provides F script for you to upload vim scripts. |
|
45
|
|
|
|
|
|
|
it creates a upload form template for you. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# in /path/to/script.vim/ directory |
|
48
|
|
|
|
|
|
|
$ vim-upload script.vim |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$ vim-upload script-2.04.tar.gz |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
then the file L will be created after the first upload. just edit the file , update script_id |
|
53
|
|
|
|
|
|
|
and the next time you can upload script easily. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$ vim-upload script.vim |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub new { |
|
62
|
0
|
|
|
0
|
0
|
|
my $self = bless {} , shift; |
|
63
|
0
|
|
|
|
|
|
my %args = @_; |
|
64
|
0
|
|
|
|
|
|
$self->{mech} = WWW::Mechanize->new(); |
|
65
|
0
|
|
|
|
|
|
$|++; |
|
66
|
0
|
|
|
|
|
|
return $self; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub mech { |
|
70
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
71
|
0
|
|
|
|
|
|
return $self->{mech}; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
1
|
|
5
|
use constant config_file => File::Spec->join($ENV{HOME},".vim-uploader"); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1039
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub read_config { |
|
77
|
0
|
|
|
0
|
0
|
|
my $path = config_file; |
|
78
|
0
|
0
|
|
|
|
|
return unless -e $path; |
|
79
|
0
|
|
|
|
|
|
open FH , "<" , $path; |
|
80
|
0
|
|
|
|
|
|
my $line = ; |
|
81
|
0
|
|
|
|
|
|
close FH; |
|
82
|
0
|
|
|
|
|
|
$line =~ s/\n$//; |
|
83
|
0
|
|
|
|
|
|
my ($user,$pass) = split /:/,$line; |
|
84
|
|
|
|
|
|
|
return { |
|
85
|
0
|
|
|
|
|
|
user => $user, |
|
86
|
|
|
|
|
|
|
pass => $pass, |
|
87
|
|
|
|
|
|
|
}; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub login { |
|
91
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
92
|
0
|
|
|
|
|
|
my $config; |
|
93
|
0
|
0
|
|
|
|
|
$config = { @_ } if @_; |
|
94
|
0
|
|
0
|
|
|
|
$config ||= $self->read_config(); |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
unless( $config ) { |
|
97
|
0
|
|
|
|
|
|
print "Seems you dont have " . config_file . ". create one ? (Y/n) : "; |
|
98
|
0
|
|
|
|
|
|
my $ans = ; |
|
99
|
0
|
|
|
|
|
|
chomp $ans; |
|
100
|
0
|
|
0
|
|
|
|
$ans ||= 'Y'; |
|
101
|
0
|
0
|
|
|
|
|
if( $ans =~ /y/i ) { |
|
102
|
0
|
|
|
|
|
|
print "User: "; |
|
103
|
0
|
|
|
|
|
|
my $user = ; |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
print "Password: "; |
|
106
|
0
|
|
|
|
|
|
my $pass = ; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
chomp $user; |
|
109
|
0
|
|
|
|
|
|
chomp $pass; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
open FH , ">" , config_file; |
|
112
|
0
|
|
|
|
|
|
print FH "$user:$pass\n"; |
|
113
|
0
|
|
|
|
|
|
close FH; |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
print "Created.\n"; |
|
116
|
0
|
|
|
|
|
|
$config = $self->read_config(); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
print "Login\n"; |
|
121
|
0
|
|
|
|
|
|
$self->mech->get( "http://www.vim.org/login.php" ); |
|
122
|
0
|
|
|
|
|
|
$self->mech->form_name( 'login' ); |
|
123
|
0
|
|
|
|
|
|
$self->mech->field( userName => $config->{user} ); |
|
124
|
0
|
|
|
|
|
|
$self->mech->field( password => $config->{pass} ); |
|
125
|
0
|
|
|
|
|
|
$self->mech->click_button( value => 'Login'); |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
die "Authentication Failed" |
|
128
|
|
|
|
|
|
|
if $self->mech->content =~ /Authentication failed/; |
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
print "Sucessed\n"; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 upload_new( %args ) |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
script_name |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
script_file |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
script_type: 'color scheme' , 'ftplugin' , 'game' , 'indent' , 'syntax' , 'utility' , 'patch' |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
vim_version: 5.7 , 6.0 , 7.0 , 7.2 |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
script_version: |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
summary |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
description |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
install_details |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub upload_new { |
|
157
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
158
|
0
|
|
|
|
|
|
my %args = @_; |
|
159
|
0
|
|
|
|
|
|
my $new_script_url = 'http://www.vim.org/scripts/add_script.php'; |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
$args{ACTION} = 'UPLOAD_NEW'; |
|
162
|
0
|
|
|
|
|
|
$args{MAX_FILE_SIZE} = '10485760'; |
|
163
|
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
my @undefs; |
|
165
|
0
|
|
|
|
|
|
my @fields = qw(script_name script_file script_type vim_version script_version summary description install_details); |
|
166
|
0
|
|
|
|
|
|
for( @fields ){ |
|
167
|
0
|
0
|
|
|
|
|
push @undefs, $_ unless $args{$_}; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
0
|
0
|
|
|
|
|
die "Field " . join(',',@undefs) . " is undefined." if @undefs; |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
$self->mech->get( $new_script_url ); |
|
172
|
0
|
|
|
|
|
|
$self->mech->form_name('script'); |
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
for ( @fields ) { |
|
175
|
0
|
|
|
|
|
|
$self->mech->field( $_ => $args{$_} ); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
$self->mech->click_button( value => 'upload' ); |
|
179
|
0
|
0
|
|
|
|
|
die "ERROR" if $self->mech->content =~ /Vim Online Error/; |
|
180
|
0
|
|
|
|
|
|
print "DONE\n"; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub upload { |
|
186
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
187
|
0
|
|
|
|
|
|
my %args = @_; |
|
188
|
0
|
|
|
|
|
|
my $script_id = $args{ script_id }; |
|
189
|
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
my $new_version_url |
|
191
|
|
|
|
|
|
|
= sprintf( |
|
192
|
|
|
|
|
|
|
'http://www.vim.org/scripts/add_script_version.php?script_id=%d', |
|
193
|
|
|
|
|
|
|
$script_id ); |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
print "Reading upload form\n"; |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
$self->mech->get( $new_version_url ); |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
0
|
|
|
|
|
die "ERROR" if $self->mech->content =~ /Vim Online Error/; |
|
200
|
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
$self->mech->form_name( 'script' ); |
|
202
|
0
|
|
|
|
|
|
for ( keys %args ) { |
|
203
|
0
|
|
|
|
|
|
$self->mech->field( $_ => $args{$_} ); |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
$self->mech->click_button( value => 'upload'); |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
0
|
|
|
|
|
die "ERROR" if $self->mech->content =~ /Vim Online Error/; |
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
print "DONE\n"; |
|
211
|
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
$self->mech->get( 'http://www.vim.org/scripts/script.php?script_id=' . $script_id ); |
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
my $html = $self->mech->content; |
|
215
|
0
|
|
|
|
|
|
return index($html, $args{version_comment}); |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 AUTHOR |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Cornelius, C<< >> |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 BUGS |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
225
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
226
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 SUPPORT |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
perldoc VIM::Uploader |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
You can also look for information at: |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=over 4 |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
L |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
L |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
L |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item * Search CPAN |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
L |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=back |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Copyright 2009 Cornelius. |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
This program is released under the following license: MIT |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=cut |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
1; # End of VIM::Uploader |