/[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 165 by dpavlin, Sat Nov 26 20:21:54 2005 UTC revision 172 by dpavlin, Sun Nov 27 01:42:33 2005 UTC
# Line 53  C<< webpac->default_template >>. Line 53  C<< webpac->default_template >>.
53  sub template : Local {  sub template : Local {
54          my ( $self, $c ) = @_;          my ( $self, $c ) = @_;
55    
56          my $template_file =          my $template_filename =
57                  $c->req->params->{template_filename} ||                  $c->req->params->{template_filename} ||
58                  $c->config->{webpac}->{default_template} ||                  $c->config->{webpac}->{default_template} ||
59                  $c->log->fatal("need default_template");                  $c->log->fatal("need default_template");
60    
61          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
62    
63          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");
64    
65            my $template_full_path = "$template_path/$template_filename";
66    
67            if ($c->req->params->{save_template}) {
68                    my $t = $c->req->params->{template_content};
69                    my $size = length($t);
70                    $c->log->debug("saving $template_full_path, $size bytes");
71                    if ($webpac->save_html( $template_full_path, $t )) {
72                            $c->res->output("<span>saved $template_filename, $size bytes</span>");
73                    } else {
74                            $c->res->output("<span>error saving $template_filename!</span>");
75                    }
76                    return;
77            }
78    
79          $c->log->debug("loading $template_full_path");          $c->log->debug("loading $template_full_path");
80    
# Line 70  sub template : Local { Line 84  sub template : Local {
84                  return;                  return;
85          }          }
86    
87            # load template html
88          $c->stash->{'template_content'} =          $c->stash->{'template_content'} =
89                  $webpac->load_html( $template_full_path );                  $webpac->load_html( $template_full_path );
90    
91            # load template list
92    
93            opendir(my $d, $template_path) || $c->log->fatal("can't opendir '$template_path': $!");
94            my @templates = grep { /\.tt$/i } readdir($d);
95    
96            $c->stash->{template_list} = \@templates;
97            $c->stash->{template_filename} = $template_filename;
98    
99          $c->stash->{template} = 'editor/template.tt';          $c->stash->{template} = 'editor/template.tt';
100  }  }
101    
102  =item css  =item css
103    
104    Return css.
105    
106    B<Not finished>
107    
108  =cut  =cut
109    
110  sub css : Local {  sub css : Local {
111          my ( $self, $c ) = @_;          my ( $self, $c ) = @_;
112    
113          my $css_file = $c->config->{webpac}->{default_css} || die("need default_css");          my $css_filename = $c->config->{webpac}->{default_css} || die("need default_css");
114          my $css_path = $c->config->{webpac}->{css_path} || die("need css_path");          my $css_path = $c->config->{webpac}->{css_path} || die("need css_path");
115          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
116    
117          my $css_full_path = "$css_path/$css_file";          my $css_full_path = "$css_path/$css_filename";
118    
119            if ($c->req->params->{save_css}) {
120                    my $t = $c->req->params->{css_content};
121                    my $size = length($t);
122                    $c->log->debug("saving $css_full_path, $size bytes");
123                    if ($webpac->save_html( $css_full_path, $t )) {
124                            $c->res->output("<span>saved $css_filename, $size bytes</span>");
125                    } else {
126                            $c->res->output("<span>error saving $css_filename!</span>");
127                    }
128                    return;
129            }
130    
131          $c->log->debug("loading $css_full_path");          $c->log->debug("loading $css_full_path");
132    
# Line 98  sub css : Local { Line 137  sub css : Local {
137    
138  =item record  =item record
139    
140    Return html of record taking C<mfn> and C<template_filename> from request.
141    
142  =cut  =cut
143    
144  sub record : Local {  sub record : Local {
# Line 125  sub record : Local { Line 166  sub record : Local {
166          );          );
167  }  }
168    
 =back  
169    
170    
171    =back
172    
173  =head1 AUTHOR  =head1 AUTHOR
174    
175  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>

Legend:
Removed from v.165  
changed lines
  Added in v.172

  ViewVC Help
Powered by ViewVC 1.1.26