X-Git-Url: https://git.jankratochvil.net/?p=MyWeb.git;a=blobdiff_plain;f=Web.pm;fp=Web.pm;h=d84cadc17461d294fa3be4ef82bad9d6bfe9ddb8;hp=3ef46cf8884f1d5baa77d5698106d900ae20e606;hb=e8d9508cb8e92d8672b75e888cfa5119ccc690c3;hpb=aa4afc6bfb9d83e2b1bc55637b46bce3a6821b61 diff --git a/Web.pm b/Web.pm index 3ef46cf..d84cadc 100644 --- a/Web.pm +++ b/Web.pm @@ -31,7 +31,7 @@ our @EXPORT=qw( &Wrequire &Wuse &path_web &path_abs_disk &uri_escaped - &a_href &a_href_cc + &a_href &a_href_cc &text_cc &vskip &img ¢erimg &rightimg &leftimg $W @@ -891,6 +891,14 @@ sub remote_ip () return $r; } +sub _cc() +{ + my $r; + $r||=Geo::IP->new()->country_code_by_addr(remote_ip()) if $have_Geo_IP; + $r||=""; + return $r; +} + # $url={"JP"=>"http://specific",...}; # $url={""=>"http://default",...}; sub a_href_cc($$;%) @@ -899,14 +907,20 @@ my($url,$contents,%args)=@_; # A bit ineffective but we must process all the possibilities to get stable 'headers_in' hits! my %map=map(($_=>a_href($url->{$_},$contents,%args)),keys(%$url)); - my $cc; - $cc||=Geo::IP->new()->country_code_by_addr(remote_ip()) if $have_Geo_IP; - $cc||=""; - my $r=$map{$cc}; + my $r=$map{_cc()}; return $r if $r; return $contents; } +# $tree={"JP"=>"specific",...}; +# $tree={""=>"default",...}; +sub text_cc($) +{ +my($tree)=@_; + + return $tree->{_cc()}; +} + sub make ($) { my($cmd)=@_;