<%shared>
my @contents;
my $request = $m->dhandler_arg;
my ($edicao, $pagina) = split /\//, $request;

my $dir = "/news/arquivo/$edicao";

my $index = "$dir/index.txt";
if ($m->comp_exists($index)){
	my $indextxt = $m->scomp($index);
	@contents = split /\n/, $indextxt;
}
my $filename;
if ($pagina){
	$filename = $pagina;
}else{
	$filename = $contents[1] . ".html";
}
$filename =	lc($m->comp("/_shared/procs/utils/get7bitstr.m", str=>$filename));
$filename =~ s/\ /_/g;	
$filename =~ s/\&/_/g;
</%shared>
<%init>
my $comp = "$dir/$filename";

if ($m->comp_exists($comp)){
	$m->comp($comp);
}else{
	$m->comp("/_shared/templates/messages/page_not_found.html");
}
</%init>

%#-------------------------------------------------------------
<%method header>
%#-------------------------------------------------------------
<%init>
my $title = (scalar @contents) ? shift @contents:'Newsletter GuiaNet';
</%init>
<& PARENT:header, title=>$title &>
<div style='background-color: #ecf1f3; border: solid 1px #ccc'>
<select class='form-select2' onChange="document.location='/news/<%$edicao%>/'+this.options[this.selectedIndex].value+'.html'">
% foreach my $page (@contents){
%	my $pfile =	lc($m->comp("/_shared/procs/utils/get7bitstr.m", str=>$page));
%	$pfile =~ s/\ /_/g;
%	$pfile =~ s/\&/_/g;
<option value='<%$pfile%>' <% $filename =~ /^$pfile/ ? 'selected':'' %>><%$page%>
% }
</select>	
</div>
</%method>
%#-------------------------------------------------------------
<%method footer>
%#-------------------------------------------------------------
<& PARENT:footer, selected=>$edicao &>
</%method>
