Unverified Commit 7b858447 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Profile: Add JSON renderer

parent 5a72c603
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2422,7 +2422,8 @@ sub startup {
	  ->to( 'profile#user_status', format => undef );
	$r->get('/ajax/status/#name')->to('profile#status_card');
	$r->get('/ajax/status/:name/:ts')->to('profile#status_card');
	$r->get('/p/:name')->to('profile#profile');
	$r->get( '/p/:name' => [ format => [ 'html', 'json' ] ] )
	  ->to( 'profile#profile', format => undef );
	$r->get( '/p/:name/j/:id' => 'public_journey' )
	  ->to('profile#journey_details');
	$r->get('/.well-known/webfinger')->to('account#webfinger');
+40 −28
Original line number Diff line number Diff line
@@ -152,8 +152,18 @@ sub profile {
		@journeys = $self->journeys->get(%opt);
	}

	$self->render(
		'profile',
	$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},
@@ -165,21 +175,23 @@ sub profile {
			follow_requested => ( $relation and $relation eq 'requests_follow' )
			? 1
			: 0,
		can_follow => ( $my_user and $user->{accept_follows} and not $relation )
		? 1
			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
			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
			follows_me =>
			  ( $inverse_relation and $inverse_relation eq 'follows' ) ? 1
			: 0,
		follow_reqs_me =>
		  ( $inverse_relation and $inverse_relation eq 'requests_follow' ) ? 1
			follow_reqs_me => (
				$inverse_relation and $inverse_relation eq 'requests_follow'
			  ) ? 1
			: 0,
			journey  => $status,
			journeys => [@journeys],
		}
	);
}