/[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 164 by dpavlin, Thu Nov 24 22:29:29 2005 UTC revision 165 by dpavlin, Sat Nov 26 20:21:54 2005 UTC
# Line 4  use strict; Line 4  use strict;
4  use warnings;  use warnings;
5  use base 'Catalyst::Controller';  use base 'Catalyst::Controller';
6    
7    use Data::Dumper;
8    
9  =head1 NAME  =head1 NAME
10    
11  Webpacus::Controller::Editor - Catalyst Controller  Webpacus::Controller::Editor - AJAX template and CSS editor
12    
13  =head1 SYNOPSIS  =head1 SYNOPSIS
14    
15  See L<Webpacus>  See L<Webpacus>, L<WebPAC>
16    
17  =head1 DESCRIPTION  =head1 DESCRIPTION
18    
# Line 25  Catalyst Controller. Line 27  Catalyst Controller.
27  =cut  =cut
28    
29  sub default : Private {  sub default : Private {
30      my ( $self, $c ) = @_;          my ( $self, $c ) = @_;
31    
32            my $webpac = $c->comp('Model::WebPAC');
33            my $params = $c->req->params;
34            my $log = $c->log;
35    
36      my $webpac = $c->comp('Model::WebPAC');          my $template_filename =
37      my $params = $c->req->params;                  $c->req->params->{template_filename} ||
38      my $log = $c->log;                  $c->config->{webpac}->{default_template} ||
39                    $c->log->fatal("need default_template");
40    
41      $c->stash->{template} = 'editor.tt';          $c->stash->{template_filename} = $template_filename;
42    
43            $c->stash->{template} = 'editor.tt';
44  }  }
45    
46    =item template
47    
48    fetch template using C<template_filename> in request or
49    C<< webpac->default_template >>.
50    
51    =cut
52    
53  sub template : Local {  sub template : Local {
54          my ( $self, $c ) = @_;          my ( $self, $c ) = @_;
55    
56          my $template_file = $c->config->{webpac}->{default_template} || die("need default_template");          my $template_file =
57                    $c->req->params->{template_filename} ||
58                    $c->config->{webpac}->{default_template} ||
59                    $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_full_path = $webpac->{template_path} . "/$template_file";
64    
65            $c->log->debug("loading $template_full_path");
66    
67            if (! -r $template_full_path) {
68                    $c->log->warn("can't find '$template_full_path': $!");
69                    $c->res->output("can't find template '$template_full_path'");
70                    return;
71            }
72    
73          $c->stash->{'template_content'} =          $c->stash->{'template_content'} =
74                  $webpac->load_html( $template_full_path );                  $webpac->load_html( $template_full_path );
75    
76          $c->stash->{template} = 'editor/template.tt';          $c->stash->{template} = 'editor/template.tt';
77  }  }
78    
79    =item css
80    
81    =cut
82    
83  sub css : Local {  sub css : Local {
84          my ( $self, $c ) = @_;          my ( $self, $c ) = @_;
85    
86          my $css_file = $c->config->{webpac}->{default_css} || die("need default_css");          my $css_file = $c->config->{webpac}->{default_css} || die("need default_css");
87          my $css_path = $c->config->{webpac}->{css_path} || die("need css_path");          my $css_path = $c->config->{webpac}->{css_path} || die("need css_path");
88          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
89          $c->stash->{'css_content'} = $webpac->load_html( "$css_path/$css_file" );  
90            my $css_full_path = "$css_path/$css_file";
91    
92            $c->log->debug("loading $css_full_path");
93    
94            $c->stash->{'css_content'} = $webpac->load_html( $css_full_path );
95    
96          $c->stash->{template} = 'editor/css.tt';          $c->stash->{template} = 'editor/css.tt';
97  }  }
98    
99    =item record
100    
101    =cut
102    
103    sub record : Local {
104            my ( $self, $c ) = @_;
105    
106            $c->log->debug('record params '.Dumper($c->req->params));
107    
108            my $mfn = $c->req->params->{mfn};
109    
110            if (! $mfn) {
111                    $c->log->warn("no mfn, using 1");
112                    $mfn = 1;
113            }
114    
115            my $template_filename = $c->req->params->{template_filename};
116            if (! $template_filename) {
117                    $template_filename = $c->config->{webpac}->{default_template} || $c->log->fatal("no webpac->default_template in configuration!");
118                    $c->log->warn("no template_filename using $template_filename");
119            }
120    
121            my $webpac = $c->comp('Model::WebPAC');
122    
123            $c->res->output(
124                    $webpac->record( mfn => $mfn, template => $template_filename )
125            );
126    }
127    
128  =back  =back
129    
130    
131  =head1 AUTHOR  =head1 AUTHOR
132    
133  Dobrica Pavlinusic,,,  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
134    
135  =head1 LICENSE  =head1 LICENSE
136    

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

  ViewVC Help
Powered by ViewVC 1.1.26