/[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 49 by dpavlin, Mon Nov 14 16:15:27 2005 UTC revision 54 by dpavlin, Mon Nov 14 16:16:57 2005 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3    use strict;
4    
5  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
6  use CGI::Carp qw(fatalsToBrowser);  use CGI::Carp qw(fatalsToBrowser);
7  use CGI::Simple;  use CGI::Simple;
8  use File::Slurp;  use File::Slurp;
9    use Data::Dumper;
10    use Text::Iconv;
11    
12  use lib '../lib';  use lib '../lib';
13    
# Line 16  $abs_path =~ s#/[^/]*$#/../#; Line 20  $abs_path =~ s#/[^/]*$#/../#;
20  my $db_path = $abs_path . '/db/';  my $db_path = $abs_path . '/db/';
21  my $template = 'html_ffzg.tt';  my $template = 'html_ffzg.tt';
22    
23    my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8');
24    my $iconv_loc = new Text::Iconv('UTF-8', 'ISO-8859-2');
25    
26  my $db = new WebPAC::DB(  my $db = new WebPAC::DB(
27          path => $db_path,          path => $db_path,
28          read_only => 1,          read_only => 1,
# Line 32  my $self = $q->url( '-path_info'=>1, '-q Line 39  my $self = $q->url( '-path_info'=>1, '-q
39    
40  my $rec = $q->param('rec') || 1;  my $rec = $q->param('rec') || 1;
41    
42  print $q->header;  print $q->header( -charset    => 'utf-8' );
43    
44  if ($q->path_info =~ m#xml#) {  if ($q->path_info =~ m#xml#) {
45    
# Line 79  if ($q->path_info =~ m#xml#) { Line 86  if ($q->path_info =~ m#xml#) {
86    
87  } elsif ($q->path_info =~ m#template#) {  } elsif ($q->path_info =~ m#template#) {
88    
89                  my $tmpl = read_file($out->{'include_path'} . '/' . $template);                  my @actions;
90                  $tmpl = $q->escapeHTML($tmpl);  
91                    if ($q->param('save_template')) {
92    
93                            my $tmpl = $q->param('tt_template') || die "no template?";
94                            my $tmpl_file = $out->{'include_path'} . '/' . $template;
95                            write_file($tmpl_file . '.new', $iconv_loc->convert($tmpl)) || die "can't save $tmpl_file: $!";
96                            rename $tmpl_file . '.new', $tmpl_file || die "can't rename to $tmpl_file: $!";
97    
98                            print qq{<response>
99    <action type='html' target='div_status' errorCode='' errorMessage='' >
100    $template saved
101    </action>
102    <action type='js'>
103    <!--
104    reload_rec();
105    -->
106    </action>
107    </response>
108                            };
109                            exit;
110    
111                    }
112    
113                    my $tmpl = read_file($out->{'include_path'} . '/' . $template) || die "can't read template $template: $!";
114                    $tmpl = $q->escapeHTML($iconv_utf8->convert($tmpl));
115    
116                  print qq{<response>                  print qq{<response>
117  <action type='html' target='div_template' errorCode='' errorMessage='' >  <action type='html' target='div_template' errorCode='' errorMessage='' >
118  <textarea name="tt_template" cols="80" rows="10">  <pre>}, Dumper($q->Vars), qq{</pre>
119    
120    <form name="frmEditor" action="$self" method="post"
121    iwfTarget="div_status"
122    >
123    
124    <textarea name="tt_template" cols="80" rows="10" style="display: block;">
125  $tmpl  $tmpl
126  </textarea>  </textarea>
127  <br/><input type="button" name="save" value="Save">  
128    <br/>
129    <input type="button" name="save_template" value="Save" onclick="javascript:iwfRequest(this);" />
130    <input type="checkbox" name="checkin_template" id="checkin_checkbox" label="checkin" />
131    <span id="div_status" style="color: #808080;">idle</span>
132    
133    <input type='hidden' value='hidden post value' name='hidValue' />
134    
135    </form>
136  </action>  </action>
137  </response>  </response>
138  };                  };
139    
140                    exit;
141    
142  } else {  } else {
143          print qq{          print qq{
# Line 145  function init_page() { Line 192  function init_page() {
192  <body onload="init_page();">  <body onload="init_page();">
193    
194  db_path = <tt>$db_path</tt><br/>  db_path = <tt>$db_path</tt><br/>
195    template = <tt>$template</tt><br/>
196    
197  <div id="iwfLog" style="display: none;">  <div id="iwfLog" style="display: none;">
198  </div>  </div>
# Line 156  db_path = <tt>$db_path</tt><br/> Line 204  db_path = <tt>$db_path</tt><br/>
204          <a href="$self?rec=}, $rec + 1, qq{" onClick="return inc_rec();">&#8680;</a>&nbsp;          <a href="$self?rec=}, $rec + 1, qq{" onClick="return inc_rec();">&#8680;</a>&nbsp;
205          <a href="$self?rec=}, $rec, qq{" onClick="return reload_rec();">&#8634;</a>&nbsp;          <a href="$self?rec=}, $rec, qq{" onClick="return reload_rec();">&#8634;</a>&nbsp;
206          <a href="#" onClick="iwfRefreshLog(); return false;">&#9636;</a>&nbsp;          <a href="#" onClick="iwfRefreshLog(); return false;">&#9636;</a>&nbsp;
207    
208  </div>  </div>
209    
210  <div id="div_template">  <div id="div_template">

Legend:
Removed from v.49  
changed lines
  Added in v.54

  ViewVC Help
Powered by ViewVC 1.1.26