/[webpac2]/branches/Sack/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 /branches/Sack/web/browse.cgi

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

trunk/web/browse.cgi revision 68 by dpavlin, Wed Nov 16 15:49:22 2005 UTC branches/Sack/web/browse.cgi revision 1310 by dpavlin, Mon Sep 21 19:04:14 2009 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 72  sub get_file_in_html($) { Line 75  sub get_file_in_html($) {
75          return $content;          return $content;
76  }  }
77    
78    sub template_list_html($) {
79            my $current = shift || die;
80    
81            my $html = qq{ Template\n<ul> };
82    
83            foreach my $t (sort @templates) {
84                    if ($t eq $current) {
85                            $html .= qq{ <li><b>$t</b></li> };
86                    } else {
87                            $html .= qq{ <li><a href="#" onClick="load_template('$t'); return false;">$t</a></li> };
88                    }
89            }
90    
91            $html .= qq{ </ul> };
92            return $html;
93    }
94    
95  ##----  ##----
96    
97  if ($q->path_info =~ m#xml#) {  if ($q->path_info =~ m#xml#) {
98    
99          my @ds = $db->load_ds($rec);          my $ds = $db->load_ds($rec);
100    
101          if (@ds && $#ds > 0) {          if ($ds) {
102                  print qq{<response>                  print qq{<response>
103  <action type='html' target='div_record' errorCode='' errorMessage='' >  <action type='html' target='div_record' errorCode='' errorMessage='' >
104                  }, $iconv_utf8->convert( $out->apply(                  }, $iconv_utf8->convert( $out->apply(
105                          template => $template_file,                          template => $template_filename,
106                          data => \@ds,                          data => $ds,
107                  ) ), qq{                  ) ), qq{
108    
109  </action>  </action>
# Line 115  if ($q->path_info =~ m#xml#) { Line 135  if ($q->path_info =~ m#xml#) {
135                  exit;                  exit;
136          }          }
137    
138    } elsif ($q->path_info =~ m#template_list#) {
139    
140                    print qq{<response>
141    <action type='html' target='div_template_list' errorCode='' errorMessage='' >
142    <div>} . template_list_html($template_filename) . qq{</div>
143    </action>
144    </response>
145                    };
146    
147                    exit;
148    
149  } elsif ($q->path_info =~ m#template#) {  } elsif ($q->path_info =~ m#template#) {
150    
151                  my $template_path = $out->{'include_path'} . '/' . $template_file;                  my $template_path = $out->{'include_path'} . '/' . $template_filename;
152    
153                  if ($q->param('save_template')) {                  if ($q->param('save_template')) {
154    
# Line 125  if ($q->path_info =~ m#xml#) { Line 156  if ($q->path_info =~ m#xml#) {
156    
157                          print qq{<response>                          print qq{<response>
158  <action type='html' target='div_template_status' errorCode='' errorMessage='' >  <action type='html' target='div_template_status' errorCode='' errorMessage='' >
159  <tt>$template_file</tt> saved  <tt>$template_filename</tt> saved
160  </action>  </action>
161  <action type='js'>  <action type='js'>
162  <!--  <!--
# Line 158  $tmpl Line 189  $tmpl
189  -->  -->
190  &nbsp;&nbsp;<span id="div_template_status" style="color: #808080;">idle</span>  &nbsp;&nbsp;<span id="div_template_status" style="color: #808080;">idle</span>
191    
192  <input type='hidden' value='hidden post value' name='hidValue' />  <input type="hidden" name="template" value="$template_filename" />
193    
194  </form>  </form>
195  </action>  </action>
196  <action type='js'>  <action type='js'>
197  <!--  <!--
198    iwfOpacity('div_template', 100);
199  iwfHideGentlyDelay('div_template_status', 2, 2000, 1);  iwfHideGentlyDelay('div_template_status', 2, 2000, 1);
200  -->  -->
201  </action>  </action>
# Line 227  iwfLog('loaded CSS template'); Line 259  iwfLog('loaded CSS template');
259                  exit;                  exit;
260    
261  } else {  } else {
262    
263            my $template_list_html = template_list_html($template_filename);
264    
265          print <<"_END_OF_HEAD_";          print <<"_END_OF_HEAD_";
266  <html>  <html>
267  <head>  <head>
# Line 243  iwfLog('loaded CSS template'); Line 278  iwfLog('loaded CSS template');
278    
279  var rec = $rec ;  var rec = $rec ;
280  var url = '$self';  var url = '$self';
281    var template_filename = '$template_filename';
282    
283  var css_rnd = 0;  var css_rnd = 0;
284    
# Line 258  function load_rec(nr) { Line 294  function load_rec(nr) {
294                  iwfShow('a_left_arr', 1);                  iwfShow('a_left_arr', 1);
295          }          }
296          update_status(nr+'...');          update_status(nr+'...');
297          iwfRequest( url+'/xml/?rec='+nr, 'div_record' );          iwfRequest( url+'/xml/?template='+template_filename+'&rec='+nr, 'div_record' );
298          iwfOpacity('div_record', 30);          iwfOpacity('div_record', 30);
299  }  }
300    
# Line 293  function edit_css() { Line 329  function edit_css() {
329          return false;          return false;
330  }  }
331    
332    function load_template(name) {
333            iwfLog('changing template to '+name);
334            iwfOpacity('div_template', 30);
335            template_filename = name;
336            // load template editor
337            iwfRequest( url+'/template/?template='+template_filename, 'div_template' );
338            load_rec(rec);
339    
340            // refresh template list
341            iwfRequest( url+'/template_list/?template='+template_filename, 'div_template_list' );
342    }
343    
344  function init_page() {  function init_page() {
345          iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css'));          iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css'));
346          iwfLog('div_template = ' + iwfX('div_template') + ':' + iwfY('div_template'));          iwfLog('div_template = ' + iwfX('div_template') + ':' + iwfY('div_template'));
# Line 302  function init_page() { Line 350  function init_page() {
350    
351          iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css'));          iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css'));
352    
353          load_rec(rec);          // load template editor and record
354            load_template(template_filename);
355    
         // load template editor  
         iwfRequest( url+'/template/', 'div_template' );  
