Skip to content

Instantly share code, notes, and snippets.

@wittyfool
Created October 7, 2012 04:40
Show Gist options
  • Save wittyfool/3847122 to your computer and use it in GitHub Desktop.
Save wittyfool/3847122 to your computer and use it in GitHub Desktop.
pukiwikiで相対パスを使う方法 by mod_perl2 
package MyApache2::WikiRelpath;
use APR::Table();
use Apache2::Connection();
use Apache2::Filter ();
use Apache2::RequestRec ();
use Apache2::Const -compile => qw(OK);
use Data::Dumper;
my $READ_CHUNK_LENGTH = 2048;
my $output;
my $line;
sub handler {
my $f = shift;
my $hostname = $f->r->hostname();
my $content_type = $f->r->content_type();
unless($f->ctx){
$f->r->headers_out->unset('Content-Length');
$f->ctx(1);
# 初期化
$output = "";
}
while($f->read(my $buffer, $READ_CHUNK_LENGTH)){
$output .= $buffer;
}
if($f->seen_eos){
# ページの終了処理
if($content_type =~ /text\/html/){
$output =~ s|http://$hostname/|/|g;
}
$f->print($output);
}
return Apache2::Const::OK;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment