diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 8760135..8e10896 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1729,6 +1729,7 @@ sub startup { $r->get('/register')->to('account#registration_form'); $r->get('/reg/:id/:token')->to('account#verify'); $r->get('/status/:name')->to('traveling#user_status'); + $r->get('/ajax/status/:name')->to('traveling#public_status_card'); $r->post('/action')->to('traveling#log_action'); $r->post('/geolocation')->to('traveling#geolocation'); $r->post('/list_departures')->to('traveling#redirect_to_station'); diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index 44babfa..f7d3a75 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -222,12 +222,12 @@ sub privacy { $public_level &= ~0x02; } $self->set_privacy( $user->{id}, $public_level ); + $self->redirect_to('account'); } else { $self->param( public_status => $public_level & 0x02 ? 1 : 0 ); + $self->render( 'privacy', name => $user->{name} ); } - - $self->render( 'privacy', name => $user->{name} ); } sub change_mail { diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index cf704ec..ee94913 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -50,6 +50,8 @@ sub public_status_card { my $name = $self->stash('name'); my $user = $self->get_privacy_by_name($name); + delete $self->stash->{layout}; + if ( $user and ( $user->{public_level} & 0x02 ) ) { my $status = $self->get_user_status( $user->{id} ); $self->render( diff --git a/public/static/js/travelynx-actions.js b/public/static/js/travelynx-actions.js index 015a35d..cb4f975 100644 --- a/public/static/js/travelynx-actions.js +++ b/public/static/js/travelynx-actions.js @@ -21,10 +21,23 @@ function tvly_update() { $.get('/ajax/status_card.html', function(data) { $('.statuscol').html(data); tvly_reg_handlers(); - setTimeout(tvly_update, 15000); + setTimeout(tvly_update, 20000); }).fail(function() { $('.sync-failed-marker').css('display', 'block'); - setTimeout(tvly_update, 15000); + setTimeout(tvly_update, 20000); + }); +} +function tvly_update_public() { + var user_name; + $('.publicstatuscol').each(function() { + user_name = $(this).data('user'); + }); + $.get('/ajax/status/' + user_name + '.html', function(data) { + $('.publicstatuscol').html(data); + setTimeout(tvly_update_public, 20000); + }).fail(function() { + $('.sync-failed-marker').css('display', 'block'); + setTimeout(tvly_update_public, 20000); }); } function tvly_reg_handlers() { @@ -92,6 +105,12 @@ function tvly_reg_handlers() { $(document).ready(function() { tvly_reg_handlers(); if ($('.statuscol .autorefresh').length) { - setTimeout(tvly_update, 15000); + setTimeout(tvly_update, 20000); + } +}); +$(document).ready(function() { + tvly_reg_handlers(); + if ($('.publicstatuscol .autorefresh').length) { + setTimeout(tvly_update_public, 20000); } }); diff --git a/public/static/js/travelynx-actions.min.js b/public/static/js/travelynx-actions.min.js index 7bf9922..1276162 100644 --- a/public/static/js/travelynx-actions.min.js +++ b/public/static/js/travelynx-actions.min.js @@ -1 +1 @@ -function tvly_run(t,a,e){var n='error',c=$('
');t.hide(),t.after(c),$.post("/action",a,function(a){a.success?$(location).attr("href",a.redirect_to):(M.toast({html:n+" "+a.error}),c.remove(),e&&e(),t.append(" "+n),t.show())})}function tvly_update(){$.get("/ajax/status_card.html",function(t){$(".statuscol").html(t),tvly_reg_handlers(),setTimeout(tvly_update,15e3)}).fail(function(){$(".sync-failed-marker").css("display","block"),setTimeout(tvly_update,15e3)})}function tvly_reg_handlers(){$(".action-checkin").click(function(){var t=$(this);tvly_run(t,{action:"checkin",station:t.data("station"),train:t.data("train")})}),$(".action-checkout").click(function(){var t=$(this),a={action:"checkout",station:t.data("station"),force:t.data("force")};tvly_run(t,a,function(){t.append(" – Ohne Echtzeitdaten auschecken?"),t.data("force",!0)})}),$(".action-undo").click(function(){var t=$(this);tvly_run(t,{action:"undo",undo_id:t.data("id")})}),$(".action-cancelled-from").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_from",station:t.data("station"),train:t.data("train")})}),$(".action-cancelled-to").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_to",station:t.data("station"),force:!0})}),$(".action-delete").click(function(){var t=$(this),a={action:"delete",id:t.data("id"),checkin:t.data("checkin"),checkout:t.data("checkout")};really_delete=confirm("Diese Zugfahrt wirklich löschen? Der Eintrag wird sofort aus der Datenbank entfernt und kann nicht wiederhergestellt werden."),really_delete&&tvly_run(t,a)})}$(document).ready(function(){tvly_reg_handlers(),$(".statuscol .autorefresh").length&&setTimeout(tvly_update,15e3)}); +function tvly_run(t,e,a){var n='error',c=$('
');t.hide(),t.after(c),$.post("/action",e,function(e){e.success?$(location).attr("href",e.redirect_to):(M.toast({html:n+" "+e.error}),c.remove(),a&&a(),t.append(" "+n),t.show())})}function tvly_update(){$.get("/ajax/status_card.html",function(t){$(".statuscol").html(t),tvly_reg_handlers(),setTimeout(tvly_update,2e4)}).fail(function(){$(".sync-failed-marker").css("display","block"),setTimeout(tvly_update,2e4)})}function tvly_update_public(){var t;$(".publicstatuscol").each(function(){t=$(this).data("user")}),$.get("/ajax/status/"+t+".html",function(t){$(".publicstatuscol").html(t),setTimeout(tvly_update_public,2e4)}).fail(function(){$(".sync-failed-marker").css("display","block"),setTimeout(tvly_update_public,2e4)})}function tvly_reg_handlers(){$(".action-checkin").click(function(){var t=$(this);tvly_run(t,{action:"checkin",station:t.data("station"),train:t.data("train")})}),$(".action-checkout").click(function(){var t=$(this),e={action:"checkout",station:t.data("station"),force:t.data("force")};tvly_run(t,e,function(){t.append(" – Ohne Echtzeitdaten auschecken?"),t.data("force",!0)})}),$(".action-undo").click(function(){var t=$(this);tvly_run(t,{action:"undo",undo_id:t.data("id")})}),$(".action-cancelled-from").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_from",station:t.data("station"),train:t.data("train")})}),$(".action-cancelled-to").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_to",station:t.data("station"),force:!0})}),$(".action-delete").click(function(){var t=$(this),e={action:"delete",id:t.data("id"),checkin:t.data("checkin"),checkout:t.data("checkout")};really_delete=confirm("Diese Zugfahrt wirklich löschen? Der Eintrag wird sofort aus der Datenbank entfernt und kann nicht wiederhergestellt werden."),really_delete&&tvly_run(t,e)})}$(document).ready(function(){tvly_reg_handlers(),$(".statuscol .autorefresh").length&&setTimeout(tvly_update,2e4)}),$(document).ready(function(){tvly_reg_handlers(),$(".publicstatuscol .autorefresh").length&&setTimeout(tvly_update_public,2e4)}); diff --git a/public/static/v7 b/public/static/v9 similarity index 100% rename from public/static/v7 rename to public/static/v9 diff --git a/templates/_public_status_card.html.ep b/templates/_public_status_card.html.ep index 1b33c18..e357015 100644 --- a/templates/_public_status_card.html.ep +++ b/templates/_public_status_card.html.ep @@ -1,37 +1,11 @@ % if ($journey->{checked_in}) { -
-
+
+
+ <%= $name %> ist unterwegs

- In <%= $journey->{train_type} %> <%= $journey->{train_no} %> - % if ($journey->{arr_name}) { - von <%= $journey->{dep_name} %> nach <%= $journey->{arr_name} %>. - % } - % else { - ab <%= $journey->{dep_name} %>. - % } -

-

- <%= $journey->{real_departure}->strftime('%H:%M') %> - % if ($journey->{real_departure}->epoch != $journey->{sched_departure}->epoch) { - (<%= sprintf('%+d', ($journey->{real_departure}->epoch - $journey->{sched_departure}->epoch)/60) %>) - % } - → - % if ($journey->{real_arrival}->epoch) { - <%= $journey->{real_arrival}->strftime('%H:%M') %> - % if ($journey->{real_arrival}->epoch != $journey->{sched_arrival}->epoch) { - (<%= sprintf('%+d', ($journey->{real_arrival}->epoch - $journey->{sched_arrival}->epoch)/60) %>) - % } - % } - % elsif ($journey->{arr_name}) { - noch nicht bekannt - % } - % else { - unbekannt - % } -

-

-

+
+ <%= $journey->{train_type} %> <%= $journey->{train_no} %>
% if ($journey->{departure_countdown} > 120) { Abfahrt in <%= sprintf('%.f', $journey->{departure_countdown} / 60) %> Minuten % } @@ -57,8 +31,36 @@ Ankunft in mehr als zwei Stunden % }
-
-
+
+
+
+

+

+

+ <%= $journey->{dep_name} %>
+ <%= $journey->{real_departure}->strftime('%H:%M') %> + % if ($journey->{real_departure}->epoch != $journey->{sched_departure}->epoch) { + (<%= sprintf('%+d', ($journey->{real_departure}->epoch - $journey->{sched_departure}->epoch)/60) %>) + % } +
+
+ % if ($journey->{arr_name}) { + <%= $journey->{arr_name} %>
+ % } + % else { + Fahrt ins Blaue
+ % } + % if ($journey->{real_arrival}->epoch) { + <%= $journey->{real_arrival}->strftime('%H:%M') %> + % if ($journey->{real_arrival}->epoch != $journey->{sched_arrival}->epoch) { + (<%= sprintf('%+d', ($journey->{real_arrival}->epoch - $journey->{sched_arrival}->epoch)/60) %>) + % } + % } + % elsif ($journey->{arr_name}) { + noch nicht bekannt + % } +
+

% if (@{$journey->{messages} // []} > 0 and $journey->{messages}[0]) { @@ -76,8 +78,9 @@
% } % else { -
+
+ <%= $name %> ist gerade nicht eingecheckt

Zuletzt gesehen in <%= $journey->{arr_name} %>. diff --git a/templates/account.html.ep b/templates/account.html.ep index fe1280f..fc4387d 100644 --- a/templates/account.html.ep +++ b/templates/account.html.ep @@ -37,17 +37,14 @@ edit - Privatsphäre + Öffentliche Daten edit % if ($acc->{is_public} == 0) { - Keine öffentlichen Daten - % } - % else { - Öffentliche Daten: + Keine % } % if ($acc->{is_public} & 0x02) { - Status + Aktueller Status % } diff --git a/templates/layouts/default.html.ep b/templates/layouts/default.html.ep index 9dfd741..d80ac3d 100644 --- a/templates/layouts/default.html.ep +++ b/templates/layouts/default.html.ep @@ -5,7 +5,7 @@ - % my $av = 'v8'; # asset version + % my $av = 'v9'; # asset version %= stylesheet "/static/${av}/css/materialize.min.css" %= stylesheet "/static/${av}/css/material-icons.css" %= stylesheet "/static/${av}/css/local.css" diff --git a/templates/privacy.html.ep b/templates/privacy.html.ep index bf509ce..9fa2048 100644 --- a/templates/privacy.html.ep +++ b/templates/privacy.html.ep @@ -1,4 +1,4 @@ -

Privatsphäre

+

Öffentliche Daten

Hier kannst du auswählen, welche Aspekte deines Accounts bzw. deiner diff --git a/templates/user_status.html.ep b/templates/user_status.html.ep index 7691258..2a6be03 100644 --- a/templates/user_status.html.ep +++ b/templates/user_status.html.ep @@ -1,5 +1,5 @@
-
+
%= include '_public_status_card', name => $name, journey => $journey