356          // load css editor          // load css editor
357          iwfRequest( url+'/css/', 'div_css' );          iwfRequest( url+'/css/', 'div_css' );
358  }  }
# Line 319  function init_page() { Line 366  function init_page() {
366  </div>  </div>
367    
368  db_path = <tt>$db_path</tt><br/>  db_path = <tt>$db_path</tt><br/>
 template = <tt>$template_file</tt><br/>  
369  css = <tt>$css_file</tt>  css = <tt>$css_file</tt>
370    
371  <div style="background: #e0e0e0; padding: 0.5em; display: block;">  <div style="background: #e0e0e0; padding: 0.5em; display: block;">
# Line 332  css = <tt>$css_file</tt> Line 378  css = <tt>$css_file</tt>
378    
379  </div>  </div>
380    
381    
382    <div id="div_template_list" style="display: inline; border: 2px solid #ffcc88; float: right; z-index: 10;">
383    $template_list_html
384    </div>
385    
386  <div>  <div>
387    
388  <div style="display: block;">  <div style="border: 2px solid #ffff80;">
389    
390  Editor  Editor
391  <a id="a_template" href="#" onClick="return edit_template();">template</a>  <a id="a_template" href="#" onClick="return edit_template();">template</a>
392  <a id="a_css" href="#" onClick="return edit_css();">css</a>  <a id="a_css" href="#" onClick="return edit_css();">css</a>
393    
394    
395  <div id="div_template">  <div id="div_template">
396  <span style="color: #808080;"> no template loaded yet. </span>  <span style="color: #808080;"> no template loaded yet. </span>
397  </div>  </div>

Legend:
Removed from v.68  
changed lines
  Added in v.1310

  ViewVC Help
Powered by ViewVC 1.1.26