summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-05-31 10:59:41 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-05-31 10:59:41 +0200
commit7b8584473bb7946affbb73dba5116103864ab6d1 (patch)
treeda4d7a64e8c201fa71f1b81348ff8a687e614075 /lib/Travelynx/Controller
parent5a72c603070503420a0fd826a0d39037ad771194 (diff)
Profile: Add JSON renderer
Diffstat (limited to 'lib/Travelynx/Controller')
-rwxr-xr-xlib/Travelynx/Controller/Profile.pm68
1 files changed, 40 insertions, 28 deletions
diff --git a/lib/Travelynx/Controller/Profile.pm b/lib/Travelynx/Controller/Profile.pm
index fc2d38c..b2b6e03 100755
--- a/lib/Travelynx/Controller/Profile.pm
+++ b/lib/Travelynx/Controller/Profile.pm
@@ -152,34 +152,46 @@ sub profile {
@journeys = $self->journeys->get(%opt);
}
- $self->render(
- 'profile',
- title => "travelynx: $name",
- name => $name,
- uid => $user->{id},
- privacy => $user,
- bio => $profile->{bio}{html},
- metadata => $profile->{metadata},
- is_self => $is_self,
- following => ( $relation and $relation eq 'follows' ) ? 1 : 0,
- follow_requested => ( $relation and $relation eq 'requests_follow' )
- ? 1
- : 0,
- can_follow => ( $my_user and $user->{accept_follows} and not $relation )
- ? 1
- : 0,
- can_request_follow =>
- ( $my_user and $user->{accept_follow_requests} and not $relation )
- ? 1
- : 0,
- follows_me => ( $inverse_relation and $inverse_relation eq 'follows' )
- ? 1
- : 0,
- follow_reqs_me =>
- ( $inverse_relation and $inverse_relation eq 'requests_follow' ) ? 1
- : 0,
- journey => $status,
- journeys => [@journeys],
+ $self->respond_to(
+ json => {
+ json => {
+ name => $name,
+ uid => $user->{id},
+ bio => $profile->{bio}{html},
+ metadata => $profile->{metadata},
+ journeys => [@journeys],
+ }
+ },
+ any => {
+ template => 'profile',
+ title => "travelynx: $name",
+ name => $name,
+ uid => $user->{id},
+ privacy => $user,
+ bio => $profile->{bio}{html},
+ metadata => $profile->{metadata},
+ is_self => $is_self,
+ following => ( $relation and $relation eq 'follows' ) ? 1 : 0,
+ follow_requested => ( $relation and $relation eq 'requests_follow' )
+ ? 1
+ : 0,
+ can_follow =>
+ ( $my_user and $user->{accept_follows} and not $relation ) ? 1
+ : 0,
+ can_request_follow => (
+ $my_user and $user->{accept_follow_requests} and not $relation
+ ) ? 1
+ : 0,
+ follows_me =>
+ ( $inverse_relation and $inverse_relation eq 'follows' ) ? 1
+ : 0,
+ follow_reqs_me => (
+ $inverse_relation and $inverse_relation eq 'requests_follow'
+ ) ? 1
+ : 0,
+ journey => $status,
+ journeys => [@journeys],
+ }
);
}