--- Webpacus/lib/Webpacus/Model/WebPAC.pm 2005/11/26 20:21:54 165 +++ Webpacus/lib/Webpacus/Model/WebPAC.pm 2005/11/27 05:07:01 178 @@ -68,9 +68,14 @@ $self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } ); - my $db_path = $c->config->{webpac}->{db_path}; - my $template_path = $c->config->{webpac}->{template_path}; - $self->{template_path} = $template_path; + # save config parametars in object + foreach my $f (qw/db_path template_path hits_on_page/) { + $self->{$f} = $c->config->{hyperestraier}->{$f} || + $c->config->{webpac}->{$f}; + $log->debug("self->{$f} = " . $self->{$f}); + } + my $db_path = $self->{db_path}; + my $template_path = $self->{template_path}; $log->debug("using db path '$db_path', template path '$template_path'"); @@ -99,11 +104,6 @@ "'" ); - # save config parametars in object - foreach my $f (qw/hits_on_page/) { - $self->{$f} = $c->config->{hyperestraier}->{$f}; - $log->debug("self->{$f} = " . $self->{$f}); - } return $self; @@ -119,13 +119,14 @@ sub iconv_on_save { my $self = shift; + my $content = shift || return; $self->{iconv_save} ||= new Text::Iconv( $self->config->{webpac}->{out_encoding}, $self->config->{webpac}->{webpac_encoding}, ); - $self->{iconv_save}->convert( @_ ); + return $self->{iconv_save}->convert( $content ); } @@ -287,8 +288,6 @@ sub save_html { my ($self, $path, $content) = @_; - $content = $self->iconv_on_save( $content ) || die "no content?"; - sub _conv_js { my $t = shift || return; return $self->{iconv}->convert(chr(hex($t))); @@ -297,6 +296,16 @@ $content =~ s/^[\n\r]+//s; $content =~ s/[\n\r]+$/\n/s; + my $iconv_on_save = new Text::Iconv( + $self->config->{webpac}->{out_encoding}, + $self->config->{webpac}->{webpac_encoding}, + ); + $self->{log}->debug( "content BEFORE : $content" ); + no utf8; + $content = $iconv_on_save->convert( $content ) || die "no content?"; + + $self->{log}->debug( "content AFTER: $content" ); + write_file($path . '.new', $content) || die "can't save ${path}.new $!"; rename $path . '.new', $path || die "can't rename to $path: $!"; }