add files
|
1 |
package Mojolicious::Command::generate::lite_app; |
2 |
use Mojo::Base 'Mojolicious::Command'; |
|
3 | ||
4 |
has description => "Generate Mojolicious::Lite application.\n"; |
|
5 |
has usage => "usage: $0 generate lite_app [NAME]\n"; |
|
6 | ||
7 |
sub run { |
|
8 |
my ($self, $name) = @_; |
|
9 |
$name ||= 'myapp.pl'; |
|
10 |
$self->render_to_rel_file('liteapp', $name); |
|
11 |
$self->chmod_file($name, 0744); |
|
12 |
} |
|
13 | ||
14 |
1; |
|
15 |
__DATA__ |
|
16 | ||
17 |
@@ liteapp |
|
18 |
#!/usr/bin/env perl |
|
19 |
use Mojolicious::Lite; |
|
20 | ||
21 |
# Documentation browser under "/perldoc" |
|
22 |
plugin 'PODRenderer'; |
|
23 | ||
24 |
get '/' => sub { |
|
25 |
my $self = shift; |
|
26 |
$self->render('index'); |
|
27 |
}; |
|
28 | ||
29 |
app->start; |
|
30 |
<% %>__DATA__ |
|
31 | ||
32 |
<% %>@@ index.html.ep |
|
33 |
%% layout 'default'; |
|
34 |
%% title 'Welcome'; |
|
35 |
Welcome to the Mojolicious real-time web framework! |
|
36 | ||
37 |
<% %>@@ layouts/default.html.ep |
|
38 |
<!DOCTYPE html> |
|
39 |
<html> |
|
40 |
<head><title><%%= title %></title></head> |
|
41 |
<body><%%= content %></body> |
|
42 |
</html> |
|
43 | ||
44 |
__END__ |
|
45 | ||
46 |
=encoding utf8 |
|
47 | ||
48 |
=head1 NAME |
|
49 | ||
50 |
Mojolicious::Command::generate::lite_app - Lite app generator command |
|
51 | ||
52 |
=head1 SYNOPSIS |
|
53 | ||
54 |
use Mojolicious::Command::generate::lite_app; |
|
55 | ||
56 |
my $app = Mojolicious::Command::generate::lite_app->new; |
|
57 |
$app->run(@ARGV); |
|
58 | ||
59 |
=head1 DESCRIPTION |
|
60 | ||
61 |
L<Mojolicious::Command::generate::lite_app> generate fully functional |
|
62 |
L<Mojolicious::Lite> applications. |
|
63 | ||
64 |
This is a core command, that means it is always enabled and its code a good |
|
65 |
example for learning to build new commands, you're welcome to fork it. |
|
66 | ||
67 |
=head1 ATTRIBUTES |
|
68 | ||
69 |
L<Mojolicious::Command::generate::lite_app> inherits all attributes from |
|
70 |
L<Mojolicious::Command> and implements the following new ones. |
|
71 | ||
72 |
=head2 description |
|
73 | ||
74 |
my $description = $app->description; |
|
75 |
$app = $app->description('Foo!'); |
|
76 | ||
77 |
Short description of this command, used for the command list. |
|
78 | ||
79 |
=head2 usage |
|
80 | ||
81 |
my $usage = $app->usage; |
|
82 |
$app = $app->usage('Foo!'); |
|
83 | ||
84 |
Usage information for this command, used for the help screen. |
|
85 | ||
86 |
=head1 METHODS |
|
87 | ||
88 |
L<Mojolicious::Command::generate::lite_app> inherits all methods from |
|
89 |
L<Mojolicious::Command> and implements the following new ones. |
|
90 | ||
91 |
=head2 run |
|
92 | ||
93 |
$app->run(@ARGV); |
|
94 | ||
95 |
Run this command. |
|
96 | ||
97 |
=head1 SEE ALSO |
|
98 | ||
99 |
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>. |
|
100 | ||
101 |
=cut |