/[webpac2]/Webpacus/lib/Webpacus/Controller/Editor.pm
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 /Webpacus/lib/Webpacus/Controller/Editor.pm

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

revision 181 by dpavlin, Sun Nov 27 18:18:11 2005 UTC revision 271 by dpavlin, Sat Dec 17 03:19:58 2005 UTC
# Line 41  sub default : Private { Line 41  sub default : Private {
41    
42          $c->stash->{template_filename} = $template_filename;          $c->stash->{template_filename} = $template_filename;
43    
44            $c->stash->{databases} = $c->comp('Model::Databases')->list_inputs;
45    
46          $c->stash->{template} = 'editor.tt';          $c->stash->{template} = 'editor.tt';
47  }  }
48    
# Line 75  sub template : Local { Line 77  sub template : Local {
77                  if ($webpac->save_html( $template_full_path, $t )) {                  if ($webpac->save_html( $template_full_path, $t )) {
78                          $c->res->output("<span>saved $template_filename, $size bytes</span>");                          $c->res->output("<span>saved $template_filename, $size bytes</span>");
79                  } else {                  } else {
80                          $c->res->output("<span>error saving $template_filename!</span>");                          $c->res->output("<span class=\"error\">error saving $template_filename!</span>");
81                  }                  }
82                  return;                  return;
83          }          }
# Line 131  sub css : Local { Line 133  sub css : Local {
133                  if ($webpac->save_html( $css_full_path, $t )) {                  if ($webpac->save_html( $css_full_path, $t )) {
134                          $c->res->output("<span>saved $css_filename, $size bytes</span>");                          $c->res->output("<span>saved $css_filename, $size bytes</span>");
135                  } else {                  } else {
136                          $c->res->output("<span>error saving $css_filename!</span>");                          $c->res->output("<span class=\"error\">error saving $css_filename!</span>");
137                  }                  }
138                  return;                  return;
139          }          }
# Line 140  sub css : Local { Line 142  sub css : Local {
142    
143          $c->stash->{'css_content'} = $webpac->load_html( $css_full_path );          $c->stash->{'css_content'} = $webpac->load_html( $css_full_path );
144    
145            $c->stash->{'css_list'} = [ qw/user.css foobar.css/ ];
146    
147          $c->stash->{template} = 'editor/css.tt';          $c->stash->{template} = 'editor/css.tt';
148  }  }
149    
# Line 154  sub record : Local { Line 158  sub record : Local {
158    
159          $c->log->debug('record params '.Dumper($c->req->params));          $c->log->debug('record params '.Dumper($c->req->params));
160    
161          my $mfn = $c->req->params->{mfn};          my $record_uri = $c->req->params->{record_uri};
162            $record_uri ||= $c->config->{editor}->{default_record_uri} and
163          if (! $mfn) {                  $c->log->warn("using editor: default_record_uri");
164                  $c->log->warn("no mfn, using 1");  
165                  $mfn = 1;          if (! $record_uri) {
166                    $c->log->fatal("record called without record_uri and default_record_uri not found in config under editor");
167                    $c->stash->{error} = 'record retrival failed';
168                    $c->stash->{template} = 'error.tt';
169                    return;
170          }          }
171    
172          my $template_filename = $c->req->params->{template_filename};          my $template_filename = $c->req->params->{template_filename};
# Line 169  sub record : Local { Line 177  sub record : Local {
177    
178          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
179    
180          my $html = $webpac->record( mfn => $mfn, template => $template_filename );          my $html = $webpac->record( record_uri => $record_uri, template => $template_filename );
181    
182          if ($html) {          if ($html) {
183                  $c->log->debug('check html with tidy');                  $c->log->debug('check html with tidy');
# Line 211  __TIDY_CLOSE__ Line 219  __TIDY_CLOSE__
219                  } else {                  } else {
220                          $html .= qq{<div class="tidy tidy_error">Can't parse this record with HTML Tidy!</div>};                          $html .= qq{<div class="tidy tidy_error">Can't parse this record with HTML Tidy!</div>};
221                  }                  }
222            } else {
223                    $html .= qq{<div class="no_results">Can't find record</div>};
224          }          }
225                    
                   
226          $c->response->content_type('text/html; charset=utf-8');          $c->response->content_type('text/html; charset=utf-8');
227          $c->res->output( $html );          $c->response->body( $html );
228  }  }
229    
230    

Legend:
Removed from v.181  
changed lines
  Added in v.271

  ViewVC Help
Powered by ViewVC 1.1.26