# Plugin name: notice
# Author: Shinra Kawasemi as Mitsuki
# Version: 1.0 19-Feb-2005
# Documentation: none. :(

package notice;
use strict;
use vars qw($notice $title $url $body);

use CGI qw(Delete param url);

# --- Configurable variables -----

my $notice_file = "notice.txt";

# --- Plug-in package variables --------


# --------------------------------

sub start {
  1;
}


sub filter {
  my ($pkg, $files) = @_;
  foreach my $path (keys %$files) {
    my ($dir, $file) = $path =~ m:(.*)/(.*):;
    
    if ($file eq $notice_file){
      $$files{$path} = 1;
    }
    if ($file =~ m/\.tail\.txt$/){
      $$files{$path} = 1;
    }
  }
  
  1;
 }

sub head {
  my($pkg, $path, $head_ref) = @_;
  my $notice_path = "$blosxom::datadir/$path/$notice_file";
  
  $url = "$blosxom::url/$path/$notice_file";
  $url =~ s/\.[^\.]+$//;
  $url .= ".$blosxom::flavour";
  
  if (-f $notice_path && param('page') <= 1){
    open(FH, $notice_path);
    chomp($title = <FH>);
    chomp($body = join '', <FH>);
    close(FH);
    
    $notice = &$blosxom::template($path, 'notice', $blosxom::flavour);
    $notice = &$blosxom::interpolate($notice);
  }
  
  1;
}

sub date{
  my ($pkg, $currentdir, $date_ref, $files, $dw,$mo,$mo_num,$da,$ti,$yr) = @_;
  
  if ($files == 1){
    $$date_ref = "<h2>Notes</h2>";
  }
  1;
}


1;

