41 |
|
|
42 |
$c->stash->{template_filename} = $template_filename; |
$c->stash->{template_filename} = $template_filename; |
43 |
|
|
44 |
|
$c->stash->{databases} = $c->config->{databases} or |
45 |
|
$c->log->fail("didn't find databases in config"); |
46 |
|
|
47 |
$c->stash->{template} = 'editor.tt'; |
$c->stash->{template} = 'editor.tt'; |
48 |
} |
} |
49 |
|
|
78 |
if ($webpac->save_html( $template_full_path, $t )) { |
if ($webpac->save_html( $template_full_path, $t )) { |
79 |
$c->res->output("<span>saved $template_filename, $size bytes</span>"); |
$c->res->output("<span>saved $template_filename, $size bytes</span>"); |
80 |
} else { |
} else { |
81 |
$c->res->output("<span>error saving $template_filename!</span>"); |
$c->res->output("<span class=\"error\">error saving $template_filename!</span>"); |
82 |
} |
} |
83 |
return; |
return; |
84 |
} |
} |
134 |
if ($webpac->save_html( $css_full_path, $t )) { |
if ($webpac->save_html( $css_full_path, $t )) { |
135 |
$c->res->output("<span>saved $css_filename, $size bytes</span>"); |
$c->res->output("<span>saved $css_filename, $size bytes</span>"); |
136 |
} else { |
} else { |
137 |
$c->res->output("<span>error saving $css_filename!</span>"); |
$c->res->output("<span class=\"error\">error saving $css_filename!</span>"); |
138 |
} |
} |
139 |
return; |
return; |
140 |
} |
} |
159 |
|
|
160 |
$c->log->debug('record params '.Dumper($c->req->params)); |
$c->log->debug('record params '.Dumper($c->req->params)); |
161 |
|
|
162 |
my $mfn = $c->req->params->{mfn}; |
my $record_uri = $c->req->params->{record_uri}; |
163 |
|
$record_uri ||= $c->config->{editor}->{default_record_uri} and |
164 |
if (! $mfn) { |
$c->log->warn("using editor: default_record_uri"); |
165 |
$c->log->warn("no mfn, using 1"); |
|
166 |
$mfn = 1; |
if (! $record_uri) { |
167 |
|
$c->log->fatal("record called without record_uri and default_record_uri not found in config under editor"); |
168 |
|
$c->stash->{error} = 'record retrival failed'; |
169 |
|
$c->stash->{template} = 'error.tt'; |
170 |
|
return; |
171 |
} |
} |
172 |
|
|
173 |
my $template_filename = $c->req->params->{template_filename}; |
my $template_filename = $c->req->params->{template_filename}; |
178 |
|
|
179 |
my $webpac = $c->comp('Model::WebPAC'); |
my $webpac = $c->comp('Model::WebPAC'); |
180 |
|
|
181 |
my $html = $webpac->record( mfn => $mfn, template => $template_filename ); |
my $html = $webpac->record( record_uri => $record_uri, template => $template_filename ); |
182 |
|
|
183 |
if ($html) { |
if ($html) { |
184 |
$c->log->debug('check html with tidy'); |
$c->log->debug('check html with tidy'); |
220 |
} else { |
} else { |
221 |
$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>}; |
222 |
} |
} |
223 |
|
} else { |
224 |
|
$html .= qq{<div class="no_results">Can't find record</div>}; |
225 |
} |
} |
226 |
|
|
|
|
|
227 |
$c->response->content_type('text/html; charset=utf-8'); |
$c->response->content_type('text/html; charset=utf-8'); |
228 |
$c->res->output( $html ); |
$c->response->body( $html ); |
229 |
} |
} |
230 |
|
|
231 |
|
|