line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::SearchApp::Entry; |
2
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
3
|
2
|
|
|
2
|
|
6
|
use Moo; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
456
|
use vars qw($VERSION $es $server); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
126
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.05'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Dancer::SearchApp::Entry - a search index entry |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $entry = Dancer::SearchApp::Entry->new({ |
15
|
|
|
|
|
|
|
url => 'http://www.example.com/', |
16
|
|
|
|
|
|
|
title => 'An Example', |
17
|
|
|
|
|
|
|
content => '...', |
18
|
|
|
|
|
|
|
language => 'en', |
19
|
|
|
|
|
|
|
mime_type => 'text/html', |
20
|
|
|
|
|
|
|
author => 'A. U. Thor', |
21
|
|
|
|
|
|
|
}); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This is a aonvenience package to hold the information on an entry in the index. |
24
|
|
|
|
|
|
|
This should basically match whatever you have in the index, like an ORM |
25
|
|
|
|
|
|
|
or a glorified hash. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 C<< ->url >> |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 C<< ->id >> |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 C<< ->mime_type >> |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 C<< ->author >> |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 C<< ->creation_date >> |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 C<< ->content >> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 C<< ->title >> |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 C<< ->folder >> |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 C<< ->language >> |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Canonical URL |
50
|
|
|
|
|
|
|
has url => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
#isa => 'Str', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
{ |
56
|
2
|
|
|
2
|
|
7
|
no warnings 'once'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
457
|
|
57
|
|
|
|
|
|
|
*id = \*url; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has mime_type => ( |
61
|
|
|
|
|
|
|
is => 'ro', |
62
|
|
|
|
|
|
|
#isa => 'Str', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has author => ( |
66
|
|
|
|
|
|
|
is => 'ro', |
67
|
|
|
|
|
|
|
#isa => 'Str', |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has creation_date => ( |
71
|
|
|
|
|
|
|
is => 'ro', |
72
|
|
|
|
|
|
|
#isa => 'Str', |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has content => ( |
76
|
|
|
|
|
|
|
is => 'ro', |
77
|
|
|
|
|
|
|
#isa => 'Str', # HTML-String |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has title => ( |
81
|
|
|
|
|
|
|
is => 'ro', |
82
|
|
|
|
|
|
|
#isa => 'Str', |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has folder => ( |
86
|
|
|
|
|
|
|
is => 'ro', |
87
|
|
|
|
|
|
|
#isa => 'Str', |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
has language => ( |
91
|
|
|
|
|
|
|
is => 'ro', |
92
|
|
|
|
|
|
|
#isa => 'Str', # 'de', not (yet) de-DE |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 C<< ->from_es >> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Parses the elements as returned from Elasticsearch. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub from_es { |
102
|
0
|
|
|
0
|
1
|
|
my( $class, $result ) = @_; |
103
|
0
|
|
|
|
|
|
my %args = %{ $result->{_source} }; |
|
0
|
|
|
|
|
|
|
104
|
0
|
0
|
|
|
|
|
if( $args{ "Content-Type" } ) { |
105
|
0
|
|
|
|
|
|
$args{ mime_type } = delete $args{ "Content-Type" }; |
106
|
|
|
|
|
|
|
}; |
107
|
0
|
|
|
|
|
|
my $self = $class->new( %args ); |
108
|
0
|
|
|
|
|
|
$self |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 C<< ->basic_mime_type >> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
if( 'text/plain' eq $item->basic_mime_type ) { |
114
|
|
|
|
|
|
|
print "" . $item->content . " " |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Converts |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
text/plain; encoding=Latin-1 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
to |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
text/plain |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub basic_mime_type { |
128
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
129
|
0
|
|
|
|
|
|
my $mt = $self->mime_type; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$mt =~ s!;.*!!; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
$mt |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 REPOSITORY |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The public repository of this module is |
141
|
|
|
|
|
|
|
L. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SUPPORT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
The public support forum of this module is |
146
|
|
|
|
|
|
|
L. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 TALKS |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
I've given a talk about this module at Perl conferences: |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 BUG TRACKER |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Please report bugs in this module via the RT CPAN bug queue at |
157
|
|
|
|
|
|
|
L |
158
|
|
|
|
|
|
|
or via mail to L. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Max Maischein C |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COPYRIGHT (c) |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Copyright 2014-2016 by Max Maischein C. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 LICENSE |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This module is released under the same terms as Perl itself. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |