Apache-NNTPGateway
view release on metacpan or search on metacpan
NNTPGateway.pm view on Meta::CPAN
'fr' => "Retour",
},
'error' =>
{
'en' => "Error",
'fr' => "Erreur",
},
'long_format' =>
{
'en' => "Long format",
'fr' => "Format long",
},
'short_format' =>
{
'en' => "Short format",
'fr' => "Format court",
},
'msg_cite' =>
{
# format: article-id, from
'en' => "In article %s, %s wrote",
'fr' => "Dans l'article %s, %s écrivait",
},
'catchup_at' =>
{
# format: date-string
'en' => "Catchup at %s, done",
'fr' => "Catchup le %s, effectué",
},
'no_catchup' =>
{
'en' => "Catchup function not enabled for this server",
'fr' => "La fonction Catchup n'est pas active pour ce serveur",
},
'list_all' =>
{
'en' => "List all articles, even already read",
'fr' => "Liste de tous les articles, même déjà lus",
},
'list_new' =>
{
'en' => "List new articles",
'fr' => "Liste des nouveaux articles",
},
);
# All possibles actions
my %Actions_Map =
(
'list' => \&action_list,
'last' => \&action_last,
'read' => \&action_read,
'followup' => \&action_followup,
'post' => \&action_post,
'catchup' => \&action_catchup,
);
# Action shown in main menu
my %Menu_Entries_Map =
(
'list' => 1,
'last' => 1,
'post' => 1,
);
# Action that are posting actions....
my %Post_Actions_Map =
(
'post' => 1,
'followup' => 1,
);
# Unauthorized actions (configurable).
my %Disabled_Actions = ();
# Headers shown in headers=min
my %Used_Headers_Map =
(
'from' => 1,
'date' => 1,
'subject' => 1,
);
# Anonymous posters map (configurable).
my %Anonymous_Posters =
(
'anonymous' => 'Anonymous',
);
# Run time global vars:
# All keys are lowercase: see get_args()...
my $Args = {};
# Populated by get_config() ....
my %From_Posters = ();
my $The_Action = $DEFAULT_ACTION_NAME;
my $Title = $PKG_NAME;
my $NNTP_Server = $DEFAULT_NEWS_SERVER;
my $The_Newsgroup = undef;
my $The_GroupDescription = undef;
my $NewsUrl = "news://$NNTP_Server/$The_Newsgroup";
my $Base = '/';
my $StyleSheet = '';
my $Anonymous_Post_Allowed = 0;
my $Organization = $DEFAULT_ORGANIZATION;
my $Templates_Dir = $DEFAULT_TEMPLATES_DIR;
my $Catchup_Cookie_Name = undef;
my $The_User = '';
# Subs decl --------------------------------------------------------------
sub handler ( $ );
sub action_list ( $ );
sub action_catchup ( $ );
sub action_last ( $\$ );
NNTPGateway.pm view on Meta::CPAN
###
sub print_html_head ( $\@ ) {
my ( $r, $no_cache, $extra_title ) = @_;
my $title = $Title;
$title .= ": $extra_title" if $extra_title;
$r->content_type( 'text/html' );
# Goood, but some more efforts are needed ...
$r->no_cache($no_cache?1:0);
$r->send_http_header();
$r->print(
"\n\n${HTML_DTD}\n",
"<html>\n",
"<head>\n",
"<title>${title}</title>\n",
$StyleSheet?"<LINK REL=StyleSheet HREF=\"$StyleSheet\" TYPE=\"text/css\">":"<!-- no StyleSheet -->",
"</head>\n",
"<body bgcolor=\"$BODY_BGCOLOR\">\n",
"<a name=\"TOP\"> </a>\n",
"<hr noshade>\n",
"<div align=\"right\" class=\"head\"><font size=\"-1\">\n",
"\t<a href=\"$Base\">$PKG_NAME</a> \@ <a href=\"$NewsUrl\">$NewsUrl</a>\n",
"</font></div>\n",
"<h1 align=\"right\" class=\"title\"><a href=\"$Base\">${title}</a></h1>\n",
);
$r->print( "<h3 align=\"right\">($The_GroupDescription)</h3>\n" ) if $The_GroupDescription;
return;
} # end print_html_head();
### Sub print_html_foot() ###
# &print_html_foot( request ):
# - Description:
# - Arguments : the request
###
sub print_html_foot ( $ ) {
my ($r) = @_;
$r->print(
"<hr noshade>\n",
"<div align=\"right\" class=\"copyright\"><em><a href=\"$PKG_HOMEPAGE\">$PKG_COPYRIGHT</a></em></div>\n",
"<hr noshade>\n",
"</body></html>\n",
);
return;
} # end print_html_foot();
### Sub print_html_menu() ###
# &print_html_menu( request [, action] ):
# - Description:
# - Arguments : the request, the current action.
###
sub print_html_menu ( $\$ ) {
my ($r, $action) = @_;
$action ||= $The_Action;
$r->print( "\n<table width=\"100%\" align=\"center\"><tr><td bgcolor=\"$MENU_BGCOLOR\" align=\"center\">" );
foreach ( keys %Actions_Map ) {
next unless $Menu_Entries_Map{$_};
next if $Disabled_Actions{$_};
my $Aname = &message($_);
$Aname = $_ =~ s/^([a-z]{1,1})/uc( $1 )/e unless $Aname;
if ( $_ eq $action ) {
$r->print( "<font color=\"red\">[ ${Aname} ]</font>" );
} else {
$r->print( "<font color=\"blue\">[ <a href=\"${Base}/$_\">${Aname}</a> ]</font>" );
}
}
$r->print( "</td></tr></table>\n" );
return;
} # end print_html_menu();
### Sub print_html_error() ###
# $ret = &print_html_error( args ):
# - Description:
# - Arguments :
# - Return :
###
sub print_html_error ( $\$$$ ) {
my ($r, $h1, $err, $msg) = @_;
$h1 ||= &message('error');
$r->print(
"<h1 align=\"center\">$h1</h1>\n<p>",
$err?"<div align=\"center\" class=\"error\"><font color=\"red\"><strong>$err</strong></font></div><p>\n":"",
);
return;
} # end print_html_error();
### Sub to_html() ###
# $ret = &to_html( args ):
# - Description:
# - Arguments :
# - Return :
###
sub to_html ( $ ) {
my $v = shift;
$v =~ s/&/&/g;#this should be the 1st one!!
$v =~ s/</</g;
$v =~ s/>/>/g;
$v =~ s/\s+/ /g;
$v =~ s/\"/"/g;
return $v;
} # end to_html();
# NNTP Utilities ----------------------------------------------------
### Sub nntp_connect() ###
# status = &nntp_connect( request ):
# - Description: Try hardly to connect to the nntp server.
# - Arguments : the Apache request
( run in 2.645 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )