diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 8760135f99c26155306eb5f4af0f096ff9bcbfe7..8e108962d5b2cdd6404b0ac08da312ccb99217c2 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 44babfa85425f266d21279e47bc3412686c67967..f7d3a752ed0db56cf1d9656931be9ddce1ddb6c2 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 cf704ecf09af19197e420630b93116b933a22f74..ee949134bc418111eb308501ba3ec30dfe6216d5 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 015a35d851ef397b2e6d646f239dcedc98d67a42..cb4f97520b56272d87b8099198d81e0ca10b2c6f 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 7bf9922adb5fb1b5bccd00f5ff7d8a03d2f91ee1..1276162eba32ad11cc7d054dc2164b30bbe365ab 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 1b33c18a630faaeca8c1f1c6bc237d7b48c7524e..e35701576a1c452fec075914c814d28cd1abe9e8 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 fe1280fc6355e7de1fa26b1a785617fe934dee69..fc4387d191bd0816db01fcbbf96d56e39984863e 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 9dfd7417f0faccf05eb20c7871a0a1385cb9c025..d80ac3d2e1ce4a2284e01cdfdd152175f5a46d33 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 bf509cef86aacc0d0c1fd17345bef34f1912051e..9fa20483c553795f3699c852f589f60da99a36ac 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 7691258338cb97e8328d4fe21e52924b2f8d41ed..2a6be03f70b2a5389d17e9a80a50fbf6cf973ce8 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