--- Webpacus/lib/Webpacus/Controller/Editor.pm 2005/11/26 20:21:54 165
+++ Webpacus/lib/Webpacus/Controller/Editor.pm 2005/11/27 01:42:33 172
@@ -53,14 +53,28 @@
sub template : Local {
my ( $self, $c ) = @_;
- my $template_file =
+ my $template_filename =
$c->req->params->{template_filename} ||
$c->config->{webpac}->{default_template} ||
$c->log->fatal("need default_template");
my $webpac = $c->comp('Model::WebPAC');
- my $template_full_path = $webpac->{template_path} . "/$template_file";
+ my $template_path = $webpac->{template_path} || $c->log->fatal("can't find template_path in Model::WebPAC");
+
+ my $template_full_path = "$template_path/$template_filename";
+
+ if ($c->req->params->{save_template}) {
+ my $t = $c->req->params->{template_content};
+ my $size = length($t);
+ $c->log->debug("saving $template_full_path, $size bytes");
+ if ($webpac->save_html( $template_full_path, $t )) {
+ $c->res->output("saved $template_filename, $size bytes");
+ } else {
+ $c->res->output("error saving $template_filename!");
+ }
+ return;
+ }
$c->log->debug("loading $template_full_path");
@@ -70,24 +84,49 @@
return;
}
+ # load template html
$c->stash->{'template_content'} =
$webpac->load_html( $template_full_path );
+ # load template list
+
+ opendir(my $d, $template_path) || $c->log->fatal("can't opendir '$template_path': $!");
+ my @templates = grep { /\.tt$/i } readdir($d);
+
+ $c->stash->{template_list} = \@templates;
+ $c->stash->{template_filename} = $template_filename;
+
$c->stash->{template} = 'editor/template.tt';
}
=item css
+Return css.
+
+B
+
=cut
sub css : Local {
my ( $self, $c ) = @_;
- my $css_file = $c->config->{webpac}->{default_css} || die("need default_css");
+ my $css_filename = $c->config->{webpac}->{default_css} || die("need default_css");
my $css_path = $c->config->{webpac}->{css_path} || die("need css_path");
my $webpac = $c->comp('Model::WebPAC');
- my $css_full_path = "$css_path/$css_file";
+ my $css_full_path = "$css_path/$css_filename";
+
+ if ($c->req->params->{save_css}) {
+ my $t = $c->req->params->{css_content};
+ my $size = length($t);
+ $c->log->debug("saving $css_full_path, $size bytes");
+ if ($webpac->save_html( $css_full_path, $t )) {
+ $c->res->output("saved $css_filename, $size bytes");
+ } else {
+ $c->res->output("error saving $css_filename!");
+ }
+ return;
+ }
$c->log->debug("loading $css_full_path");
@@ -98,6 +137,8 @@
=item record
+Return html of record taking C and C from request.
+
=cut
sub record : Local {
@@ -125,9 +166,10 @@
);
}
-=back
+=back
+
=head1 AUTHOR
Dobrica Pavlinusic, C<< >>