annotate Lib/Engine/Output/Page.pm @ 23:716b287d4795

merge
author Sergey
date Wed, 30 Sep 2009 17:43:52 +0400
parents 03e58a454b20
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package Engine;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 our $Encoding;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 package Engine::Output::Page;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 use Common;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8 use DOM;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 sub Print {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11 my ($class,$Query,$Action) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 if (DOM::Site->can('LoadPage')) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14 my $pageId = $Action->RequestURI->path;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 DOM::Site->RegisterObject("Request",$Action);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 my $Page = DOM::Site->LoadPage($pageId);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17 print $Query->header(-status => 200);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 undef $@;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19 eval {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20 $Page->Properties->{Encoding} = $Engine::Encoding;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21 $Page->Render(*STDOUT);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 };
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23 if ($@) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24 print $Query->start_html('Error processing template');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 print $Query->p("Page: $pageId");
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 print $Query->p("Error: $@");
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 print $Query->end_html;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 } else {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 die new Exception('The site doesn\'t support page output');
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34 1;