Changeset 72
- Timestamp:
- 07/21/06 09:52:29 (2 years ago)
- Files:
-
- trunk/TODO (modified) (1 diff)
- trunk/lib/PrlMnks/Plugin/RSS.pm (modified) (5 diffs)
- trunk/lib/PrlMnks/Type.pm (modified) (1 diff)
- trunk/t/plugin/rss/rss.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/TODO
r68 r72 1 limit the length of the nodes in XML 2 3 cache output of non-id xml 1 limit the length of the nodes in XML. This is tricky because the content is HTML and we should try not to trim it so that the HTML becomes invalid. 4 2 5 3 look for if modified since headers when sending file 6 4 7 5 create an 'out' page that uses cookies to store where the user should be sent. 6 7 create search facility 8 9 create firefox plugin for searching trunk/lib/PrlMnks/Plugin/RSS.pm
r69 r72 10 10 11 11 sub add_node { 12 my $self = shift; 13 my $node = shift; 12 my $self = shift; 13 my $node = shift; 14 my $node_data = $node->as_hashref; 15 my @to_delete = (); 14 16 15 17 # delete ourselves. 16 my $file = $self->path_to_file( 'rss', $node->node_id, 'xml' ); 17 unlink $file if -e $file; 18 push @to_delete, $node->node_id; 18 19 19 20 # Delete all the elders of this node. 20 foreach my $id ( keys %{ $node->elders || {} } ) { 21 my $file = $self->path_to_file( 'rss', $id, 'xml' ); 21 push @to_delete, keys %{ $node->elders || {} }; 22 23 # Delete the author. 24 push @to_delete, $node_data->{author_id}; 25 26 # Delete the category and 'top' if needed. 27 if ( $node->is_top ) { 28 push @to_delete, $node_data->{type_id}; 29 push @to_delete, 'top'; 30 } 31 32 # Always delete 'all'. 33 push @to_delete, 'all'; 34 35 # warn Dumper { id => $node->node_id, delete => \@to_delete } 36 # if $node->is_top; 37 38 foreach my $id (@to_delete) { 39 next unless $id; 40 my $file = $self->rss_file($id); 22 41 unlink $file if -e $file; 23 42 } … … 117 136 . " limit $max_nodes"; 118 137 119 warn $sql;138 #warn $sql; 120 139 121 140 my $sth = PrlMnks::DBI->dbh->prepare($sql); … … 131 150 # warn Dumper \@nodes; 132 151 133 warn "cache this and clear it on add node"; 134 return $self->send_template('/rss/list.mason'); 152 return $self->send_template( '/rss/list.mason', { cache_to => $file } ); 135 153 } 136 154 … … 163 181 $self->vars->{nodes} = \@nodes; 164 182 165 warn "cache this and clear it on add node"; 166 return $self->send_template('/rss/list.mason'); 183 return $self->send_template( '/rss/list.mason', { cache_to => $file } ); 167 184 } 168 185 … … 188 205 $self->vars->{nodes} = \@nodes; 189 206 190 warn "cache this and clear it on add node"; 191 return $self->send_template('/rss/list.mason'); 207 return $self->send_template( '/rss/list.mason', { cache_to => $file } ); 192 208 } 193 209 trunk/lib/PrlMnks/Type.pm
r53 r72 226 226 return @ids; 227 227 } 228 228 229 1; trunk/t/plugin/rss/rss.t
r69 r72 13 13 use_ok $p; 14 14 use_ok "PrlMnks::Node"; 15 16 { # Delete all the rss. 17 my $rss_dir = PrlMnks->shared('rss'); 18 `rm -rf $rss_dir`; 19 } 15 20 16 21 # Add a load of nodes to the database: … … 39 44 40 45 # Anonymous monk and perlquestions. 41 961, 46 961, 432878, 115, 42 47 ); 43 48 … … 71 76 72 77 # Check that we can get nodes by category name. 73 $mech->get_ok( '/rss/perlquestion.xml', 'perlquestion' ); 74 $mech->get_ok( '/rss/top.xml', 'top' );78 # $mech->get_ok( '/rss/perlquestion.xml', 'perlquestion' ); => 79 # $mech->get_ok( '/rss/top.xml', 'top' ); 75 80 76 # Check that user nodes work too. 81 my @tests = ( 82 { id => 961, cache_id => 961, nodes => [ 961, 508076, ], }, 83 { id => 'top', cache_id => 'top', nodes => [ 961, 432878, ], }, 84 { id => 'perlquestion', cache_id => 115, nodes => [ 432878, ], }, 85 ); 86 87 # Check that other types oF node work too. 88 foreach my $test (@tests) { 89 my $id = $test->{id}; 90 91 foreach my $node_id ( @{ $test->{nodes} } ) { 92 93 # diag "------------- id: $id, node_id: $node_id"; 94 95 my $cache_file = 96 PrlMnks->path_to_file( 'rss', $test->{cache_id}, 'xml' ); 97 ok !-e $cache_file, "not found $cache_file"; 98 $mech->get_ok("/rss/$id.xml"); 99 ok -e $cache_file, "found $cache_file"; 100 101 my $node = 102 PrlMnks::Node->new( 103 xml => scalar slurp "test_data/flat/$node_id-flat.xml" ); 104 ok $p->add_node($node), "added node '$id'"; 105 ok !-e $cache_file, "removed $cache_file"; 106 107 } 108 } 109 77 110 $mech->get_ok( '/rss/961.xml', 'anonymous monk: 961' ); # Anonymous monk. 78 111 $mech->content_contains( '/508245.html', "found child node" ); 79 112 80 # Delete all the rss. 81 my $rss_dir = PrlMnks->shared('rss'); 82 `rm -rf $rss_dir`; 113 { # Delete all the rss. 114 my $rss_dir = PrlMnks->shared('rss'); 115 `rm -rf $rss_dir`; 116 }
