# Blosxom Plugin: notfound # Author(s): KITAMURA Akatsuki # Version: 2004-11-21 # Blosxom Home/Docs/Licensing: http://www.blosxom.com/ # This script is encoded in UTF-8. package notfound; use strict; # --- Configurable variables ----------- # Not Found出力を避けるフレーバーの拡張子(正規表現) # wikieditishで記事を新規追加する場合などで設定 my $flavour_re = '^wikieditish$'; # --- Plug-in package variables -------- # エントリ数 my $stories; # -------------------------------------- sub start { return 0 if ($blosxom::static_or_dynamic eq 'static'); return 0 if ($flavour_re && $blosxom::flavour =~ /$flavour_re/o); $stories = 0; 1; } sub story { $stories += 1; 1; } sub last { # 記事があったら復帰 $stories and return 1; # 記事が無かったら404 Not Foundを返す $blosxom::output = &default_404_page; $blosxom::header->{-status} = "404 Not Found"; $blosxom::header->{-type} = "text/html"; 1; } sub default_404_page { return <<__EOT__; 404 Not Found

Not Found

The requested URL $ENV{REQUEST_URI} was not found on this server.


@{[ $ENV{SERVER_SIGNATURE} || "
" . ( $ENV{SERVER_SOFTWARE} =~ m{(^\w+/[\d.]+)} )[0] . " Server at " . $ENV{SERVER_NAME} . " Port " . $ENV{SERVER_PORT} . "
" ]} __EOT__ # 註: signatureの部分がややこしくなっているのは、 # suEXEC環境で$ENV{SERVER_SIGNATURE}が # 定義されてないことがあったたため、その対処。 } 1; __END__ =head1 NAME Blosxom Plug-in: notfound =head1 SYNOPSIS 目的: 記事が無い場合にHTTPステータス "404 Not Found" を 返すためのプラグインです。 =head1 INSTALLATION このプラグインファイルをプラグインディレクトリ($plugin_dir)に 置いて下さい。 =head1 CONFIGURATION 記事が無くても404 Not Foundを返したくない場合、 例えばwikieditishプラグインを使って新規記事を追加するような 場合には、$flavour_re にNot Foundを返さなくするフレーバーの 拡張子を正規表現で設定して下さい。 my $flavour_re = '^wikieditish$'; my $flavour_re = '^(?:abc|def|ghi)$'; # abc or def or ghi =head1 VERSION 2004-11-21 =head1 AUTHOR 北村曉 (KITAMURA Akatsuki) , http://www.akatsukinishisu.net/ =head1 SEE ALSO Blosxom Home/Docs/Licensing: http://www.blosxom.com/ Blosxom Plugin Docs: http://www.blosxom.com/plugins/ =head1 LICENSE This Blosxom Plug-in Copyright (c) 2004, KITAMURA Akatsuki Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.