summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-07-15 19:20:37 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2023-07-15 19:20:37 +0200
commit1cca278baac0f50012e524eac7c441c998f4d8c3 (patch)
treeae292c5aef5c86e92d255e97010507c67daa02c6
parentbee67f096a5732fed5cb9c3e716012b536950022 (diff)
add timeline / current checkins
-rwxr-xr-xlib/Travelynx.pm1
-rwxr-xr-xlib/Travelynx/Controller/Profile.pm24
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm14
-rw-r--r--templates/_checked_in.html.ep3
-rw-r--r--templates/_public_status_card.html.ep5
-rw-r--r--templates/_timeline-checked-in.html.ep7
-rw-r--r--templates/_timeline_link.html.ep16
-rw-r--r--templates/landingpage.html.ep6
-rw-r--r--templates/timeline-checked-in.html.ep3
9 files changed, 77 insertions, 2 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 5b8680e..c529cb7 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -2201,6 +2201,7 @@ sub startup {
$authed_r->post('/delete')->to('account#delete');
$authed_r->post('/logout')->to('account#do_logout');
$authed_r->post('/set_token')->to('api#set_token');
+ $authed_r->get('/timeline/in-transit')->to('profile#checked_in');
}
diff --git a/lib/Travelynx/Controller/Profile.pm b/lib/Travelynx/Controller/Profile.pm
index b8812f8..03f3b0d 100755
--- a/lib/Travelynx/Controller/Profile.pm
+++ b/lib/Travelynx/Controller/Profile.pm
@@ -546,4 +546,28 @@ sub status_card {
);
}
+sub checked_in {
+ my ($self) = @_;
+
+ my $uid = $self->current_user->{id};
+ my @journeys = $self->in_transit->get_timeline(
+ uid => $uid,
+ with_data => 1
+ );
+
+ if ( $self->param('ajax') ) {
+ delete $self->stash->{layout};
+ $self->render(
+ '_timeline-checked-in',
+ journeys => [@journeys],
+ );
+ }
+ else {
+ $self->render(
+ 'timeline-checked-in',
+ journeys => [@journeys],
+ );
+ }
+}
+
1;
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index f283762..fe9b4f5 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -382,7 +382,13 @@ sub compute_effective_visibility {
sub homepage {
my ($self) = @_;
if ( $self->is_user_authenticated ) {
- my $status = $self->get_user_status;
+ my $uid = $self->current_user->{id};
+ my $status = $self->get_user_status;
+ my @timeline = $self->in_transit->get_timeline(
+ uid => $uid,
+ short => 1
+ );
+ $self->stash( timeline => [@timeline] );
my @recent_targets;
if ( $status->{checked_in} ) {
my $journey_visibility
@@ -457,6 +463,12 @@ sub status_card {
delete $self->stash->{layout};
+ my @timeline = $self->in_transit->get_timeline(
+ uid => $self->current_user->{id},
+ short => 1
+ );
+ $self->stash( timeline => [@timeline] );
+
if ( $status->{checked_in} ) {
my $journey_visibility
= $self->compute_effective_visibility(
diff --git a/templates/_checked_in.html.ep b/templates/_checked_in.html.ep
index df5472b..2382ac4 100644
--- a/templates/_checked_in.html.ep
+++ b/templates/_checked_in.html.ep
@@ -1,4 +1,7 @@
% my $user = current_user();
+% if (@{stash('timeline') // []}) {
+ %= include '_timeline_link', timeline => stash('timeline')
+% }
<div class="autorefresh">
<div class="card">
<div class="card-content">
diff --git a/templates/_public_status_card.html.ep b/templates/_public_status_card.html.ep
index acbae0d..cbdc878 100644
--- a/templates/_public_status_card.html.ep
+++ b/templates/_public_status_card.html.ep
@@ -7,6 +7,9 @@
% if (stash('from_profile')) {
Unterwegs mit <%= include '_format_train', journey => $journey %>
% }
+ % elsif (stash('from_timeline')) {
+ <a href="/p/<%= $name %>"><%= $name %></a>: <%= include '_format_train', journey => $journey %>
+ % }
% else {
<a href="/p/<%= $name %>"><%= $name %></a> ist unterwegs
% }
@@ -16,7 +19,7 @@
<p>„<%= $journey->{comment} %>“</p>
% }
<p>
- % if (not stash('from_profile')) {
+ % if (not stash('from_profile') and not stash('from_timeline')) {
<div class="center-align">
%= include '_format_train', journey => $journey
</div>
diff --git a/templates/_timeline-checked-in.html.ep b/templates/_timeline-checked-in.html.ep
new file mode 100644
index 0000000..b1d37ce
--- /dev/null
+++ b/templates/_timeline-checked-in.html.ep
@@ -0,0 +1,7 @@
+% for my $journey (@{$journeys}) {
+ <div class="row">
+ <div class="col s12 autorefresh">
+ %= include '_public_status_card', name => $journey->{followee_name}, privacy => {}, journey => $journey, from_timeline => 1
+ </div>
+ </div>
+% }
diff --git a/templates/_timeline_link.html.ep b/templates/_timeline_link.html.ep
new file mode 100644
index 0000000..782906e
--- /dev/null
+++ b/templates/_timeline_link.html.ep
@@ -0,0 +1,16 @@
+<div>
+ <a href="/timeline/in-transit">
+ % if (@{$timeline} <= 2) {
+ <strong><%= $timeline->[0]->{followee_name} %></strong>
+ % }
+ % if (@{$timeline} == 1) {
+ ist gerade unterwegs
+ % }
+ % elsif (@{$timeline} == 2) {
+ und <strong><%= $timeline->[1]->{followee_name} %></strong> sind gerade unterwegs
+ % }
+ % else {
+ <strong><%= scalar @{$timeline} %></strong> Accounts sind gerade unterwegs
+ % }
+ </a>
+</div>
diff --git a/templates/landingpage.html.ep b/templates/landingpage.html.ep
index b91cd89..d3b514f 100644
--- a/templates/landingpage.html.ep
+++ b/templates/landingpage.html.ep
@@ -18,6 +18,9 @@
%= include '_checked_in', journey => $status, journey_visibility => stash('journey_visibility');
% }
% elsif ($status->{cancelled}) {
+ % if ( @{stash('timeline') // [] } ) {
+ %= include '_timeline_link', timeline => stash('timeline')
+ % }
<div class="card info-color">
<div class="card-content">
<span class="card-title">Zugausfall dokumentieren</span>
@@ -45,6 +48,9 @@
</div>
% }
% else {
+ % if ( @{stash('timeline') // [] } ) {
+ %= include '_timeline_link', timeline => stash('timeline')
+ % }
<div class="card">
<div class="card-content">
<span class="card-title">Hallo, <%= current_user->{name} %>!</span>
diff --git a/templates/timeline-checked-in.html.ep b/templates/timeline-checked-in.html.ep
new file mode 100644
index 0000000..0ed492e
--- /dev/null
+++ b/templates/timeline-checked-in.html.ep
@@ -0,0 +1,3 @@
+<div class="timeline-in-transit">
+ %= include '_timeline-checked-in', journeys => $journeys
+</div>