| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::AutoReload; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.010'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Automatically reload open browser windows when your application changes |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
#pod |
|
7
|
|
|
|
|
|
|
#pod use Mojolicious::Lite; |
|
8
|
|
|
|
|
|
|
#pod plugin AutoReload => {}; |
|
9
|
|
|
|
|
|
|
#pod get '/' => 'index'; |
|
10
|
|
|
|
|
|
|
#pod app->start; |
|
11
|
|
|
|
|
|
|
#pod __DATA__ |
|
12
|
|
|
|
|
|
|
#pod @@ index.html.ep |
|
13
|
|
|
|
|
|
|
#pod Hello world! |
|
14
|
|
|
|
|
|
|
#pod |
|
15
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
16
|
|
|
|
|
|
|
#pod |
|
17
|
|
|
|
|
|
|
#pod This plugin automatically reloades the page when the Mojolicious webapp |
|
18
|
|
|
|
|
|
|
#pod restarts. This is especially useful when using L
|
|
19
|
|
|
|
|
|
|
#pod server|http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Reloading>, |
|
20
|
|
|
|
|
|
|
#pod which automatically restarts the webapp when it detects changes. |
|
21
|
|
|
|
|
|
|
#pod Combined, C and C will |
|
22
|
|
|
|
|
|
|
#pod automatically display your new content whenever you change your webapp |
|
23
|
|
|
|
|
|
|
#pod in your editor! |
|
24
|
|
|
|
|
|
|
#pod |
|
25
|
|
|
|
|
|
|
#pod This works by opening a WebSocket connection to a specific Mojolicious |
|
26
|
|
|
|
|
|
|
#pod route. When the server restarts, the WebSocket is disconnected, which |
|
27
|
|
|
|
|
|
|
#pod triggers a reload of the page. |
|
28
|
|
|
|
|
|
|
#pod |
|
29
|
|
|
|
|
|
|
#pod The AutoReload plugin will automatically add a C<< |
|
354
|
|
|
|
|
|
|
ENDHTML |
|
355
|
|
|
|
|
|
|
} |
|
356
|
1
|
|
|
|
|
14
|
return ''; |
|
357
|
2
|
|
|
|
|
33
|
} ); |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
1; |
|
361
|
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
__END__ |