source: main/trunk/greenstone2/perllib/cpan/Mojolicious.pm@ 32205

Last change on this file since 32205 was 32205, checked in by ak19, 6 years ago

First set of commits to do with implementing the new 'paged_html' output option of PDFPlugin that uses using xpdftools' new pdftohtml. So far tested only on Linux (64 bit), but things work there so I'm optimistically committing the changes since they work. 2. Committing the pre-built Linux binaries of XPDFtools for both 32 and 64 bit built by the XPDF group. 2. To use the correct bitness variant of xpdftools, setup.bash now exports the BITNESS env var, consulted by gsConvert.pl. 3. All the perl code changes to do with using xpdf tools' pdftohtml to generate paged_html and feed it in the desired form into GS(3): gsConvert.pl, PDFPlugin.pm and its parent ConvertBinaryPFile.pm have been modified to make it all work. xpdftools' pdftohtml generates a folder containing an html file and a screenshot for each page in a PDF (as well as an index.html linking to each page's html). However, we want a single html file that contains each individual 'page' html's content in a div, and need to do some further HTML style, attribute and structure modifications to massage the xpdftool output to what we want for GS. In order to parse and manipulate the HTML 'DOM' to do this, we're using the Mojo::DOM package that Dr Bainbridge found and which he's compiled up. Mojo::DOM is therefore also committed in this revision. Some further changes and some display fixes are required, but need to check with the others about that.

File size: 27.3 KB
Line 
1package Mojolicious;
2use Mojo::Base -base;
3
4# "Fry: Shut up and take my money!"
5use Carp ();
6use Mojo::Exception;
7use Mojo::Home;
8use Mojo::Log;
9use Mojo::Util;
10use Mojo::UserAgent;
11use Mojolicious::Commands;
12use Mojolicious::Controller;
13use Mojolicious::Plugins;
14use Mojolicious::Renderer;
15use Mojolicious::Routes;
16use Mojolicious::Sessions;
17use Mojolicious::Static;
18use Mojolicious::Types;
19use Mojolicious::Validator;
20use Scalar::Util ();
21
22has commands => sub {
23 my $commands = Mojolicious::Commands->new(app => shift);
24 Scalar::Util::weaken $commands->{app};
25 return $commands;
26};
27has controller_class => 'Mojolicious::Controller';
28has home => sub { Mojo::Home->new->detect(ref shift) };
29has log => sub {
30 my $self = shift;
31
32 # Check if we have a log directory that is writable
33 my $log = Mojo::Log->new;
34 my $home = $self->home;
35 my $mode = $self->mode;
36 $log->path($home->child('log', "$mode.log"))
37 if -d $home->child('log') && -w _;
38
39 # Reduced log output outside of development mode
40 return $mode eq 'development' ? $log : $log->level('info');
41};
42has 'max_request_size';
43has mode => sub { $ENV{MOJO_MODE} || $ENV{PLACK_ENV} || 'development' };
44has moniker => sub { Mojo::Util::decamelize ref shift };
45has plugins => sub { Mojolicious::Plugins->new };
46has renderer => sub { Mojolicious::Renderer->new };
47has routes => sub { Mojolicious::Routes->new };
48has secrets => sub {
49 my $self = shift;
50
51 # Warn developers about insecure default
52 $self->log->debug('Your secret passphrase needs to be changed');
53
54 # Default to moniker
55 return [$self->moniker];
56};
57has sessions => sub { Mojolicious::Sessions->new };
58has static => sub { Mojolicious::Static->new };
59has types => sub { Mojolicious::Types->new };
60has ua => sub {
61 my $ua = Mojo::UserAgent->new;
62 Scalar::Util::weaken $ua->server->app(shift)->{app};
63 return $ua;
64};
65has validator => sub { Mojolicious::Validator->new };
66
67our $CODENAME = 'Doughnut';
68our $VERSION = '7.84';
69
70sub AUTOLOAD {
71 my $self = shift;
72
73 my ($package, $method) = our $AUTOLOAD =~ /^(.+)::(.+)$/;
74 Carp::croak "Undefined subroutine &${package}::$method called"
75 unless Scalar::Util::blessed $self && $self->isa(__PACKAGE__);
76
77 # Call helper with fresh controller
78 Carp::croak qq{Can't locate object method "$method" via package "$package"}
79 unless my $helper = $self->renderer->get_helper($method);
80 return $self->build_controller->$helper(@_);
81}
82
83sub build_controller {
84 my ($self, $tx) = @_;
85 $tx ||= $self->build_tx;
86
87 # Embedded application
88 my $stash = {};
89 if (my $sub = $tx->can('stash')) { ($stash, $tx) = ($tx->$sub, $tx->tx) }
90
91 # Build default controller
92 my $defaults = $self->defaults;
93 @$stash{keys %$defaults} = values %$defaults;
94 my $c
95 = $self->controller_class->new(app => $self, stash => $stash, tx => $tx);
96 Scalar::Util::weaken $c->{app};
97
98 return $c;
99}
100
101sub build_tx {
102 my $self = shift;
103
104 my $tx = Mojo::Transaction::HTTP->new;
105 my $max = $self->max_request_size;
106 $tx->req->max_message_size($max) if defined $max;
107 $self->plugins->emit_hook(after_build_tx => $tx, $self);
108
109 return $tx;
110}
111
112sub config { Mojo::Util::_stash(config => @_) }
113sub defaults { Mojo::Util::_stash(defaults => @_) }
114
115sub dispatch {
116 my ($self, $c) = @_;
117
118 my $plugins = $self->plugins->emit_hook(before_dispatch => $c);
119
120 # Try to find a static file
121 my $tx = $c->tx;
122 $self->static->dispatch($c) and $plugins->emit_hook(after_static => $c)
123 unless $tx->res->code;
124
125 # Start timer (ignore static files)
126 my $stash = $c->stash;
127 unless ($stash->{'mojo.static'} || $stash->{'mojo.started'}) {
128 my $req = $c->req;
129 my $method = $req->method;
130 my $path = $req->url->path->to_abs_string;
131 my $id = $req->request_id;
132 $self->log->debug(qq{$method "$path" ($id)});
133 $c->helpers->timing->begin('mojo.timer');
134 }
135
136 # Routes
137 $plugins->emit_hook(before_routes => $c);
138 $c->helpers->reply->not_found
139 unless $tx->res->code || $self->routes->dispatch($c) || $tx->res->code;
140}
141
142sub handler {
143 my $self = shift;
144
145 # Dispatcher has to be last in the chain
146 ++$self->{dispatch}
147 and $self->hook(around_action => sub { $_[2]($_[1]) })
148 and $self->hook(around_dispatch => sub { $_[1]->app->dispatch($_[1]) })
149 unless $self->{dispatch};
150
151 # Process with chain
152 my $c = $self->build_controller(@_);
153 Scalar::Util::weaken $c->{tx};
154 $self->plugins->emit_chain(around_dispatch => $c);
155
156 # Delayed response
157 $self->log->debug('Nothing has been rendered, expecting delayed response')
158 unless $c->stash->{'mojo.rendered'};
159}
160
161sub helper { shift->renderer->add_helper(@_) }
162
163sub hook { shift->plugins->on(@_) }
164
165sub new {
166 my $self = shift->SUPER::new(@_);
167
168 my $home = $self->home;
169 push @{$self->renderer->paths}, $home->child('templates')->to_string;
170 push @{$self->static->paths}, $home->child('public')->to_string;
171
172 # Default to controller and application namespace
173 my $r = $self->routes->namespaces(["@{[ref $self]}::Controller", ref $self]);
174
175 # Hide controller attributes/methods
176 $r->hide(qw(app continue cookie every_cookie every_param));
177 $r->hide(qw(every_signed_cookie finish flash helpers match on param));
178 $r->hide(qw(redirect_to render render_later render_maybe render_to_string));
179 $r->hide(qw(rendered req res respond_to send session signed_cookie stash));
180 $r->hide(qw(tx url_for validation write write_chunk));
181
182 $self->plugin($_)
183 for qw(HeaderCondition DefaultHelpers TagHelpers EPLRenderer EPRenderer);
184
185 # Exception handling should be first in chain
186 $self->hook(around_dispatch => \&_exception);
187
188 $self->startup;
189
190 return $self;
191}
192
193sub plugin {
194 my $self = shift;
195 $self->plugins->register_plugin(shift, $self, @_);
196}
197
198sub server { $_[0]->plugins->emit_hook(before_server_start => @_[1, 0]) }
199
200sub start {
201 my $self = shift;
202 $_->warmup for $self->static, $self->renderer;
203 return $self->commands->run(@_ ? @_ : @ARGV);
204}
205
206sub startup { }
207
208sub _exception {
209 my ($next, $c) = @_;
210 local $SIG{__DIE__}
211 = sub { ref $_[0] ? CORE::die $_[0] : Mojo::Exception->throw(shift) };
212 $c->helpers->reply->exception($@) unless eval { $next->(); 1 };
213}
214
2151;
216
217=encoding utf8
218
219=head1 NAME
220
221Mojolicious - Real-time web framework
222
223=head1 SYNOPSIS
224
225 # Application
226 package MyApp;
227 use Mojo::Base 'Mojolicious';
228
229 # Route
230 sub startup {
231 my $self = shift;
232 $self->routes->get('/hello')->to('foo#hello');
233 }
234
235 # Controller
236 package MyApp::Controller::Foo;
237 use Mojo::Base 'Mojolicious::Controller';
238
239 # Action
240 sub hello {
241 my $self = shift;
242 $self->render(text => 'Hello World!');
243 }
244
245=head1 DESCRIPTION
246
247An amazing real-time web framework built on top of the powerful L<Mojo> web
248development toolkit. With support for RESTful routes, plugins, commands,
249Perl-ish templates, content negotiation, session management, form validation,
250testing framework, static file server, C<CGI>/C<PSGI> detection, first class
251Unicode support and much more for you to discover.
252
253Take a look at our excellent documentation in L<Mojolicious::Guides>!
254
255=head1 HOOKS
256
257L<Mojolicious> will emit the following hooks in the listed order.
258
259=head2 before_server_start
260
261Emitted right before the application server is started, for web servers that
262support it, which includes all the built-in ones (except for
263L<Mojo::Server::CGI>). Note that this hook is EXPERIMENTAL and might change
264without warning!
265
266 $app->hook(before_server_start => sub {
267 my ($server, $app) = @_;
268 ...
269 });
270
271Useful for reconfiguring application servers dynamically or collecting server
272diagnostics information. (Passed the server and application objects)
273
274=head2 after_build_tx
275
276Emitted right after the transaction is built and before the HTTP request gets
277parsed.
278
279 $app->hook(after_build_tx => sub {
280 my ($tx, $app) = @_;
281 ...
282 });
283
284This is a very powerful hook and should not be used lightly, it makes some
285rather advanced features such as upload progress bars possible. Note that this
286hook will not work for embedded applications, because only the host application
287gets to build transactions. (Passed the transaction and application objects)
288
289=head2 around_dispatch
290
291Emitted right after a new request has been received and wraps around the whole
292dispatch process, so you have to manually forward to the next hook if you want
293to continue the chain. Default exception handling with
294L<Mojolicious::Plugin::DefaultHelpers/"reply-E<gt>exception"> is the first hook
295in the chain and a call to L</"dispatch"> the last, yours will be in between.
296
297 $app->hook(around_dispatch => sub {
298 my ($next, $c) = @_;
299 ...
300 $next->();
301 ...
302 });
303
304This is a very powerful hook and should not be used lightly, it allows you to,
305for example, customize application-wide exception handling, consider it the
306sledgehammer in your toolbox. (Passed a callback leading to the next hook and
307the default controller object)
308
309=head2 before_dispatch
310
311Emitted right before the static file server and router start their work.
312
313 $app->hook(before_dispatch => sub {
314 my $c = shift;
315 ...
316 });
317
318Very useful for rewriting incoming requests and other preprocessing tasks.
319(Passed the default controller object)
320
321=head2 after_static
322
323Emitted after a static file response has been generated by the static file
324server.
325
326 $app->hook(after_static => sub {
327 my $c = shift;
328 ...
329 });
330
331Mostly used for post-processing static file responses. (Passed the default
332controller object)
333
334=head2 before_routes
335
336Emitted after the static file server determined if a static file should be
337served and before the router starts its work.
338
339 $app->hook(before_routes => sub {
340 my $c = shift;
341 ...
342 });
343
344Mostly used for custom dispatchers and collecting metrics. (Passed the default
345controller object)
346
347=head2 around_action
348
349Emitted right before an action gets executed and wraps around it, so you have to
350manually forward to the next hook if you want to continue the chain. Default
351action dispatching is the last hook in the chain, yours will run before it.
352
353 $app->hook(around_action => sub {
354 my ($next, $c, $action, $last) = @_;
355 ...
356 return $next->();
357 });
358
359This is a very powerful hook and should not be used lightly, it allows you for
360example to pass additional arguments to actions or handle return values
361differently. Note that this hook can trigger more than once for the same
362request if there are nested routes. (Passed a callback leading to the next hook,
363the current controller object, the action callback and a flag indicating if this
364action is an endpoint)
365
366=head2 before_render
367
368Emitted before content is generated by the renderer. Note that this hook can
369trigger out of order due to its dynamic nature, and with embedded applications
370will only work for the application that is rendering.
371
372 $app->hook(before_render => sub {
373 my ($c, $args) = @_;
374 ...
375 });
376
377Mostly used for pre-processing arguments passed to the renderer. (Passed the
378current controller object and the render arguments)
379
380=head2 after_render
381
382Emitted after content has been generated by the renderer that will be assigned
383to the response. Note that this hook can trigger out of order due to its
384dynamic nature, and with embedded applications will only work for the
385application that is rendering.
386
387 $app->hook(after_render => sub {
388 my ($c, $output, $format) = @_;
389 ...
390 });
391
392Mostly used for post-processing dynamically generated content. (Passed the
393current controller object, a reference to the content and the format)
394
395=head2 after_dispatch
396
397Emitted in reverse order after a response has been generated. Note that this
398hook can trigger out of order due to its dynamic nature, and with embedded
399applications will only work for the application that is generating the response.
400
401 $app->hook(after_dispatch => sub {
402 my $c = shift;
403 ...
404 });
405
406Useful for rewriting outgoing responses and other post-processing tasks.
407(Passed the current controller object)
408
409=head1 ATTRIBUTES
410
411L<Mojolicious> implements the following attributes.
412
413=head2 commands
414
415 my $commands = $app->commands;
416 $app = $app->commands(Mojolicious::Commands->new);
417
418Command line interface for your application, defaults to a
419L<Mojolicious::Commands> object.
420
421 # Add another namespace to load commands from
422 push @{$app->commands->namespaces}, 'MyApp::Command';
423
424=head2 controller_class
425
426 my $class = $app->controller_class;
427 $app = $app->controller_class('Mojolicious::Controller');
428
429Class to be used for the default controller, defaults to
430L<Mojolicious::Controller>. Note that this class needs to have already been
431loaded before the first request arrives.
432
433=head2 home
434
435 my $home = $app->home;
436 $app = $app->home(Mojo::Home->new);
437
438The home directory of your application, defaults to a L<Mojo::Home> object
439which stringifies to the actual path.
440
441 # Portably generate path relative to home directory
442 my $path = $app->home->child('data', 'important.txt');
443
444=head2 log
445
446 my $log = $app->log;
447 $app = $app->log(Mojo::Log->new);
448
449The logging layer of your application, defaults to a L<Mojo::Log> object. The
450level will default to C<debug> if the L</mode> is C<development>, or C<info>
451otherwise. All messages will be written to C<STDERR>, or a C<log/$mode.log> file
452if a C<log> directory exists.
453
454 # Log debug message
455 $app->log->debug('It works');
456
457=head2 max_request_size
458
459 my $max = $app->max_request_size;
460 $app = $app->max_request_size(16777216);
461
462Maximum request size in bytes, defaults to the value of
463L<Mojo::Message/"max_message_size">. Setting the value to C<0> will allow
464requests of indefinite size. Note that increasing this value can also
465drastically increase memory usage, should you for example attempt to parse an
466excessively large request body with the methods L<Mojo::Message/"dom"> or
467L<Mojo::Message/"json">.
468
469=head2 mode
470
471 my $mode = $app->mode;
472 $app = $app->mode('production');
473
474The operating mode for your application, defaults to a value from the
475C<MOJO_MODE> and C<PLACK_ENV> environment variables or C<development>.
476
477=head2 moniker
478
479 my $moniker = $app->moniker;
480 $app = $app->moniker('foo_bar');
481
482Moniker of this application, often used as default filename for configuration
483files and the like, defaults to decamelizing the application class with
484L<Mojo::Util/"decamelize">.
485
486=head2 plugins
487
488 my $plugins = $app->plugins;
489 $app = $app->plugins(Mojolicious::Plugins->new);
490
491The plugin manager, defaults to a L<Mojolicious::Plugins> object. See the
492L</"plugin"> method below if you want to load a plugin.
493
494 # Add another namespace to load plugins from
495 push @{$app->plugins->namespaces}, 'MyApp::Plugin';
496
497=head2 renderer
498
499 my $renderer = $app->renderer;
500 $app = $app->renderer(Mojolicious::Renderer->new);
501
502Used to render content, defaults to a L<Mojolicious::Renderer> object. For more
503information about how to generate content see
504L<Mojolicious::Guides::Rendering>.
505
506 # Add another "templates" directory
507 push @{$app->renderer->paths}, '/home/sri/templates';
508
509 # Add another "templates" directory with higher precedence
510 unshift @{$app->renderer->paths}, '/home/sri/themes/blue/templates';
511
512 # Add another class with templates in DATA section
513 push @{$app->renderer->classes}, 'Mojolicious::Plugin::Fun';
514
515=head2 routes
516
517 my $routes = $app->routes;
518 $app = $app->routes(Mojolicious::Routes->new);
519
520The router, defaults to a L<Mojolicious::Routes> object. You use this in your
521startup method to define the url endpoints for your application.
522
523 # Add routes
524 my $r = $app->routes;
525 $r->get('/foo/bar')->to('test#foo', title => 'Hello Mojo!');
526 $r->post('/baz')->to('test#baz');
527
528 # Add another namespace to load controllers from
529 push @{$app->routes->namespaces}, 'MyApp::MyController';
530
531=head2 secrets
532
533 my $secrets = $app->secrets;
534 $app = $app->secrets([$bytes]);
535
536Secret passphrases used for signed cookies and the like, defaults to the
537L</"moniker"> of this application, which is not very secure, so you should
538change it!!! As long as you are using the insecure default there will be debug
539messages in the log file reminding you to change your passphrase. Only the
540first passphrase is used to create new signatures, but all of them for
541verification. So you can increase security without invalidating all your
542existing signed cookies by rotating passphrases, just add new ones to the front
543and remove old ones from the back.
544
545 # Rotate passphrases
546 $app->secrets(['new_passw0rd', 'old_passw0rd', 'very_old_passw0rd']);
547
548=head2 sessions
549
550 my $sessions = $app->sessions;
551 $app = $app->sessions(Mojolicious::Sessions->new);
552
553Signed cookie based session manager, defaults to a L<Mojolicious::Sessions>
554object. You can usually leave this alone, see
555L<Mojolicious::Controller/"session"> for more information about working with
556session data.
557
558 # Change name of cookie used for all sessions
559 $app->sessions->cookie_name('mysession');
560
561=head2 static
562
563 my $static = $app->static;
564 $app = $app->static(Mojolicious::Static->new);
565
566For serving static files from your C<public> directories, defaults to a
567L<Mojolicious::Static> object.
568
569 # Add another "public" directory
570 push @{$app->static->paths}, '/home/sri/public';
571
572 # Add another "public" directory with higher precedence
573 unshift @{$app->static->paths}, '/home/sri/themes/blue/public';
574
575 # Add another class with static files in DATA section
576 push @{$app->static->classes}, 'Mojolicious::Plugin::Fun';
577
578 # Remove built-in favicon
579 delete $app->static->extra->{'favicon.ico'};
580
581=head2 types
582
583 my $types = $app->types;
584 $app = $app->types(Mojolicious::Types->new);
585
586Responsible for connecting file extensions with MIME types, defaults to a
587L<Mojolicious::Types> object.
588
589 # Add custom MIME type
590 $app->types->type(twt => 'text/tweet');
591
592=head2 ua
593
594 my $ua = $app->ua;
595 $app = $app->ua(Mojo::UserAgent->new);
596
597A full featured HTTP user agent for use in your applications, defaults to a
598L<Mojo::UserAgent> object.
599
600 # Perform blocking request
601 say $app->ua->get('example.com')->result->body;
602
603=head2 validator
604
605 my $validator = $app->validator;
606 $app = $app->validator(Mojolicious::Validator->new);
607
608Validate values, defaults to a L<Mojolicious::Validator> object.
609
610 # Add validation check
611 $app->validator->add_check(foo => sub {
612 my ($v, $name, $value) = @_;
613 return $value ne 'foo';
614 });
615
616 # Add validation filter
617 $app->validator->add_filter(quotemeta => sub {
618 my ($v, $name, $value) = @_;
619 return quotemeta $value;
620 });
621
622=head1 METHODS
623
624L<Mojolicious> inherits all methods from L<Mojo::Base> and implements the
625following new ones.
626
627=head2 build_controller
628
629 my $c = $app->build_controller;
630 my $c = $app->build_controller(Mojo::Transaction::HTTP->new);
631 my $c = $app->build_controller(Mojolicious::Controller->new);
632
633Build default controller object with L</"controller_class">.
634
635 # Render template from application
636 my $foo = $app->build_controller->render_to_string(template => 'foo');
637
638=head2 build_tx
639
640 my $tx = $app->build_tx;
641
642Build L<Mojo::Transaction::HTTP> object and emit L</"after_build_tx"> hook.
643
644=head2 config
645
646 my $hash = $app->config;
647 my $foo = $app->config('foo');
648 $app = $app->config({foo => 'bar', baz => 23});
649 $app = $app->config(foo => 'bar', baz => 23);
650
651Application configuration.
652
653 # Remove value
654 my $foo = delete $app->config->{foo};
655
656 # Assign multiple values at once
657 $app->config(foo => 'test', bar => 23);
658
659=head2 defaults
660
661 my $hash = $app->defaults;
662 my $foo = $app->defaults('foo');
663 $app = $app->defaults({foo => 'bar', baz => 23});
664 $app = $app->defaults(foo => 'bar', baz => 23);
665
666Default values for L<Mojolicious::Controller/"stash">, assigned for every new
667request.
668
669 # Remove value
670 my $foo = delete $app->defaults->{foo};
671
672 # Assign multiple values at once
673 $app->defaults(foo => 'test', bar => 23);
674
675=head2 dispatch
676
677 $app->dispatch(Mojolicious::Controller->new);
678
679The heart of every L<Mojolicious> application, calls the L</"static"> and
680L</"routes"> dispatchers for every request and passes them a
681L<Mojolicious::Controller> object.
682
683=head2 handler
684
685 $app->handler(Mojo::Transaction::HTTP->new);
686 $app->handler(Mojolicious::Controller->new);
687
688Sets up the default controller and emits the L</"around_dispatch"> hook for
689every request.
690
691=head2 helper
692
693 $app->helper(foo => sub {...});
694
695Add or replace a helper that will be available as a method of the controller
696object and the application object, as well as a function in C<ep> templates. For
697a full list of helpers that are available by default see
698L<Mojolicious::Plugin::DefaultHelpers> and L<Mojolicious::Plugin::TagHelpers>.
699
700 # Helper
701 $app->helper(cache => sub { state $cache = {} });
702
703 # Application
704 $app->cache->{foo} = 'bar';
705 my $result = $app->cache->{foo};
706
707 # Controller
708 $c->cache->{foo} = 'bar';
709 my $result = $c->cache->{foo};
710
711 # Template
712 % cache->{foo} = 'bar';
713 %= cache->{foo}
714
715=head2 hook
716
717 $app->hook(after_dispatch => sub {...});
718
719Extend L<Mojolicious> with hooks, which allow code to be shared with all
720requests indiscriminately, for a full list of available hooks see L</"HOOKS">.
721
722 # Dispatchers will not run if there's already a response code defined
723 $app->hook(before_dispatch => sub {
724 my $c = shift;
725 $c->render(text => 'Skipped static file server and router!')
726 if $c->req->url->path->to_route =~ /do_not_dispatch/;
727 });
728
729=head2 new
730
731 my $app = Mojolicious->new;
732 my $app = Mojolicious->new(moniker => 'foo_bar');
733 my $app = Mojolicious->new({moniker => 'foo_bar'});
734
735Construct a new L<Mojolicious> application and call L</"startup">. Will
736automatically detect your home directory. Also sets up the renderer, static file
737server, a default set of plugins and an L</"around_dispatch"> hook with the
738default exception handling.
739
740=head2 plugin
741
742 $app->plugin('some_thing');
743 $app->plugin('some_thing', foo => 23);
744 $app->plugin('some_thing', {foo => 23});
745 $app->plugin('SomeThing');
746 $app->plugin('SomeThing', foo => 23);
747 $app->plugin('SomeThing', {foo => 23});
748 $app->plugin('MyApp::Plugin::SomeThing');
749 $app->plugin('MyApp::Plugin::SomeThing', foo => 23);
750 $app->plugin('MyApp::Plugin::SomeThing', {foo => 23});
751
752Load a plugin, for a full list of example plugins included in the
753L<Mojolicious> distribution see L<Mojolicious::Plugins/"PLUGINS">.
754
755=head2 server
756
757 $app->server(Mojo::Server->new);
758
759Emits the L</"before_server_start"> hook. Note that this method is EXPERIMENTAL
760and might change without warning!
761
762=head2 start
763
764 $app->start;
765 $app->start(@ARGV);
766
767Start the command line interface for your application. For a full list of
768commands that are available by default see L<Mojolicious::Commands/"COMMANDS">.
769Note that the options C<-h>/C<--help>, C<--home> and C<-m>/C<--mode>, which are
770shared by all commands, will be parsed from C<@ARGV> during compile time.
771
772 # Always start daemon
773 $app->start('daemon', '-l', 'http://*:8080');
774
775=head2 startup
776
777 $app->startup;
778
779This is your main hook into the application, it will be called at application
780startup. Meant to be overloaded in a subclass.
781
782 sub startup {
783 my $self = shift;
784 ...
785 }
786
787=head1 AUTOLOAD
788
789In addition to the L</"ATTRIBUTES"> and L</"METHODS"> above you can also call
790helpers on L<Mojolicious> objects. This includes all helpers from
791L<Mojolicious::Plugin::DefaultHelpers> and L<Mojolicious::Plugin::TagHelpers>.
792Note that application helpers are always called with a new default controller
793object, so they can't depend on or change controller state, which includes
794request, response and stash.
795
796 # Call helper
797 say $app->dumper({foo => 'bar'});
798
799 # Longer version
800 say $app->build_controller->helpers->dumper({foo => 'bar'});
801
802=head1 BUNDLED FILES
803
804The L<Mojolicious> distribution includes a few files with different licenses
805that have been bundled for internal use.
806
807=head2 Mojolicious Artwork
808
809 Copyright (C) 2010-2018, Sebastian Riedel.
810
811Licensed under the CC-SA License, Version 4.0
812L<http://creativecommons.org/licenses/by-sa/4.0>.
813
814=head2 jQuery
815
816 Copyright (C) jQuery Foundation.
817
818Licensed under the MIT License, L<http://creativecommons.org/licenses/MIT>.
819
820=head2 prettify.js
821
822 Copyright (C) 2006, 2013 Google Inc..
823
824Licensed under the Apache License, Version 2.0
825L<http://www.apache.org/licenses/LICENSE-2.0>.
826
827=head1 CODE NAMES
828
829Every major release of L<Mojolicious> has a code name, these are the ones that
830have been used in the past.
831
8327.0, C<Doughnut> (U+1F369)
833
8346.0, C<Clinking Beer Mugs> (U+1F37B)
835
8365.0, C<Tiger Face> (U+1F42F)
837
8384.0, C<Top Hat> (U+1F3A9)
839
8403.0, C<Rainbow> (U+1F308)
841
8422.0, C<Leaf Fluttering In Wind> (U+1F343)
843
8441.0, C<Snowflake> (U+2744)
845
846=head1 SPONSORS
847
848Some of the work on this distribution has been sponsored by
849L<The Perl Foundation|http://www.perlfoundation.org>, thank you!
850
851=head1 PROJECT FOUNDER
852
853Sebastian Riedel, C<[email protected]>
854
855=head1 CORE DEVELOPERS
856
857Current members of the core team in alphabetical order:
858
859=over 2
860
861Jan Henning Thorsen, C<[email protected]>
862
863Joel Berger, C<[email protected]>
864
865Marcus Ramberg, C<[email protected]>
866
867=back
868
869The following members of the core team are currently on hiatus:
870
871=over 2
872
873Abhijit Menon-Sen, C<[email protected]>
874
875Glen Hinkle, C<[email protected]>
876
877=back
878
879=head1 CREDITS
880
881In alphabetical order:
882
883=over 2
884
885Adam Kennedy
886
887Adriano Ferreira
888
889Al Newkirk
890
891Alex Efros
892
893Alex Salimon
894
895Alexey Likhatskiy
896
897Anatoly Sharifulin
898
899Andre Parker
900
901Andre Vieth
902
903Andreas Jaekel
904
905Andreas Koenig
906
907Andrew Fresh
908
909Andrew Nugged
910
911Andrey Khozov
912
913Andrey Kuzmin
914
915Andy Grundman
916
917Aristotle Pagaltzis
918
919Ashley Dev
920
921Ask Bjoern Hansen
922
923Audrey Tang
924
925Ben Tyler
926
927Ben van Staveren
928
929Benjamin Erhart
930
931Bernhard Graf
932
933Breno G. de Oliveira
934
935Brian Duggan
936
937Brian Medley
938
939Burak Gursoy
940
941Ch Lamprecht
942
943Charlie Brady
944
945Chas. J. Owens IV
946
947Chase Whitener
948
949Christian Hansen
950
951chromatic
952
953Curt Tilmes
954
955Dan Book
956
957Daniel Kimsey
958
959Daniel Mantovani
960
961Danijel Tasov
962
963Danny Thomas
964
965David Davis
966
967David Webb
968
969Diego Kuperman
970
971Dmitriy Shalashov
972
973Dmitry Konstantinov
974
975Dominik Jarmulowicz
976
977Dominique Dumont
978
979Dotan Dimet
980
981Douglas Christopher Wilson
982
983Ettore Di Giacinto
984
985Eugen Konkov
986
987Eugene Toropov
988
989Flavio Poletti
990
991Gisle Aas
992
993Graham Barr
994
995Graham Knop
996
997Henry Tang
998
999Hideki Yamamura
1000
1001Hiroki Toyokawa
1002
1003Ian Goodacre
1004
1005Ilya Chesnokov
1006
1007James Duncan
1008
1009Jan Jona Javorsek
1010
1011Jan Schmidt
1012
1013Jaroslav Muhin
1014
1015Jesse Vincent
1016
1017Johannes Plunien
1018
1019John Kingsley
1020
1021Jonathan Yu
1022
1023Josh Leder
1024
1025Kazuhiro Shibuya
1026
1027Kevin Old
1028
1029Kitamura Akatsuki
1030
1031Klaus S. Madsen
1032
1033Knut Arne Bjorndal
1034
1035Lars Balker Rasmussen
1036
1037Lee Johnson
1038
1039Leon Brocard
1040
1041Magnus Holm
1042
1043Maik Fischer
1044
1045Mark Fowler
1046
1047Mark Grimes
1048
1049Mark Stosberg
1050
1051Marty Tennison
1052
1053Matt S Trout
1054
1055Matthew Lineen
1056
1057Maksym Komar
1058
1059Maxim Vuets
1060
1061Michael Gregorowicz
1062
1063Michael Harris
1064
1065Mike Magowan
1066
1067Mirko Westermeier
1068
1069Mons Anderson
1070
1071Moritz Lenz
1072
1073Neil Watkiss
1074
1075Nic Sandfield
1076
1077Nils Diewald
1078
1079Oleg Zhelo
1080
1081Olivier Mengue
1082
1083Pascal Gaudette
1084
1085Paul Evans
1086
1087Paul Robins
1088
1089Paul Tomlin
1090
1091Pavel Shaydo
1092
1093Pedro Melo
1094
1095Peter Edwards
1096
1097Pierre-Yves Ritschard
1098
1099Piotr Roszatycki
1100
1101Quentin Carbonneaux
1102
1103Rafal Pocztarski
1104
1105Randal Schwartz
1106
1107Richard Elberger
1108
1109Rick Delaney
1110
1111Robert Hicks
1112
1113Robin Lee
1114
1115Roland Lammel
1116
1117Roy Storey
1118
1119Ryan Jendoubi
1120
1121Salvador Fandino
1122
1123Santiago Zarate
1124
1125Sascha Kiefer
1126
1127Scott Wiersdorf
1128
1129Sergey Zasenko
1130
1131Simon Bertrang
1132
1133Simone Tampieri
1134
1135Shu Cho
1136
1137Skye Shaw
1138
1139Stanis Trendelenburg
1140
1141Steffen Ullrich
1142
1143Stephan Kulow
1144
1145Stephane Este-Gracias
1146
1147Stevan Little
1148
1149Steve Atkins
1150
1151Tatsuhiko Miyagawa
1152
1153Terrence Brannon
1154
1155Tianon Gravi
1156
1157Tomas Znamenacek
1158
1159Tudor Constantin
1160
1161Ulrich Habel
1162
1163Ulrich Kautz
1164
1165Uwe Voelker
1166
1167Viacheslav Tykhanovskyi
1168
1169Victor Engmark
1170
1171Viliam Pucik
1172
1173Wes Cravens
1174
1175William Lindley
1176
1177Yaroslav Korshak
1178
1179Yuki Kimoto
1180
1181Zak B. Elep
1182
1183Zoffix Znet
1184
1185=back
1186
1187=head1 COPYRIGHT AND LICENSE
1188
1189Copyright (C) 2008-2018, Sebastian Riedel and others.
1190
1191This program is free software, you can redistribute it and/or modify it under
1192the terms of the Artistic License version 2.0.
1193
1194=head1 SEE ALSO
1195
1196L<https://github.com/kraih/mojo>, L<Mojolicious::Guides>,
1197L<https://mojolicious.org>.
1198
1199=cut
Note: See TracBrowser for help on using the repository browser.