-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build
171 lines (132 loc) · 4.26 KB
/
Build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
mkdir -p /srv/www/catalyst/icb/ICB/extlib
cd /srv/www/catalyst/icb
git init
cd ICB
cpanm -L extlib \
local::lib \
autodie \
Text::Xslate \
Catalyst::Devel \
Catalyst::Action::REST \
Catalyst::View::Xslate \
CatalystX::Routes \
Chloro \
CSS::Minifier::XS \
DBIx::Class \
DBIx::Class::DeploymentHandler \
DBIx::Class::EncodedColumn \
DBIx::Class::TimeStamp \
File::Which \
IPC::System::Simple \
JavaScript::Minifier::XS \
MooseX::Configuration
git add extlib
git commit -m "Installed required CPAN modules."
# Set local::lib to use the ICB extlib directory:
eval $(perl -I/srv/www/catalyst/icb/ICB/extlib/lib/perl5 -Mlocal::lib=/srv/www/catalyst/icb/ICB/extlib)
# Create the ICB Catalyst application:
cd /srv/www/catalyst/icb
catalyst.pl ICB
# Test that the index page can be viewed and that it returns the default welcome page.
cd /srv/www/catalyst/icb/ICB
script/icb_server -d
# Create and configure an Xslate view:
script/icb_create.pl view HTML Xslate
diff --git a/ICB/lib/ICB.pm b/ICB/lib/ICB.pm
index cab4465..f35f032 100644
--- a/ICB/lib/ICB.pm
+++ b/ICB/lib/ICB.pm
@@ -40,6 +40,10 @@ __PACKAGE__->config(
# Disable deprecated behavior needed by old applications
disable_component_resolution_regex_fallback => 1,
enable_catalyst_header => 1, # Send X-Catalyst header
+ default_view => 'HTML',
+ 'View::HTML' => {
+ path => [ __PACKAGE__->path_to( 'root', 'template', 'html' ) ],
+ },
);
# Start the application
# Remove the default welcome page:
diff --git a/ICB/lib/ICB/Controller/Root.pm b/ICB/lib/ICB/Controller/Root.pm
index 46f8783..213325b 100644
--- a/ICB/lib/ICB/Controller/Root.pm
+++ b/ICB/lib/ICB/Controller/Root.pm
@@ -30,7 +30,7 @@ sub index :Path :Args(0) {
my ( $self, $c ) = @_;
# Hello World
- $c->response->body( $c->welcome_message );
+ #$c->response->body( $c->welcome_message );
}
=head2 default
# Create a directory for the HTML templates:
cd /srv/www/catalyst/icb/ICB
mkdir -p root/template/html
# Create a wrapper template:
new file mode 100644
index 0000000..f4d04ed
--- /dev/null
+++ b/ICB/root/template/html/wrapper.tx
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Inca Cafè Bar</title>
+ <meta name="viewport" content="width=device-width, initial-scale
+ <meta name="description" content="">
+ <meta name="author" content="">
+ </head>
+
+ <body>
+ : block body->{}
+ <script type="text/javascript" src="http://ajax.googleapis.com/a
+ </body>
+</html>
# Add an index page template:
new file mode 100644
index 0000000..4ed33ac
--- /dev/null
+++ b/ICB/root/template/html/index.tx
@@ -0,0 +1,6 @@
+: cascade wrapper
+: around body->{
+<h1>Hello, world!</h1>
+: }
# Test that the index page can be viewed and that it returns the 'Hello, World!' content.
# Switch to using CatalystX::Routes. CatalystX::Routes creates chained actions, and these have a lower priority than :Path actions. It is therefore necessary to change the default handler to a chained handler to prevent it from overriding the index page. By not specifying the number of arguments, it will have a lower priority than the index action.
diff --git a/ICB/lib/ICB/Controller/Root.pm b/ICB/lib/ICB/Controller/Root.pm
index 213325b..efaf2d3 100644
--- a/ICB/lib/ICB/Controller/Root.pm
+++ b/ICB/lib/ICB/Controller/Root.pm
@@ -2,6 +2,8 @@ package ICB::Controller::Root;
use Moose;
use namespace::autoclean;
+use CatalystX::Routes;
+
BEGIN { extends 'Catalyst::Controller' }
#
@@ -26,12 +28,14 @@ The root page (/)
=cut
-sub index :Path :Args(0) {
- my ( $self, $c ) = @_;
+get_html q{}
+ => args 0
+ => sub {
+ my $self = shift;
+ my $c = shift;
- # Hello World
- #$c->response->body( $c->welcome_message );
-}
+ $c->stash( template => 'index.tx' );
+};
=head2 default
@@ -39,7 +43,7 @@ Standard 404 error page
=cut
-sub default :Path {
+sub default :Chained('/') :PathPart('') :Args() {
my ( $self, $c ) = @_;
$c->response->body( 'Page not found' );
$c->response->status(404);
@@ -51,7 +55,7 @@ Attempt to render a view, if needed.
=cut