line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Controller::JSON; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
35
|
|
16016
|
use strict; |
|
35
|
|
|
|
|
90
|
|
|
35
|
|
|
|
|
1069
|
|
4
|
35
|
|
|
35
|
|
229
|
use parent 'Catalyst::Controller'; |
|
35
|
|
|
|
|
79
|
|
|
35
|
|
|
|
|
221
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
MojoMojo::Controller::JSON - Various functions that return JSON data. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This is the Mojo for various functions that return JSON data. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This controller dispatches various JSON data to AJAX methods in MojoMojo. |
17
|
|
|
|
|
|
|
These methods will be called indirectly through JavaScript functions. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 ACTIONS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 tagsearch (json/tagsearch) |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Backend which handles jQuery autocomplete requests for tag. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub tagsearch : Local { |
28
|
0
|
|
|
0
|
|
0
|
my ($self, $c) = @_; |
29
|
0
|
|
|
|
|
0
|
my $query = $c->req->param('q'); |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
0
|
|
|
0
|
if (defined($query) && length($query)) { |
32
|
0
|
|
|
|
|
0
|
my $rs = $c->model('DBIC::Tag')->search({ |
33
|
|
|
|
|
|
|
tag => { -like => $query.'%' }, |
34
|
|
|
|
|
|
|
}, { |
35
|
|
|
|
|
|
|
select => [ 'tag' ], |
36
|
|
|
|
|
|
|
as => [ 'tag' ], |
37
|
|
|
|
|
|
|
group_by => [ 'tag' ], |
38
|
|
|
|
|
|
|
}); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
my @tags; |
41
|
0
|
|
|
|
|
0
|
while( my $each_rs = $rs->next ) |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
|
|
0
|
push(@tags, $each_rs->tag); |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
0
|
$c->stash->{json}->{tags} = \@tags; |
46
|
|
|
|
|
|
|
} |
47
|
35
|
|
|
35
|
|
6234
|
} |
|
35
|
|
|
|
|
94
|
|
|
35
|
|
|
|
|
231
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 container_set_default_width (json/container_set_default_width) |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Store width in session variable I<container_default_width>. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub container_set_default_width : Local { |
56
|
0
|
|
|
0
|
1
|
0
|
my ($self, $c, $width) = @_; |
57
|
0
|
|
|
|
|
0
|
$c->session->{container_default_width} = $width; |
58
|
0
|
|
|
|
|
0
|
$c->stash->{json}->{width} = $width; |
59
|
35
|
|
|
35
|
|
419390
|
} |
|
35
|
|
|
|
|
99
|
|
|
35
|
|
|
|
|
176
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 container_maximize_width (json/container_maximize_width) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Set or unset session variable I<maximize_width>, which is used to toggle maximum |
65
|
|
|
|
|
|
|
width when displaying the page. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub container_maximize_width : Local { |
70
|
0
|
|
|
0
|
1
|
0
|
my ($self, $c, $width) = @_; |
71
|
0
|
0
|
|
|
|
0
|
if ($width){ |
72
|
0
|
|
|
|
|
0
|
$c->session->{maximize_width}=1; |
73
|
|
|
|
|
|
|
} else { |
74
|
0
|
|
|
|
|
0
|
delete ($c->session->{maximize_width}); |
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
|
|
|
0
|
$c->stash->{json}->{width}=$c->session->{container_set_default_width}; |
77
|
35
|
|
|
35
|
|
33291
|
} |
|
35
|
|
|
|
|
82
|
|
|
35
|
|
|
|
|
166
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 auto |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Set default view |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub auto : Private { |
87
|
0
|
|
|
0
|
1
|
|
my ($self, $c) = @_; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$c->stash->{current_view} = 'JSON'; |
90
|
0
|
|
|
|
|
|
return 1; |
91
|
35
|
|
|
35
|
|
31434
|
} |
|
35
|
|
|
|
|
88
|
|
|
35
|
|
|
|
|
157
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Sachin Sebastian <sachinjsk at cpan.org> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Robert Litwiniec <linio at wonder.pl> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify it under |
104
|
|
|
|
|
|
|
the same terms as Perl itself. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |