[Bps-public-commit] rt-extension-turbo branch master updated. 550179834cda9453cdfd3e13084bec4e51ed5bb9
BPS Git Server
git at git.bestpractical.com
Tue Oct 11 18:07:08 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-turbo".
The branch, master has been updated
via 550179834cda9453cdfd3e13084bec4e51ed5bb9 (commit)
via dbf8c6d3ff6423974117e4b111c9fd48ae7fd8be (commit)
via 23e67607f149a3b54dc61b9597aaa272fdaedd9a (commit)
via 9df9aa7aff6e1f2b8e4307a2fa9e434520884fc0 (commit)
via 305f95a02b3f7a537b20b548040b6a6e1b3c261f (commit)
via 593ad4b213bf717cc9355a4ff51edcbc705d543f (commit)
from bcba503782971ed122c1e614ac5f71e5528aa79a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 550179834cda9453cdfd3e13084bec4e51ed5bb9
Merge: bcba503 dbf8c6d
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Aug 18 14:05:36 2022 -0400
Merge branch 'enable-globally'
commit dbf8c6d3ff6423974117e4b111c9fd48ae7fd8be
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Aug 18 14:03:46 2022 -0400
Remove commented out code
MyTurbo is now much closer to being a copy of MyRT with additional
lines only for stashing component and search names in notes.
diff --git a/html/Elements/MyTurbo b/html/Elements/MyTurbo
index 1d3b12f..8964531 100644
--- a/html/Elements/MyTurbo
+++ b/html/Elements/MyTurbo
@@ -1,19 +1,18 @@
+% $m->callback( ARGSRef => \%ARGS, CallbackName => 'BeforeTable' );
<div class="myrt row">
+
<div class="<% 'boxcontainer col-md-' . ( $sidebar ? '8' : '12' ) %>">
-% foreach my $entry ( @$body ) {
-% $show_cb->($entry);
-% }
+% $show_cb->($_) foreach @$body;
</div>
% if ( $sidebar ) {
<div class="boxcontainer col-md-4">
-% foreach my $entry ( @$sidebar ) {
-% $show_cb->($entry);
-% }
+% $show_cb->($_) foreach @$sidebar;
</div>
% }
-</div>
+</div>
+% $m->callback( ARGSRef => \%ARGS, CallbackName => 'AfterTable' );
<%init>
# All lifted from MyRT in core RT
my %allowed_components = map {$_ => 1} @{RT->Config->Get('HomepageComponents')};
@@ -85,18 +84,13 @@ $show_cb = sub {
else {
# Add turbo tags for components
$m->notes->{ComponentForTitle} = $name;
-# $m->out('<turbo-frame id="component-' . lc($name) . '" src="/Views/Component/' . $name . '" loading="lazy">');
-# $m->comp('/Widgets/Spinner');
-$m->comp( $name, %{ $entry->{arguments} || {} } );
-# $m->out('</turbo-frame>');
+ $m->comp( $name, %{ $entry->{arguments} || {} } );
}
} elsif ( $type eq 'search' ) {
# Add turbo tags for saved searches
my ($saved_search, $search_name) = RT::Dashboard->ShowSearchName($entry);
$m->notes->{SavedSearchForTitle} = $search_name;
-# $m->out('<turbo-frame id="savedsearch-' . lc($search_name) . '" src="/Views/Component/SavedSearch?SavedSearch=' . $search_name . '&Rows=' . $Rows . '">');
-$m->comp( '/Elements/ShowSearch', RT::Dashboard->ShowSearchName($entry), Override => { Rows => $Rows } );
-# $m->out('</turbo-frame>');
+ $m->comp( '/Elements/ShowSearch', RT::Dashboard->ShowSearchName($entry), Override => { Rows => $Rows } );
} elsif ( $type eq 'dashboard' ) {
my $current_dashboard = RT::Dashboard->new($session{CurrentUser});
my ($ok, $msg) = $current_dashboard->LoadById($entry->{id});
commit 23e67607f149a3b54dc61b9597aaa272fdaedd9a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Aug 18 13:48:49 2022 -0400
Add todo for Rows argument
diff --git a/lib/RT/Extension/Turbo.pm b/lib/RT/Extension/Turbo.pm
index e67e18a..219a04b 100644
--- a/lib/RT/Extension/Turbo.pm
+++ b/lib/RT/Extension/Turbo.pm
@@ -73,6 +73,11 @@ Update RT to read the "collapsed" cookie setting and load titlebox
closed if the titlebox has been hidden. Currently we load open, then
quickly close it. This allows lazy load to work properly.
+=item *
+
+Remove hard-coded Rows argument from Saved Searches. This should be loaded
+from the Saved Search configuration.
+
=back
=head1 AUTHOR
commit 9df9aa7aff6e1f2b8e4307a2fa9e434520884fc0
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Aug 18 13:46:04 2022 -0400
Process links as normal page fetches for components and searches
diff --git a/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent b/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
index 542a6f2..4ab15e8 100644
--- a/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
+++ b/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
@@ -12,7 +12,7 @@ if ( $m->request_path =~ /^\/Views/ ) {
elsif ( $m->notes('SavedSearchForTitle') ) {
# Homepage request for a saved search, send turbo tags
my $name = $m->notes('SavedSearchForTitle');
- $content .= '<turbo-frame id="savedsearch-' . lc($name) . '" src="/Views/Component/SavedSearch?SavedSearch=' . $name . '&Rows=10">';
+ $content .= '<turbo-frame id="savedsearch-' . lc($name) . '" src="/Views/Component/SavedSearch?SavedSearch=' . $name . '&Rows=10" target="_top">';
$content .= '<div class="text-center"><div class="spinner-border text-secondary" role="status"><span class="sr-only">Loading...</span></div></div>';
$content .= '</turbo-frame>';
$m->notes->{'SavedSearchForTitle'} = 0;
@@ -20,7 +20,7 @@ elsif ( $m->notes('SavedSearchForTitle') ) {
elsif ( $m->notes('ComponentForTitle') ) {
# Homepage request for a mason component, send turbo tags
my $name = $m->notes('ComponentForTitle');
- $content .= '<turbo-frame id="component-' . lc($name) . '" src="/Views/Component/' . $name . '" loading="lazy">';
+ $content .= '<turbo-frame id="component-' . lc($name) . '" src="/Views/Component/' . $name . '" loading="lazy" target="_top">';
$content .= '<div class="text-center"><div class="spinner-border text-secondary" role="status"><span class="sr-only">Loading...</span></div></div>';
$content .= '</turbo-frame>';
$m->notes->{'ComponentForTitle'} = 0;
commit 305f95a02b3f7a537b20b548040b6a6e1b3c261f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Aug 18 13:24:29 2022 -0400
Add case for non-turbo titleboxes
diff --git a/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent b/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
index 11c10e0..542a6f2 100644
--- a/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
+++ b/html/Callbacks/RT-Extension-Turbo/Widgets/Titlebox/ModifyContent
@@ -1,5 +1,6 @@
<%init>
my $content;
+my $change_content = 1;
if ( $m->request_path =~ /^\/Views/ ) {
# Turbo refresh, send body, no titlebox
$m->out( $$Content );
@@ -28,7 +29,14 @@ elsif ( $m->request_path =~ /^\/turbo_home\.html$/ ) {
# Homepage load that isn't a search or a component
$content = '';
}
-$$Content = $content;
+else {
+ # Regular request, don't change anything
+ $change_content = 0;
+}
+
+if ( $change_content ) {
+ $$Content = $content;
+}
</%init>
<%args>
$ARGSRef
commit 593ad4b213bf717cc9355a4ff51edcbc705d543f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Aug 12 10:02:04 2022 -0400
Enable Turbo Drive everywhere
This should improve page load performance for all pages
by using refresh rather than full page reloads.
diff --git a/lib/RT/Interface/Web_Vendor.pm b/lib/RT/Interface/Web_Vendor.pm
new file mode 100644
index 0000000..8a01d53
--- /dev/null
+++ b/lib/RT/Interface/Web_Vendor.pm
@@ -0,0 +1,47 @@
+use strict;
+use warnings;
+no warnings qw(redefine);
+
+package RT::Interface::Web;
+
+
+sub Redirect {
+ my $redir_to = shift;
+ untie $HTML::Mason::Commands::session;
+ my $uri = URI->new($redir_to);
+ my $server_uri = URI->new( RT->Config->Get('WebURL') );
+
+ # Make relative URIs absolute from the server host and scheme
+ $uri->scheme($server_uri->scheme) if not defined $uri->scheme;
+ if (not defined $uri->host) {
+ $uri->host($server_uri->host);
+ $uri->port($server_uri->port);
+ }
+
+ # If the user is coming in via a non-canonical
+ # hostname, don't redirect them to the canonical host,
+ # it will just upset them (and invalidate their credentials)
+ # don't do this if $RT::CanonicalizeRedirectURLs is true
+ if ( !RT->Config->Get('CanonicalizeRedirectURLs')
+ && $uri->host eq $server_uri->host
+ && $uri->port eq $server_uri->port )
+ {
+ my $env_uri = URI->new(GetWebURLFromRequest());
+ $uri->scheme($env_uri->scheme);
+ $uri->host($env_uri->host);
+ $uri->port($env_uri->port);
+ }
+
+ # not sure why, but on some systems without this call mason doesn't
+ # set status to 302, but 200 instead and people see blank pages
+ $HTML::Mason::Commands::r->status(303);
+
+ # Perlbal expects a status message, but Mason's default redirect status
+ # doesn't provide one. See also rt.cpan.org #36689.
+ $HTML::Mason::Commands::m->redirect( $uri->canonical, "303 See other" );
+
+ $HTML::Mason::Commands::m->abort;
+}
+
+
+1;
diff --git a/static/js/rt-extension-turbo.js b/static/js/rt-extension-turbo.js
index 3cfb8b8..05b0bc5 100644
--- a/static/js/rt-extension-turbo.js
+++ b/static/js/rt-extension-turbo.js
@@ -1,7 +1,11 @@
-// Disable by default, then enable where needed
-Turbo.session.drive = false;
+// Enable everywhere
+// Turbo.session.drive = false;
jQuery(function() {
+ jQuery(document).on('turbo:render', function(e) {
+ // Refresh any dropdowns after they are loaded by turbo
+ jQuery('.selectpicker').selectpicker('refresh');
+ });
jQuery(document).on('turbo:frame-render', function(e) {
// Refresh any dropdowns after they are loaded by turbo
jQuery('.selectpicker').selectpicker('refresh');
-----------------------------------------------------------------------
Summary of changes:
.../Widgets/Titlebox/ModifyContent | 14 +++++--
html/Elements/MyTurbo | 22 ++++------
lib/RT/Extension/Turbo.pm | 5 +++
lib/RT/Interface/Web_Vendor.pm | 47 ++++++++++++++++++++++
static/js/rt-extension-turbo.js | 8 +++-
5 files changed, 77 insertions(+), 19 deletions(-)
create mode 100644 lib/RT/Interface/Web_Vendor.pm
hooks/post-receive
--
rt-extension-turbo
More information about the Bps-public-commit
mailing list