SVN: toys/rsget.pl/RSGet: HTTPRequest.pm ListManager.pm
sparky
sparky at pld-linux.org
Sat Sep 12 01:45:59 CEST 2009
Author: sparky
Date: Sat Sep 12 01:45:58 2009
New Revision: 10580
Modified:
toys/rsget.pl/RSGet/HTTPRequest.pm
toys/rsget.pl/RSGet/ListManager.pm
Log:
- few improvements
Modified: toys/rsget.pl/RSGet/HTTPRequest.pm
==============================================================================
--- toys/rsget.pl/RSGet/HTTPRequest.pm (original)
+++ toys/rsget.pl/RSGet/HTTPRequest.pm Sat Sep 12 01:45:58 2009
@@ -50,7 +50,7 @@
$headers->{Content_Type} = sprintf "text/%s; charset=utf-8", ($1 eq "js" ? "javascript" : "css");
local $/ = undef;
- open F_IN, "data/$file";
+ open F_IN, '<', $main::data_path . "/data/" . $file;
$_ = <F_IN>;
close F_IN;
@@ -420,7 +420,7 @@
sub f_addform
{
my $id = shift;
- return '<form action="/add" method="POST"' . ( $id ? '>' : ' target="_blank">' )
+ return '<form action="/add" method="POST"' . ( defined $id ? '>' : ' target="_blank">' )
. '<fieldset id="add"><legend>Add links to the list</legend>'
. ( $id ? qq#<input type="hidden" name="id" value="$id" /># : '' )
. '<textarea cols="100" rows="8" name="links"></textarea>'
@@ -456,6 +456,13 @@
$r .= '<li class="comment">' . href( $l ) . '</li>';
}
+ my %cmd_to_color = (
+ DONE => "blue",
+ GET => "green",
+ STOP => "red",
+ ADD => "orange",
+ );
+
my $lines = $list->{lines};
foreach my $l ( @$lines ) {
unless ( ref $l ) {
@@ -463,7 +470,7 @@
next;
}
- $r .= qq#<li class="file green">#;
+ $r .= qq#<li class="file $cmd_to_color{ $l->{cmd} }">#;
$r .= qq#<div class="info"><span class="cmd">$l->{cmd}</span></div>#;
$r .= '</li>';
@@ -491,11 +498,15 @@
$list = RSGet::ListManager::add_list_comment( $post->{comment}, $post->{id} )
if $post->{comment};
- $r .= '<fieldset id="f_listask"></fieldset>';
- $r .= f_addlist( $list );
- $r .= f_addcomment( $list->{id} );
- $r .= f_addform( $list->{id} );
- $r .= qq#<script type="text/javascript">init_add( "$list->{id}" );</script>#;
+ if ( $list ) {
+ $r .= '<fieldset id="f_listask"></fieldset>';
+ $r .= f_addlist( $list );
+ $r .= f_addcomment( $list->{id} );
+ $r .= f_addform( $list->{id} );
+ $r .= qq#<script type="text/javascript">init_add( "$list->{id}" );</script>#;
+ } else {
+ $r .= f_addform( "" );
+ }
$r .= xhtml_end();
return $r;
Modified: toys/rsget.pl/RSGet/ListManager.pm
==============================================================================
--- toys/rsget.pl/RSGet/ListManager.pm (original)
+++ toys/rsget.pl/RSGet/ListManager.pm Sat Sep 12 01:45:58 2009
@@ -287,6 +287,7 @@
} while ( exists $all_lists{$id} );
}
my $list = $all_lists{$id} ||= {};
+ return unless ref $list;
$list->{comment} ||= [];
my $lines = $list->{lines} ||= [];
@@ -373,13 +374,14 @@
my $lines = $list->{lines};
$list->{select_clone} = 1;
my @used_save;
- foreach my $line ( @$lines ) {
+ for ( my $i = 0; $i < scalar @$lines; $i++ ) {
+ my $line = $lines->[$i];
next unless ref $line;
my $globals = $line->{globals};
my $uris = $line->{uris};
unless ( keys %$uris ) {
- $line = "";
- next;
+ my $l = splice @$lines, $i, 1;
+ redo;
}
foreach my $uri ( keys %$uris ) {
@@ -394,14 +396,16 @@
hadd $options, %{$save->{options}} if $save->{options};
if ( my $links = $save->{links} ) {
+ my @new;
foreach my $uri ( @$links ) {
my $getter = RSGet::Dispatch::getter( $uri );
if ( $getter ) {
- push @$lines, { cmd => "ADD", globals => {}, uris => { $uri => [ $getter, {} ] } };
+ push @new, { cmd => "ADD", globals => {}, uris => { $uri => [ $getter, {} ] } };
} else {
- push @$lines, "# unsupported uri: $uri";
+ push @new, "# unsupported uri: $uri";
}
}
+ splice @$lines, $i+1, 0, @new;
}
if ( my $clones = $save->{clones} ) {
hadd $uris, %$clones;
More information about the pld-cvs-commit
mailing list