From 207441df6a60cff7e7f046f49c20d0427d7e4424 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 16 Nov 2005 15:33:12 +0000 Subject: [PATCH] r8900@llin: dpavlin | 2005-11-16 16:33:30 +0100 added CSS editor git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@67 07558da8-63fa-0310-ba24-9fe276d99e06 --- web/browse.cgi | 185 ++++++++++++++++++++++++++++++++++++++++--------- web/user.css | 9 +++ 2 files changed, 161 insertions(+), 33 deletions(-) create mode 100644 web/user.css diff --git a/web/browse.cgi b/web/browse.cgi index a5c0cee..f55749a 100755 --- a/web/browse.cgi +++ b/web/browse.cgi @@ -18,7 +18,8 @@ my $abs_path = abs_path($0); $abs_path =~ s#/[^/]*$#/../#; my $db_path = $abs_path . '/db/'; -my $template = 'html_ffzg.tt'; +my $template_file = 'html_ffzg.tt'; +my $css_file = 'user.css'; my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); my $iconv_loc = new Text::Iconv('UTF-8', 'ISO-8859-2'); @@ -41,6 +42,37 @@ my $rec = $q->param('rec') || 1; print $q->header( -charset => 'utf-8' ); +##---- some handy subs + +sub update_file($$) { + my ($path, $content) = @_; + + $content = $iconv_loc->convert( $content ) || die "no content?"; + + sub _conv_js { + my $t = shift || return; + return $iconv_loc->convert(chr(hex($t))); + } + $content =~ s/%u([a-fA-F0-9]{4})/_conv_js($1)/gex; + $content =~ s/[\n\r]+$//s; + + write_file($path . '.new', $content) || die "can't save ${path}.new $!"; + rename $path . '.new', $path || die "can't rename to $path: $!"; +} + +sub get_file_in_html($) { + my ($path) = @_; + + die "no path?" unless ($path); + + my $content = read_file($path) || die "can't read $path: $!"; + $content = $q->escapeHTML($iconv_utf8->convert($content)); + + return $content; +} + +##---- + if ($q->path_info =~ m#xml#) { my @ds = $db->load_ds($rec); @@ -49,7 +81,7 @@ if ($q->path_info =~ m#xml#) { print qq{ }, $iconv_utf8->convert( $out->apply( - template => $template, + template => $template_file, data => \@ds, ) ), qq{ @@ -84,31 +116,21 @@ if ($q->path_info =~ m#xml#) { } elsif ($q->path_info =~ m#template#) { - my @actions; + my $template_path = $out->{'include_path'} . '/' . $template_file; 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; - $tmpl =~ s/[\n\r]+$//s; - - 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: $!"; + update_file($template_path, $q->param('tt_template')); print qq{ - -$template saved + +$template_file saved @@ -117,14 +139,12 @@ iwfHideGentlyDelay('div_status', 2, 2000, 1); } - my $tmpl = read_file($out->{'include_path'} . '/' . $template) || die "can't read template $template: $!"; - $tmpl = $q->escapeHTML($iconv_utf8->convert($tmpl)); + my $tmpl = get_file_in_html($template_path); print qq{ -
}, Dumper($q->Vars), qq{
-
+ + +
+ +  idle +
+
+ +
@@ -152,19 +226,25 @@ iwfHideGentlyDelay('div_status', 2, 2000, 1); exit; } else { - print qq{ + print <<"_END_OF_HEAD_"; WebPAC simple browse interface + + + + + -db_path = $db_path
-template = $template
- -