Update flavourpathinfo to use Blosxom::Debug.
[blosxom-plugins.git] / general / emptymessage
blob2baff87750e7a52e43583a2e886cd4936e017b8f
1 # Blosxom Plugin: emptymessage
2 # Author(s): Fletcher T. Penney http://fletcher.freeshell.org
3 # Version: 0.3
5 # Displays a message if there are no stories available in the 
6 # current directory or below.  Useful for preventing the empty
7 # page when someone enters an incorrect path
9 # Additionally, it gives an error if a partial path is entered, preventing
10 # something like /path/t matching /path/to/something
12 package emptymessage;
14 # --- Configurable variables -----
16 $message = qq!<h3><span class="header">I'm Sorry</span></h3>
17 <p>There are no stories to display here.  If you feel you have reached this page in error, please use the searchbox on the left to find what you are looking for.</p>
18 <p>If you have come here from an old link using a /weblog at the beginning, you can delete the weblog portion of the url and try again, or you can use the searchbox.</p>
19 <p>Thank You...</p>!;
21 $send_404 = 1;          # Set to 1 to send a 404 error instead.
23 $message_404 = "<!DOCTYPE HTML PUBLIC" . qq! "-//IETF//DTD HTML 2.0//EN">
24 <html>
25         <head>
26                 <title>404 Not Found</title>
27         </head>
28         <body>
29                 <h1>Not Found</h1>
30                 <p>The requested page does not exist... Please try another URL</p>
31         <p><a href="$blosxom::url">Return to home page</a>.</p>
32         </body>
33 </html>
36 # --------------------------------
38 use CGI qw/:standard/;
40 my $is_empty = 0;
42 sub start {
46 sub head {
47         my ($pkg, $currentdir, $head_ref) = @_;
48         my $empty = 0;
49         
50         $currentdir = "$blosxom::datadir/$currentdir";
51         $currentdir =~ s/\..*?$//;
52         $currentdir =~ s/\/$//;
53         
54         foreach my $file (keys %blosxom::files) {
55                 $empty = 1 if $file =~ /^$currentdir([\.\/].*)?$/;
56         }
57         
58         if ( $empty == 0 ) {
59                 if (! param('find')) {
60                         $$head_ref.= $message;
61                         $is_empty = 1;
62                 }
63         }
67 sub last {
68         if ( ( $send_404 ) && ( $is_empty ) ) {
69                 if (! param('recent')) {
70                         $blosxom::output = $message_404;
71                         print "Status: 404\n";
72                 }
73         }
74         1;