3 use CPAN; # old base.pm did not load CPAN on previous line
5 use vars qw(@EXPORT $VERSION);
6 use constant PAUSE_IP => "pause.perl.org";
10 push @CPAN::Complete::COMMANDS, qw(register modsearch);
11 $CPAN::Shell::COLOR_REGISTERED = 1;
14 CPAN::shell($_[0]||"admin's cpan> ",$_[1]);
17 sub CPAN::Shell::register {
18 my($self,$mod,@rest) = @_;
20 print "register called without argument\n";
23 if ($CPAN::META->has_inst("URI::Escape")) {
26 print "register requires URI::Escape installed, otherwise it cannot work\n";
29 print "Got request for mod[$mod]\n";
31 my $modline = join " ", $mod, @rest;
32 print "Sending to PAUSE [$modline]\n";
33 my $emodline = URI::Escape::uri_escape($modline, '^\w ');
36 sprintf("https://%s/pause/authenquery?pause99_add_mod_modid=".
37 "%s;SUBMIT_pause99_add_mod_hint=hint",
41 print "url[$url]\n\n";
42 print ">>>>Trying to open a netscape window<<<<\n";
44 system("netscape","-remote","openURL($url)");
47 my $m = CPAN::Shell->expand("Module",$mod);
49 print "Could not determine the object for $mod\n";
53 print "Found module id[$id] in database\n";
55 if (exists $m->{RO} && $m->{RO}{chapterid}) {
56 print "$id is already registered\n";
60 my(@namespace) = split /::/, $id;
61 my $rootns = $namespace[0];
63 # Tk, XML and Apache need special treatment
64 if ($rootns=~/^(Bundle)\b/) {
65 print "Bundles are not yet ready for registering\n";
69 # make a good suggestion for the chapter
70 my(@simile) = CPAN::Shell->expand("Module","/^$rootns(:|\$)/");
71 print "Found within this namespace ", join(", ", map { $_->id } @simile), "\n";
73 for my $ch (map { exists $_->{RO} ? $_->{RO}{chapterid} : ""} @simile) {
77 my(@seench) = sort grep {length($_)} keys %seench;
80 print "Found rootnamespace[$rootns] in the chapters [", join(", ", @seench), "]\n";
81 $reco_ch = $seench[0];
82 print "Picking $reco_ch\n";
83 } elsif (@seench==1) {
84 print "Found rootnamespace[$rootns] in the chapter[$seench[0]]\n";
85 $reco_ch = $seench[0];
87 print "The new rootnamespace[$rootns] needs to be introduced. Oh well.\n";
90 # Look closer at the dist
91 my $d = CPAN::Shell->expand("Distribution", $m->cpan_file);
92 printf "Module comes with dist[%s]\n", $d->id;
93 for my $contm ($d->containsmods) {
94 if ($CPAN::META->exists("CPAN::Module",$contm)) {
95 my $contm_obj = CPAN::Shell->expand("Module",$contm) or next;
96 my $is_reg = exists $contm_obj->{RO} && $contm_obj->{RO}{description};
97 printf(" in same dist: %s%s\n",
99 $is_reg ? " already in modulelist" : "",
104 # get it so that m is better and we can inspect for XS
105 CPAN::Shell->get($id);
107 CPAN::Shell->d($d->id);
113 open $mani, "$d->{build_dir}/MANIFEST" and @mani = <$mani>;
114 my @xs = grep /\.xs\b/, @mani;
116 print "Found XS files: @xs";
120 my $emodid = URI::Escape::uri_escape($id, '\W');
123 my $description = $m->{MANPAGE} || "";
124 $description =~ s/[A-Z]<//; # POD markup (and maybe more)
125 $description =~ s/^\s+//; # leading spaces
126 $description =~ s/>//; # POD
127 $description =~ s/^\Q$id\E//; # usually this line starts with the modid
128 $description =~ s/^[ \-]+//; # leading spaces and dashes
129 substr($description,44) = "" if length($description)>44;
130 $description = ucfirst($description);
131 my $edescription = URI::Escape::uri_escape($description, '^\w ');
132 $edescription =~ s/ /+/g;
134 sprintf("https://%s/pause/authenquery?pause99_add_mod_modid=".
135 "%s;pause99_add_mod_chapterid=%s;pause99_add_mod_statd=%s;".
136 "pause99_add_mod_stats=%s;pause99_add_mod_statl=%s;".
137 "pause99_add_mod_stati=%s;pause99_add_mod_description=%s;".
138 "pause99_add_mod_userid=%s;SUBMIT_pause99_add_mod_preview=preview",
147 $m->{RO}{CPAN_USERID},
150 print ">>>>Trying to open a netscape window<<<<\n";
151 system("netscape","-remote","openURL($url)");
154 sub CPAN::Shell::modsearch {
155 my($self,@line) = @_;
157 print "modsearch called without argument\n";
160 my $request = join " ", @line;
161 print "Got request[$request]\n";
162 my $erequest = URI::Escape::uri_escape($request, '^\w ');
163 $erequest =~ s/ /+/g;
165 sprintf("http://www.xray.mpe.mpg.de/cgi-bin/w3glimpse/modules?query=%s".
166 "&errors=0&case=on&maxfiles=100&maxlines=30",
170 print ">>>>Trying to open a netscape window<<<<\n";
171 system("netscape","-remote","openURL('$url')");
180 CPAN::Admin - A CPAN Shell for CPAN admins
184 perl -MCPAN::Admin -e shell
188 Note: this module is currently not maintained. If you need it and fix
189 it for your needs, please submit patches.
193 CPAN::Admin is a subclass of CPAN that adds the commands C<register>
194 and C<modsearch> to the CPAN shell.
196 C<register> calls C<get> on the named module, assembles a couple of
197 informations (description, language), and calls Netscape with the
198 -remote argument so that a form is filled with all the assembled
199 informations and the registration can be performed with a single
200 click. If the command line has more than one argument, register does
201 not run a C<get>, instead it interprets the rest of the line as DSLI
202 status, description, and userid and sends them to netscape such that
203 the form is again mostly filled and can be edited or confirmed with a
204 single click. CPAN::Admin never performs the submission click for you,
205 it is only intended to fill in the form on PAUSE and leave the
208 C<modsearch> simply passes the arguments to the search engine for the
209 modules@perl.org mailing list at http://www.xray.mpe.mpg.de where all
210 registration requests are stored. It does so in the same way as
211 register, namely with the C<netscape -remote> command.
213 An experimental feature has also been added, namely to color already
214 registered modules in listings. If you have Term::ANSIColor installed,
215 the u, r, and m commands will show already registered modules in
220 URI::Escape, netscape browser available in the path, netscape must
221 understand the -remote switch (as far as I know, this is only
222 available on UNIX); coloring of registered modules is only available
223 if Term::ANSIColor is installed.
227 This program is free software; you can redistribute it and/or
228 modify it under the same terms as Perl itself.