Changeset 112

Show
Ignore:
Timestamp:
09/25/06 18:02:54 (2 years ago)
Author:
evdb
Message:

Bug fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/httpd-live.conf

    r111 r112  
    1 <VirtualHost egg.ecclestoad.co.uk
     1<VirtualHost *:80
    22 
    3     SetEnv PRLMNKS_BASE      /home/evdb/sites/prlmnks 
    4  
    5     ServerName prlmnks.org 
     3    ServerName      prlmnks.org 
    64    ServerAlias www.prlmnks.org 
    75 
    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 
    128 
    139    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> 
    1425 
    1526</VirtualHost> 
  • trunk/lib/PrlMnks/Daemon.pm

    r111 r112  
    4747 
    4848        if ( $self->fetch_node_by_id($high_id) ) { 
     49            $self->debug("Fetched $high_id\n"); 
    4950            $success_count++; 
    5051            $high_id++; 
     
    5253 
    5354        if ( $low_id && $self->fetch_node_by_id($low_id) ) { 
     55            $self->debug("Fetched $low_id\n"); 
    5456            $success_count++; 
    5557            $low_id--; 
     
    6870    return if $self->delay_for_id($id); 
    6971 
    70     $self->debug("Fetching node $id.\n"); 
     72    $self->debug("\tFetching node $id.\n"); 
    7173 
    7274    # If the node is already in the database then return true 
    7375    return 1 if PrlMnks::Node->have_db_entry_for_id($id); 
    7476 
    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 = ''; 
    7878 
    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 ); 
    8092} 
    8193 
     
    91103 
    92104    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"); 
    94108        $self->set_delay_for_id( PrlMnks->conf('scrape_long_interval'), 
    95109            $actual_id ); 
     
    99113    # write this xml to a file. 
    100114    my $xml_file_name = PrlMnks::Node->xml_file_for_id($actual_id); 
    101     $self->debug("writing xml to '$xml_file_name'\n"); 
    102115    PrlMnks::Utils->write_to_file( $xml_file_name, \$node_xml ); 
     116    $self->debug("\t\twrote xml for $actual_id to file\n"); 
    103117 
    104118    return 1 unless $node;                # broken XML. 
     
    106120 
    107121    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"); 
    108123 
    109124    $self->run_plugins( 
     
    111126        node   => $node, 
    112127    ); 
     128    $self->debug("\t\tRan plugins for $actual_id\n"); 
    113129 
    114130    return 1; 
  • trunk/lib/PrlMnks/Template.pm

    r102 r112  
    162162} 
    163163 
     164sub 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 
    1641771; 
  • trunk/t/plugin/search/search.t

    r103 r112  
    1515} 
    1616 
    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  
    2217setup_scrabble_data( plugin => 'PrlMnks::Plugin::Search' ); 
    2318ok -e PrlMnks::Plugin::Search->search_index, "search index created"; 
    2419 
    2520# check that there are matches for 'scrabble'. 
    26 my $search_data = PrlMnks::Plugin::Search->_get_matches('clarification', 1 ,10); 
     21my $search_data = 
     22  PrlMnks::Plugin::Search->_get_matches( 'clarification', 1, 10 ); 
    2723my $results = $search_data->{results}; 
    2824is scalar @$results, 1, "one matches found"; 
     
    3026my $hit = $results->[0]; 
    3127is $hit->{node_id}, 508221, "Got correct node"; 
     28 
     29# Check that some searches work as expected. 
     30my $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  
    2424 
    2525is $$out_ref, $expected, "Templating works."; 
     26 
     27# Check that the base_url works. 
     28$ENV{SERVER_NAME} = 'server_name'; 
     29$ENV{SERVER_PORT} = 1234; 
     30is 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; 
     35is 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  
    1616    $author_name =~ s{[^ -~]+}{}g; 
    1717     
    18     my $url = "/html/$node_data->{node_id}.html"
     18    my $url = $t->base_url("html","$node_data->{node_id}.html")
    1919     
    2020</%perl> 
     
    2222<item> 
    2323    <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> 
    2626 
    2727    <description> 
  • trunk/templates/rss/list.mason

    r102 r112  
    1515    <channel> 
    1616        <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> 
    1818        <description>RSS feeds from perlmonks.org</description> 
    1919        <language>en</language> 
  • trunk/templates/search/search.mason

    r107 r112  
    4444    use List::MoreUtils qw( uniq ); 
    4545 
    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; 
    4949 
    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 ); 
    5151 
    52     my $last_page = 1; 
    53     foreach my $page_number ( @pages ) { 
     52        my $last_page = 1; 
     53        foreach my $page_number ( @pages ) { 
    5454 
    55         print "<li>&hellip;</li>\n" if $last_page < $page_number - 1; 
     55            print "<li>&hellip;</li>\n" if $last_page < $page_number - 1; 
    5656         
    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>"; 
     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>"; 
    6161 
    62         print "<li>$anchor</li>\n"; 
     62            print "<li>$anchor</li>\n"; 
    6363 
    64         $last_page = $page_number;     
     64            $last_page = $page_number;     
     65        } 
    6566    } 
    6667</%perl>         
     
    9091% } 
    9192 
    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 ) { 
    9495        <a href="<% $vars->{self_url} %>&amp;page=<% $next_page %>">next</a> 
    95 %#    </div> 
     96%   } 
    9697% } 
    9798