File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ sub startup {
61
61
$r -> get(' /' )-> to(' listen#default' );
62
62
$r -> post(' /' )-> to(' listen#receive' );
63
63
64
+ $r -> get(' /wms' )-> to(' display#json' );
64
65
$r -> get(' /display_wms' )-> to(' display#display' );
65
66
$r -> get(' /summarize_wms' )-> to(' display#summarize' );
66
67
Original file line number Diff line number Diff line change 1
1
package Whim::Controller::Display ;
2
2
use Mojo::Base ' Mojolicious::Controller' ;
3
3
use Whim::Mention;
4
+ use List::Util qw/ pairmap / ;
4
5
5
6
use Readonly;
6
7
Readonly my $BAD_REQUEST => 400;
7
8
9
+ sub serialize_wm {
10
+ my $wm = shift ;
11
+
12
+ my $data = $wm -> TO_JSON;
13
+
14
+ # TO_JSON doesn't put all the yumminess
15
+ # in the hash, so I augment with the
16
+ # other stuff I want
17
+
18
+ if ( my $author = $wm -> author ) {
19
+ $data -> {author } = {
20
+ map { $_ => $author -> $_ } qw/ name url photo /
21
+ }
22
+ }
23
+
24
+ if ( $wm -> author_photo_hash ) {
25
+ $data -> {author }{local_photo } =
26
+ ' /author_photos/' . $wm -> author_photo_hash;
27
+ }
28
+
29
+ return $data ;
30
+ }
31
+
32
+ sub json {
33
+ my $self = shift ;
34
+
35
+ return unless $self -> _get_wms;
36
+
37
+ my %mentions = pairmap {
38
+ $a => [ map { serialize_wm($_ ) } @$b ]
39
+ } %{ $self -> stash-> {webmentions } };
40
+
41
+ $self -> render( json => \%mentions );
42
+ }
43
+
8
44
sub display {
9
45
my $self = shift ;
10
46
You can’t perform that action at this time.
0 commit comments