Apache-NNTPGateway

 view release on metacpan or  search on metacpan

NNTPGateway.pm  view on Meta::CPAN

  $r->log->info( "Executing action $The_Action ..." ) if $DEBUG;
  &{$Actions_Map{$The_Action}}( $r );

  return OK; 
} # handler() ends here...




# Actions -----------------------------------------------------------


### Sub action_list() ###
# &action_list( request ):
# - Description: List all articles in the group ...
# - Arguments  : the Apache request
###
sub action_list  ( $ ) {
  my ($r) = @_;

  # Print html headers, do not cache list.
  &print_html_head( $r, 1 );
  # Print menu
  &print_html_menu( $r );

  my $force = &is_true( $Args->{force} );  
  unless ( $force ) {
    # Check range of articles to display, see get_args() for cookies
    # parsing, and action_catchup for cookies setting.
    my $catchupdate = $Args->{catchup_date};
    my $catchupid   = $Args->{catchup_id};
    my $rnews       = undef;
    $rnews = $NNTP->newnews( $catchupdate, $The_Newsgroup ) if $catchupdate;
    if ( $rnews ) {
      $r->log->info( "New news: ", @$rnews, ", since $catchupdate" ) if $DEBUG;
      # Things to do here, HELP ME! I have no way to test this feature
      # as the newnews command had been disabled by the newsserver
      # administrator here...
      #$Args->{first_art} = $rnews->[0]???
      $Args->{first_art} = $catchupid +1;
    } elsif ( $catchupid ) {
      # The main reason to get here is that the newsserver
      # administrator disabled the newnews command, villain!
      $Args->{first_art} = $catchupid +1;
    }
  }
  my $first_art = $Args->{first_art};
  my $last_art  = $Args->{last_art};
  my $n_arts    = ($last_art - $first_art) +1;
  $r->log->notice( "Listing $n_arts articles from $first_art to $last_art..." ) if $DEBUG;

  if ( $n_arts > 0 ) {

    # Some articles to display...
    &print_html_list_menu( $r, $n_arts );
    $r->print( "\n<hr noshade>\n" );
    my $i = $first_art;
    for ( ; $i <= $last_art; $i++ ) {
      # All articles are got now one by one from the newsserver,
      # remember this is not a real newsreader we will not build
      # threads trees here we've no time for that. But a powerful
      # patch to do that will be welcome anyway ;-)
      my $Article = &nntp_get_article( $i, 1 );
      if ( $Article ) {
        &print_html_article( $r, $Article, 1, &is_true( $Args->{long} ));
      } else {
        $r->print( "<span id=\"bad_id\"><strong>", &message('no_id', $i ), "</strong></span><br>\n" );
      }
    }
    # Print the list menu
    $r->print( "\n<hr noshade>\n" );
    &print_html_list_menu( $r, $n_arts );

  } else {

    # No articles to display...
    &print_html_list_menu( $r, $n_arts );

  }

  # Print global menu
  &print_html_menu( $r );
  # Print html footer
  &print_html_foot( $r );
  return;

} # end action_list();


### Sub action_catchup() ###
# &action_catchup( request ):
# - Description: Mark all articles in the group as read.
# - Arguments  : the Apache request
###
sub action_catchup ( $ ) {
  my ($r) = @_;
  
  # Prepare catchup...
  my $catchupid   = $Args->{last_art};
  my $catchupdate = $NNTP->date();
  my $newnewsok   = $NNTP->newnews( $catchupdate, $The_Newsgroup )?1:0;

  # Build the catchup cookie
  my $cookie      = new CGI::Cookie 
    ( 
     -name    => $Catchup_Cookie_Name, 
     -value   => "Id=${catchupid},Date=${catchupdate}", 
     # 10 years should be enough as expiration date.
     -expires => '+10y', 
     -domain  => $COOKIE_DOMAIN, 
     -path    => $Base
    );
  $r->header_out( 'Set-Cookie' => $cookie );

  # Print html header
  &print_html_head( $r, 1 );
  # Print menu
  &print_html_menu( $r );
  $r->print( "\n<hr noshade>\n" );

  # Just Inform user

NNTPGateway.pm  view on Meta::CPAN

 * Article id or subject added to title in read.
 * More CSS classes everywhere... read the sources.
 * use Apache::Log qw(); to access to log functions.
 * Makefile.PL improved to really check used modules versions.
 * Call  Net::Cmd functions in a  clean manner to make perl  5.6 happy (end of
   that Bareword "CMD_ERROR" install bug).

=item v0.8

 * Cookie domain better handled for catchup.
 * NNTPGatewayNewsGroupTest   removed.  Set  up    a  new  Location  and   set
   NNTPGatewayNewsGroup to  the test group and  NNTPGatewayDebug on to achieve
   the same functionality.
 * Some       more       directives   to       control        users   checking
   (NNTPGatewayUsersNamesCaseInsensitive, NNTPGatewayNonLocalPostOk).
 * Some handling of Cache-Control.
 * Made this module ready for my first CPAN contribution ;-)
 ** Cleaning source code.
 ** Cleaning Documentation.
 ** CPAN  Enabled distrib (Makefile.PL,   .tar.gz dist,  README file, CPAN  ID
    ...).

=item v0.7

 * The configuration directive B<NNTPGatewayCatchupCookieName> do not exists anymore.
 * Disconnections to news server start to be better handled.

=item v0.6

 First public release

=back


=head1 TODO

=over 4

=item *

 Safe sharing of the NNTP global.

=item *

 Keeping into account the If-Modified-Since, Last-Modified and so on ... stuff.

=item *

 Using an HTML Template system (maybe HTML::Template) instead of hard coded html.

=item *

 Improving the LANG selection stuff (maybe adding a new configuration directive?)

=item *

 Improving the C<check_user()> stuff for more security.

=item *

 Integrating Jie Gao threaded view of articles list.

=item *

 more stuff ...

=back


=head1 THANKS

 Thanks a lot to these people for they help:

=over 4

=item * Jie Gao <J.Gao@isu.usyd.edu.au>
 For his help to build a clean installation of the module.

=back


=head1 SEE ALSO

 perl(1), mod_perl(3), Apache(3), Net::NNTP(3), Net::Domain(3),
 Net::Config(3), rfc9771, getpwnam(3)


=head1 COPYRIGHT

 The application and accompanying modules are Copyright  CENA Toulouse.  It is
 free software and can be used, copied and  redistributed at the same terms as
 perl itself.


=head1 AUTHOR

 heddy Boubaker <boubaker@cpan.org>

 Home page:
 http://www.tls.cena.fr/~boubaker/WWW/Apache-NNTPGateway.shtml

=cut

### NNTPGateway.pm ends here  ----------------------------------------------



( run in 0.698 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )