Merge lp:~andrewberry/pressflow/529252-has-js-cookie into lp:pressflow

Proposed by Andrew Berry
Status: Rejected
Rejected by: David Strauss
Proposed branch: lp:~andrewberry/pressflow/529252-has-js-cookie
Merge into: lp:pressflow
Diff against target: 57 lines (+19/-5)
3 files modified
includes/common.inc (+7/-0)
misc/drupal.js (+7/-5)
misc/jsenabled.js (+5/-0)
To merge this branch: bzr merge lp:~andrewberry/pressflow/529252-has-js-cookie
Reviewer Review Type Date Requested Status
Pressflow Administrators Pending
Review via email: mp+69900@code.launchpad.net

Description of the change

Set the has_js cookie for authenticated users. This allows the Batch API to use the JS version for authenticated users if they have JS enabled.

To post a comment you must log in.
Revision history for this message
mkalkbrenner (markus-kalkbrenner) wrote :

What happens after the user logs out? Shouldn't the cookie be deleted?

Why don't we set the cookie for anonymous users as well like drupal does?

AFAIK the feature has been removed from pressflow to allow varnish to cache pages for anonymous users. They are destinguished form authenticated users using the session cookie and the "HTTP-Vary-Cookie-Header". But I think that varnish could simply be configured to ignore the has_js-cookie like most people already do for google analytics cookies.

Revision history for this message
Andrew Berry (andrewberry) wrote :

I hadn't thought about using the Batch API for anonymous users. But since those requests should be POSTs anyways, there might not be any harm in allowing has_js for anonymous, as long as the cookie is ignored on GET requests.

Revision history for this message
David Strauss (davidstrauss) wrote :

Pressflow 6 is now maintained on GitHub, so I'm marking this merge as rejected.

Unmerged revisions

106. By Andrew Berry

Allow setting of the has_js cookie for authenticated users.

105. By Andrew Berry

Restore the Drupal.jsEnabled variable.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'includes/common.inc'
2--- includes/common.inc 2011-06-01 07:13:05 +0000
3+++ includes/common.inc 2011-07-30 19:36:34 +0000
4@@ -2180,6 +2180,13 @@
5 ),
6 'inline' => array(),
7 );
8+
9+ // We never cache authenticated user pages, so if they are logged in we
10+ // allow setting of the has_js cookie so batch API functions use the JS
11+ // version.
12+ if (!user_is_anonymous()) {
13+ $javascript['header']['core']['misc/jsenabled.js'] = array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE);
14+ }
15 }
16
17 if (isset($scope) && !isset($javascript[$scope])) {
18
19=== modified file 'misc/drupal.js'
20--- misc/drupal.js 2011-05-26 02:58:29 +0000
21+++ misc/drupal.js 2011-07-30 19:36:34 +0000
22@@ -4,7 +4,7 @@
23 /**
24 * Set the variable that indicates if JavaScript behaviors should be applied
25 */
26-Drupal.jsEnabled = true;
27+Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;
28
29 /**
30 * Attach all registered behaviors to a page element.
31@@ -35,10 +35,12 @@
32 */
33 Drupal.attachBehaviors = function(context) {
34 context = context || document;
35- // Execute all of them.
36- jQuery.each(Drupal.behaviors, function() {
37- this(context);
38- });
39+ if (Drupal.jsEnabled) {
40+ // Execute all of them.
41+ jQuery.each(Drupal.behaviors, function() {
42+ this(context);
43+ });
44+ }
45 };
46
47 /**
48
49=== added file 'misc/jsenabled.js'
50--- misc/jsenabled.js 1970-01-01 00:00:00 +0000
51+++ misc/jsenabled.js 2011-07-30 19:36:34 +0000
52@@ -0,0 +1,5 @@
53+if (Drupal.jsEnabled) {
54+ // 'js enabled' cookie
55+ document.cookie = 'has_js=1; path=/';
56+}
57+

Subscribers

People subscribed via source and target branches

to status/vote changes: