/[webpac2]/trunk/web/browse.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/web/browse.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 70 by dpavlin, Sat Nov 19 23:48:24 2005 UTC revision 72 by dpavlin, Sun Nov 20 01:50:47 2005 UTC
# Line 18  my $abs_path = abs_path($0); Line 18  my $abs_path = abs_path($0);
18  $abs_path =~ s#/[^/]*$#/../#;  $abs_path =~ s#/[^/]*$#/../#;
19    
20  my $db_path = $abs_path . '/db/';  my $db_path = $abs_path . '/db/';
21  my $template_file = 'html_ffzg.tt';  my $template_path = "$abs_path/conf/output/tt";
22    opendir(my $dir, $template_path) || die "can't open template path $template_path: $!";
23    my @templates = grep { /\.tt$/i } readdir($dir);
24  my $css_file = 'user.css';  my $css_file = 'user.css';
25    
26  my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8');  my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8');
# Line 31  my $db = new WebPAC::DB( Line 33  my $db = new WebPAC::DB(
33  );  );
34    
35  my $out = new WebPAC::Output::TT(  my $out = new WebPAC::Output::TT(
36          include_path => "$abs_path/conf/output/tt",          include_path => $template_path,
37          filters => { foo => sub { shift } },          filters => { foo => sub { shift } },
38  );  );
39    
# Line 39  my $q = new CGI::Simple; Line 41  my $q = new CGI::Simple;
41  my $self = $q->url( '-path_info'=>1, '-query'=>0, '-full'=>0 );  my $self = $q->url( '-path_info'=>1, '-query'=>0, '-full'=>0 );
42    
43  my $rec = $q->param('rec') || 1;  my $rec = $q->param('rec') || 1;
44    my $template_filename = $q->param('template') || $templates[0];
45    
46  print $q->header( -charset    => 'utf-8' );  print $q->header( -charset    => 'utf-8' );
47    
# Line 82  if ($q->path_info =~ m#xml#) { Line 85  if ($q->path_info =~ m#xml#) {
85                  print qq{<response>                  print qq{<response>
86  <action type='html' target='div_record' errorCode='' errorMessage='' >  <action type='html' target='div_record' errorCode='' errorMessage='' >
87                  }, $iconv_utf8->convert( $out->apply(                  }, $iconv_utf8->convert( $out->apply(
88                          template => $template_file,                          template => $template_filename,
89                          data => $ds,                          data => $ds,
90                  ) ), qq{                  ) ), qq{
91    
# Line 117  if ($q->path_info =~ m#xml#) { Line 120  if ($q->path_info =~ m#xml#) {
120    
121  } elsif ($q->path_info =~ m#template#) {  } elsif ($q->path_info =~ m#template#) {
122    
123                  my $template_path = $out->{'include_path'} . '/' . $template_file;                  my $template_path = $out->{'include_path'} . '/' . $template_filename;
124    
125                  if ($q->param('save_template')) {                  if ($q->param('save_template')) {
126    
# Line 125  if ($q->path_info =~ m#xml#) { Line 128  if ($q->path_info =~ m#xml#) {
128    
129                          print qq{<response>                          print qq{<response>
130  <action type='html' target='div_template_status' errorCode='' errorMessage='' >  <action type='html' target='div_template_status' errorCode='' errorMessage='' >
131  <tt>$template_file</tt> saved  <tt>$template_filename</tt> saved
132  </action>  </action>
133  <action type='js'>  <action type='js'>
134  <!--  <!--
# Line 227  iwfLog('loaded CSS template'); Line 230  iwfLog('loaded CSS template');
230                  exit;                  exit;
231    
232  } else {  } else {
233    
234            my $template_form = qq{
235                    <form action="$self" method="get" style="display: inline;">
236                    <select name="template">
237            };
238            foreach my $t (@templates) {
239                    my $s = '';
240                    $s = ' selected' if ($t eq $template_filename);
241                    $template_form .= qq{<option$s>$t</option>};
242            }
243            $template_form .= qq{
244                    </select>
245                    <input type="submit" name="ch_template" value="Switch"/>
246                    </form>
247            };
248    
249          print <<"_END_OF_HEAD_";          print <<"_END_OF_HEAD_";
250  <html>  <html>
251  <head>  <head>
# Line 243  iwfLog('loaded CSS template'); Line 262  iwfLog('loaded CSS template');
262    
263  var rec = $rec ;  var rec = $rec ;
264  var url = '$self';  var url = '$self';
265    var template_filename = '$template_filename';
266    
267  var css_rnd = 0;  var css_rnd = 0;
268    
# Line 258  function load_rec(nr) { Line 278  function load_rec(nr) {
278                  iwfShow('a_left_arr', 1);                  iwfShow('a_left_arr', 1);
279          }          }
280          update_status(nr+'...');          update_status(nr+'...');
281          iwfRequest( url+'/xml/?rec='+nr, 'div_record' );          iwfRequest( url+'/xml/?template='+template_filename+'&rec='+nr, 'div_record' );
282          iwfOpacity('div_record', 30);          iwfOpacity('div_record', 30);
283  }  }
284    
# Line 305  function init_page() { Line 325  function init_page() {
325          load_rec(rec);          load_rec(rec);
326    
327          // load template editor          // load template editor
328          iwfRequest( url+'/template/', 'div_template' );          iwfRequest( url+'/template/?template='+template_filename, 'div_template' );
329          // load css editor          // load css editor
330          iwfRequest( url+'/css/', 'div_css' );          iwfRequest( url+'/css/', 'div_css' );
331  }  }
# Line 319  function init_page() { Line 339  function init_page() {
339  </div>  </div>
340    
341  db_path = <tt>$db_path</tt><br/>  db_path = <tt>$db_path</tt><br/>
342  template = <tt>$template_file</tt><br/>  template = $template_form<br/>
343  css = <tt>$css_file</tt>  css = <tt>$css_file</tt>
344    
345  <div style="background: #e0e0e0; padding: 0.5em; display: block;">  <div style="background: #e0e0e0; padding: 0.5em; display: block;">

Legend:
Removed from v.70  
changed lines
  Added in v.72

  ViewVC Help
Powered by ViewVC 1.1.26