Changeset 112
- Timestamp:
- 09/25/06 18:02:54 (2 years ago)
- Files:
-
- trunk/httpd-live.conf (modified) (1 diff)
- trunk/lib/PrlMnks/Daemon.pm (modified) (7 diffs)
- trunk/lib/PrlMnks/Template.pm (modified) (1 diff)
- trunk/t/plugin/search/search.t (modified) (2 diffs)
- trunk/t/template/template.t (modified) (1 diff)
- trunk/templates/rss/item.mason (modified) (2 diffs)
- trunk/templates/rss/list.mason (modified) (1 diff)
- trunk/templates/search/search.mason (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/httpd-live.conf
r111 r112 1 <VirtualHost egg.ecclestoad.co.uk>1 <VirtualHost *:80> 2 2 3 SetEnv PRLMNKS_BASE /home/evdb/sites/prlmnks 4 5 ServerName prlmnks.org 3 ServerName prlmnks.org 6 4 ServerAlias www.prlmnks.org 7 5 8 ScriptAliasMatch /.* /Users/evdb/sandbox/prlmnks-trunk/current/cgi/prlmnks.pl 9 10 ErrorLog /home/evdb/sites/prlmnks/shared/logs/error_log 11 LogLevel warn 6 SetEnv PRLMNKS_BASE /home/evdb/sites/prlmnks 7 ScriptAliasMatch /.* /home/evdb/sites/prlmnks/current/cgi/prlmnks.pl 12 8 13 9 CustomLog /home/evdb/sites/prlmnks/shared/logs/access_log combined 10 ErrorLog /home/evdb/sites/prlmnks/shared/logs/error_log 11 LogLevel warn 12 13 14 <Location /> 15 SetOutputFilter DEFLATE 16 17 BrowserMatch ^Mozilla/4 gzip-only-text/html 18 BrowserMatch ^Mozilla/4\.0[678] no-gzip 19 BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html 20 21 SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary 22 23 Header append Vary User-Agent env=!dont-vary 24 </Location> 14 25 15 26 </VirtualHost> trunk/lib/PrlMnks/Daemon.pm
r111 r112 47 47 48 48 if ( $self->fetch_node_by_id($high_id) ) { 49 $self->debug("Fetched $high_id\n"); 49 50 $success_count++; 50 51 $high_id++; … … 52 53 53 54 if ( $low_id && $self->fetch_node_by_id($low_id) ) { 55 $self->debug("Fetched $low_id\n"); 54 56 $success_count++; 55 57 $low_id--; … … 68 70 return if $self->delay_for_id($id); 69 71 70 $self->debug(" Fetching node $id.\n");72 $self->debug("\tFetching node $id.\n"); 71 73 72 74 # If the node is already in the database then return true 73 75 return 1 if PrlMnks::Node->have_db_entry_for_id($id); 74 76 75 my $node_xml = $self->get_xml_from_file($id) 76 || PrlMnks::PerlMonks->fetch_node_xml($id); 77 die "Could not fetch xml for '$id'" unless $node_xml; 77 my $xml = ''; 78 78 79 return $self->add_node_from_xml( $node_xml, $id ); 79 for ($xml) { 80 $xml = $self->get_xml_from_file($id); 81 $self->debug("\t\tFetched xml for $id from file\n") if $xml; 82 last if $xml; 83 84 $xml = PrlMnks::PerlMonks->fetch_node_xml($id); 85 $self->debug("\t\tFetched xml for $id from perlmonks\n") if $xml; 86 last if $xml; 87 88 die "Could not fetch xml for '$id'"; 89 } 90 91 return $self->add_node_from_xml( $xml, $id ); 80 92 } 81 93 … … 91 103 92 104 if ( $node && !$node->is_found ) { # don't store 404's 93 # we don't want to fetch this one again in a hurry. 105 106 # we don't want to fetch this one again in a hurry. 107 $self->debug("\t\tXML for $actual_id is '404'\n"); 94 108 $self->set_delay_for_id( PrlMnks->conf('scrape_long_interval'), 95 109 $actual_id ); … … 99 113 # write this xml to a file. 100 114 my $xml_file_name = PrlMnks::Node->xml_file_for_id($actual_id); 101 $self->debug("writing xml to '$xml_file_name'\n");102 115 PrlMnks::Utils->write_to_file( $xml_file_name, \$node_xml ); 116 $self->debug("\t\twrote xml for $actual_id to file\n"); 103 117 104 118 return 1 unless $node; # broken XML. … … 106 120 107 121 die "Could not save to db $node_xml" unless $node->save_to_db; 122 $self->debug("\t\tSaved xml for $actual_id to db\n"); 108 123 109 124 $self->run_plugins( … … 111 126 node => $node, 112 127 ); 128 $self->debug("\t\tRan plugins for $actual_id\n"); 113 129 114 130 return 1; trunk/lib/PrlMnks/Template.pm
r102 r112 162 162 } 163 163 164 sub base_url { 165 my $class = shift; 166 my @args = @_; 167 168 my $url = "http://"; 169 $url .= $ENV{SERVER_NAME}; 170 $url .= ":$ENV{SERVER_PORT}" 171 if $ENV{SERVER_PORT} 172 && $ENV{SERVER_PORT} != 80; 173 174 return join '/', $url, map { uri_escape($_) } @args; 175 } 176 164 177 1; trunk/t/plugin/search/search.t
r103 r112 15 15 } 16 16 17 # { # check that there are matches for 'scrabble'.18 # my $matches = PrlMnks::Plugin::Search->_get_matches('scrabble');19 # is_deeply $matches, {}, "no matches found";20 # }21 22 17 setup_scrabble_data( plugin => 'PrlMnks::Plugin::Search' ); 23 18 ok -e PrlMnks::Plugin::Search->search_index, "search index created"; 24 19 25 20 # check that there are matches for 'scrabble'. 26 my $search_data = PrlMnks::Plugin::Search->_get_matches('clarification', 1 ,10); 21 my $search_data = 22 PrlMnks::Plugin::Search->_get_matches( 'clarification', 1, 10 ); 27 23 my $results = $search_data->{results}; 28 24 is scalar @$results, 1, "one matches found"; … … 30 26 my $hit = $results->[0]; 31 27 is $hit->{node_id}, 508221, "Got correct node"; 28 29 # Check that some searches work as expected. 30 my $mech = test_mech(); 31 32 # no search 33 $mech->get_ok( '/search/', 'get /search/' ); 34 35 # search for 'scrabble' - 16 matches 36 $mech->submit_form( form_name => '', fields => { q => 'scrabble' } ); 37 $mech->content_contains( '1 to 16 of 16', 'got 16 results' ); trunk/t/template/template.t
r83 r112 24 24 25 25 is $$out_ref, $expected, "Templating works."; 26 27 # Check that the base_url works. 28 $ENV{SERVER_NAME} = 'server_name'; 29 $ENV{SERVER_PORT} = 1234; 30 is PrlMnks::Template->base_url( 'test', 'foo', 'bar' ), 31 "http://server_name:1234/test/foo/bar", "Got the correct url"; 32 33 $ENV{SERVER_NAME} = 'server_name'; 34 $ENV{SERVER_PORT} = 80; 35 is PrlMnks::Template->base_url( 'test', 'foo', 'bar' ), 36 "http://server_name/test/foo/bar", "Got the correct url"; trunk/templates/rss/item.mason
r102 r112 16 16 $author_name =~ s{[^ -~]+}{}g; 17 17 18 my $url = "/html/$node_data->{node_id}.html";18 my $url = $t->base_url("html","$node_data->{node_id}.html"); 19 19 20 20 </%perl> … … 22 22 <item> 23 23 <title><% $title | h %> (<% $author_name | h %>)</title> 24 <link><% $url %></link>25 <guid isPermaLink="true"><% $url %></guid>24 <link><% $url | h %></link> 25 <guid isPermaLink="true"><% $url | h %></guid> 26 26 27 27 <description> trunk/templates/rss/list.mason
r102 r112 15 15 <channel> 16 16 <title><% $title | h %></title> 17 <link> /html/<% $heading_node->{node_id} %>.html</link>17 <link><% $t->base_url('html', "$heading_node->{node_id}.html" ) | h %></link> 18 18 <description>RSS feeds from perlmonks.org</description> 19 19 <language>en</language> trunk/templates/search/search.mason
r107 r112 44 44 use List::MoreUtils qw( uniq ); 45 45 46 my $page_set = $vars->{page_set};47 my $url = "/search/?q=" . uri_escape( $search_string );48 $vars->{self_url} = $url;46 if ( my $page_set = $vars->{page_set} ) { 47 my $url = "/search/?q=" . uri_escape( $search_string ); 48 $vars->{self_url} = $url; 49 49 50 my @pages = uniq ( 1, @{$page_set->pages_in_set} , $page_set->last_page );50 my @pages = uniq ( 1, @{$page_set->pages_in_set} , $page_set->last_page ); 51 51 52 my $last_page = 1;53 foreach my $page_number ( @pages ) {52 my $last_page = 1; 53 foreach my $page_number ( @pages ) { 54 54 55 print "<li>…</li>\n" if $last_page < $page_number - 1;55 print "<li>…</li>\n" if $last_page < $page_number - 1; 56 56 57 my $anchor =58 $page_number == $page_set->current_page59 ? "<strong>$page_number</strong>"60 : "<a href=\"$url&page=$page_number\">$page_number</a>";57 my $anchor = 58 $page_number == $page_set->current_page 59 ? "<strong>$page_number</strong>" 60 : "<a href=\"$url&page=$page_number\">$page_number</a>"; 61 61 62 print "<li>$anchor</li>\n";62 print "<li>$anchor</li>\n"; 63 63 64 $last_page = $page_number; 64 $last_page = $page_number; 65 } 65 66 } 66 67 </%perl> … … 90 91 % } 91 92 92 % if ( my $ next_page = $vars->{page_set}->next_page) {93 % # <div class="search_pagination">93 % if ( my $page_set = $vars->{page_set} ) { 94 % if ( my $next_page = $vars->{page_set}->next_page ) { 94 95 <a href="<% $vars->{self_url} %>&page=<% $next_page %>">next</a> 95 % # </div>96 % } 96 97 % } 97 98
