[Rt-commit] rt branch, 4.6/pjax, updated. rt-4.4.1-2-ga6055e9
Shawn Moore
shawn at bestpractical.com
Wed Sep 21 15:04:21 EDT 2016
The branch, 4.6/pjax has been updated
via a6055e9d8786ea531533a05598e7b051ee7ef639 (commit)
from f8c7e0d022f9010eee30aaa5065883fa5678a8ff (commit)
Summary of changes:
etc/RT_Config.pm.in | 11 +++++++++++
lib/RT/Interface/Web.pm | 7 +++++++
share/html/Elements/Footer | 2 ++
share/html/Elements/Header | 3 +++
share/html/Elements/HeaderJavascript | 3 +++
5 files changed, 26 insertions(+)
- Log -----------------------------------------------------------------
commit a6055e9d8786ea531533a05598e7b051ee7ef639
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Sep 21 19:03:02 2016 +0000
Foundational support for PJAX
While the basic flow does work, our JS and header code are not prepared
to deal with how PJAX changes the request-response model.
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 7722558..90adcc0 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1210,6 +1210,17 @@ Set(@ChartColors, qw(
33cc33 cc3333 cc9933 6633cc
));
+=item C<$EnablePjax>
+
+PJAX "uses ajax and pushState to deliver a fast browsing experience with real
+permalinks, page titles, and a working back button". It improves performance by
+requesting only the HTML body of each page load. This avoids downloading,
+parsing, and executing the JavaScript and CSS on every request.
+
+=cut
+
+Set($EnablePjax, 1);
+
=back
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 1e2d05c..7b2b090 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1414,6 +1414,9 @@ our @GLOBAL_WHITELISTED_ARGS = (
# The NotMobile flag is fine for any page; it's only used to toggle a flag
# in the session related to which interface you get.
'NotMobile',
+
+ # jquery-pjax adds this parameter for PJAX requests
+ '_pjax',
);
our %WHITELISTED_COMPONENT_ARGS = (
@@ -4412,6 +4415,10 @@ sub GetCustomFieldInputNamePrefix {
RT::Interface::Web::GetCustomFieldInputNamePrefix(@_);
}
+sub IsPJAXRequest {
+ RT::Interface::Web::RequestENV('HTTP_X_PJAX');
+}
+
package RT::Interface::Web;
RT::Base->_ImportOverlays();
diff --git a/share/html/Elements/Footer b/share/html/Elements/Footer
index c8c6a5a..80040c3 100644
--- a/share/html/Elements/Footer
+++ b/share/html/Elements/Footer
@@ -66,8 +66,10 @@
<%$d->Dump() %>
</pre>
% }
+% unless (IsPJAXRequest()) {
</body>
</html>
+% }
<%ARGS>
$Debug => 0
$Menu => 1
diff --git a/share/html/Elements/Header b/share/html/Elements/Header
index b461da7..c991021 100644
--- a/share/html/Elements/Header
+++ b/share/html/Elements/Header
@@ -45,6 +45,7 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
+% unless (IsPJAXRequest()) {
%# index.html gets two doctypes unless we can skip it here
% unless ($SkipDoctype) {
<!DOCTYPE html>
@@ -97,6 +98,8 @@
<& /Elements/Framekiller &>
</head>
+% }
+
<body class="<% join( ' ',@{$ARGS{'BodyClass'}}) %>" <% $id && qq[id="comp-$id"] |n %>>
% if ($ShowBar) {
diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index 4b5e52b..81b44b0 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -62,6 +62,9 @@ jQuery( loadTitleBoxStates );
% if ( $onload ) {
jQuery( <% $onload |n %> );
% }
+% if ( RT->Config->Get('EnablePjax') ) {
+jQuery(document).pjax('a', 'body', { timeout: 30000 });
+% }
--></script>
<%INIT>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list