| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Whim; |
|
2
|
2
|
|
|
2
|
|
1649
|
use Mojo::Base 'Mojolicious'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
150595
|
use Mojo::File qw(curfile); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
109
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use Mojo::Loader qw(load_class); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
75
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
568
|
use Whim::Core; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
67
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
13
|
use Path::Tiny; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
1425
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.2021.05.30.0'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has info => "This is Whim, version $VERSION, by Jason McIntosh."; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub startup { |
|
16
|
3
|
|
|
3
|
1
|
61347
|
my $self = shift; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Switch the app's home to ~/.whim/ |
|
19
|
|
|
|
|
|
|
# (overridable by environment variable) |
|
20
|
3
|
|
|
|
|
7
|
my $whim_homedir; |
|
21
|
3
|
50
|
|
|
|
15
|
if ( defined $ENV{WHIM_HOME} ) { |
|
22
|
3
|
|
|
|
|
21
|
$whim_homedir = path( $ENV{WHIM_HOME} ); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
else { |
|
25
|
0
|
|
|
|
|
0
|
$whim_homedir = path( $ENV{HOME} )->child('.whim'); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
3
|
|
|
|
|
150
|
$self->home( Mojo::Home->new($whim_homedir) ); |
|
29
|
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
68
|
my $config = |
|
31
|
|
|
|
|
|
|
$self->plugin( 'Config', { default => { home => $self->home, }, } ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
4612
|
$self->commands->namespaces( ['Whim::Command'] ); |
|
34
|
3
|
|
|
|
|
228
|
$self->set_up_help; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Create a 'whim' helper containing our Whim::Core object |
|
37
|
|
|
|
|
|
|
$self->helper( |
|
38
|
|
|
|
|
|
|
whim => sub { |
|
39
|
2
|
|
|
2
|
|
2026
|
state $whim = Whim::Core->new($config); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
3
|
|
|
|
|
50
|
); |
|
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
|
|
|
|
|
266
|
$self->static->paths( |
|
47
|
|
|
|
|
|
|
[ $self->home->child('public'), |
|
48
|
|
|
|
|
|
|
curfile->sibling('Whim')->child('public'), |
|
49
|
|
|
|
|
|
|
] |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
754
|
$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
|
|
|
|
|
576
|
my $r = $self->routes; |
|
60
|
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
41
|
$r->get('/')->to('listen#default'); |
|
62
|
3
|
|
|
|
|
1096
|
$r->post('/')->to('listen#receive'); |
|
63
|
|
|
|
|
|
|
|
|
64
|
3
|
|
|
|
|
634
|
$r->get('/display_wms')->to('display#display'); |
|
65
|
3
|
|
|
|
|
1075
|
$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
|
|
|
1006
|
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
|
8
|
my $self = shift; |
|
81
|
3
|
|
|
|
|
11
|
$self->commands->message( $self->info . "\n\nAvailable commands:\n" ); |
|
82
|
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
66
|
$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> |