line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Whim; |
2
|
2
|
|
|
2
|
|
1589
|
use Mojo::Base 'Mojolicious'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
17
|
|
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
152845
|
use Mojo::File qw(curfile); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
111
|
|
5
|
2
|
|
|
2
|
|
17
|
use Mojo::Loader qw(load_class); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
85
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
588
|
use Whim::Core; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
61
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
12
|
use Path::Tiny; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1282
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.2021.06.17.0'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has info => "This is Whim, version $VERSION, by Jason McIntosh."; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub startup { |
16
|
3
|
|
|
3
|
1
|
60772
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Switch the app's home to ~/.whim/ |
19
|
|
|
|
|
|
|
# (overridable by environment variable) |
20
|
3
|
|
|
|
|
8
|
my $whim_homedir; |
21
|
3
|
50
|
|
|
|
12
|
if ( defined $ENV{WHIM_HOME} ) { |
22
|
3
|
|
|
|
|
19
|
$whim_homedir = path( $ENV{WHIM_HOME} ); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
0
|
|
|
|
|
0
|
$whim_homedir = path( $ENV{HOME} )->child('.whim'); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
131
|
$self->home( Mojo::Home->new($whim_homedir) ); |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
57
|
my $config = |
31
|
|
|
|
|
|
|
$self->plugin( 'Config', { default => { home => $self->home, }, } ); |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
4565
|
$self->commands->namespaces( ['Whim::Command'] ); |
34
|
3
|
|
|
|
|
191
|
$self->set_up_help; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Create a 'whim' helper containing our Whim::Core object |
37
|
|
|
|
|
|
|
$self->helper( |
38
|
|
|
|
|
|
|
whim => sub { |
39
|
2
|
|
|
2
|
|
1895
|
state $whim = Whim::Core->new($config); |
40
|
|
|
|
|
|
|
} |
41
|
3
|
|
|
|
|
49
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Set up docroot and template paths. |
44
|
|
|
|
|
|
|
# For both, the first place to look is the app home, and then using |
45
|
|
|
|
|
|
|
# the library directory as a fallback. |
46
|
3
|
|
|
|
|
254
|
$self->static->paths( |
47
|
|
|
|
|
|
|
[ $self->home->child('public'), |
48
|
|
|
|
|
|
|
curfile->sibling('Whim')->child('public'), |
49
|
|
|
|
|
|
|
] |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
629
|
$self->renderer->paths( |
53
|
|
|
|
|
|
|
[ $self->home->child('templates'), |
54
|
|
|
|
|
|
|
curfile->sibling('Whim')->child('templates'), |
55
|
|
|
|
|
|
|
] |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Set up routes for the listener |
59
|
3
|
|
|
|
|
535
|
my $r = $self->routes; |
60
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
35
|
$r->get('/')->to('listen#default'); |
62
|
3
|
|
|
|
|
993
|
$r->post('/')->to('listen#receive'); |
63
|
|
|
|
|
|
|
|
64
|
3
|
|
|
|
|
635
|
$r->get('/display_wms')->to('display#display'); |
65
|
3
|
|
|
|
|
1105
|
$r->get('/summarize_wms')->to('display#summarize'); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Mojolicious's 'Unknown command' error message is confusing, so |
68
|
|
|
|
|
|
|
# we do our own check for command-knownness. |
69
|
|
|
|
|
|
|
# (Mojo's load_class(), invoked below, returns truth if it fails.) |
70
|
3
|
0
|
33
|
|
|
1008
|
if ( $ARGV[0] |
|
|
|
33
|
|
|
|
|
71
|
|
|
|
|
|
|
&& $ARGV[0] ne 'help' |
72
|
|
|
|
|
|
|
&& load_class("Whim::Command::$ARGV[0]") ) |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
|
|
0
|
die "Unknown command '$ARGV[0]'. " |
75
|
|
|
|
|
|
|
. "(Type 'whim help' for a command list.)\n"; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub set_up_help { |
80
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
81
|
3
|
|
|
|
|
8
|
$self->commands->message( $self->info . "\n\nAvailable commands:\n" ); |
82
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
60
|
$self->commands->hint( |
84
|
|
|
|
|
|
|
"\nSee 'whim help COMMAND' for more information on a specific " |
85
|
|
|
|
|
|
|
. "commmand.\n" |
86
|
|
|
|
|
|
|
. "See 'man whim' for more thorough documentation.\n" ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Whim - A code library used by the Whim webmention multitool |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 DESCRIPTION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This is a code library used by the C<whim> executable. It doesn't have a |
98
|
|
|
|
|
|
|
public interface! |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SEE ALSO |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L<whim> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Jason McIntosh E<lt>jmac@jmac.orgE<gt> |