X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=web%2Fbrowse.cgi;h=6f29b2ca30109defb290f2b4f7661ee1f75b8a6d;hb=f33cf123566e06671c6805361f0f7c1959f88af5;hp=54b32836b71809bad527e8e7ef2366cb32da1ba5;hpb=088ced45eeedf8f61cf17396010d4ea9b7d2a6c8;p=webpac2
diff --git a/web/browse.cgi b/web/browse.cgi
index 54b3283..6f29b2c 100755
--- a/web/browse.cgi
+++ b/web/browse.cgi
@@ -1,9 +1,13 @@
#!/usr/bin/perl -w
+use strict;
+
use Cwd qw/abs_path/;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Simple;
use File::Slurp;
+use Data::Dumper;
+use Text::Iconv;
use lib '../lib';
@@ -16,6 +20,9 @@ $abs_path =~ s#/[^/]*$#/../#;
my $db_path = $abs_path . '/db/';
my $template = 'html_ffzg.tt';
+my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8');
+my $iconv_loc = new Text::Iconv('UTF-8', 'ISO-8859-2');
+
my $db = new WebPAC::DB(
path => $db_path,
read_only => 1,
@@ -32,7 +39,7 @@ my $self = $q->url( '-path_info'=>1, '-query'=>0, '-full'=>0 );
my $rec = $q->param('rec') || 1;
-print $q->header;
+print $q->header( -charset => 'utf-8' );
if ($q->path_info =~ m#xml#) {
@@ -41,20 +48,19 @@ if ($q->path_info =~ m#xml#) {
if (@ds && $#ds > 0) {
print qq{
- }, $out->apply(
+ }, $iconv_utf8->convert( $out->apply(
template => $template,
data => \@ds,
- ), qq{
+ ) ), qq{
-
-
};
@@ -64,13 +70,12 @@ if ($q->path_info =~ m#xml#) {
Record $rec not found!
-
-
};
@@ -79,18 +84,71 @@ if ($q->path_info =~ m#xml#) {
} elsif ($q->path_info =~ m#template#) {
- my $tmpl = read_file($out->{'include_path'} . '/' . $template);
- $tmpl = $q->escapeHTML($tmpl);
+ my @actions;
+
+ if ($q->param('save_template')) {
+
+ my $tmpl = $iconv_loc->convert( $q->param('tt_template') ) || die "no template?";
+ sub _conv_js {
+ my $t = shift || return;
+ return $iconv_loc->convert(chr(hex($t)));
+ }
+ $tmpl =~ s/%u([a-fA-F0-9]{4})/_conv_js($1)/gex;
+
+ my $tmpl_file = $out->{'include_path'} . '/' . $template;
+ write_file($tmpl_file . '.new', $tmpl) || die "can't save $tmpl_file: $!";
+ rename $tmpl_file . '.new', $tmpl_file || die "can't rename to $tmpl_file: $!";
+
+ print qq{
+
+$template saved
+
+
+
+
+
+ };
+ exit;
+
+ }
+
+ my $tmpl = read_file($out->{'include_path'} . '/' . $template) || die "can't read template $template: $!";
+ $tmpl = $q->escapeHTML($iconv_utf8->convert($tmpl));
print qq{
-
+
+
-};
+ };
+
+ exit;
} else {
print qq{
@@ -112,6 +170,11 @@ function update_status(text) {
}
function load_rec(nr) {
+ if (nr == 1) {
+ iwfHide('a_left_arr', 1);
+ } else {
+ iwfShow('a_left_arr', 1);
+ }
update_status(nr+'...');
iwfRequest( url+'/xml/?rec='+nr, 'div_record' );
iwfOpacity('div_record', 30);
@@ -124,8 +187,10 @@ function inc_rec() {
}
function dec_rec() {
- rec--;
- load_rec(rec);
+ if (rec > 1) {
+ rec--;
+ load_rec(rec);
+ }
return false;
}
@@ -145,17 +210,19 @@ function init_page() {
db_path = $db_path
+template = $template