Nexcessnet_Turpentine - Version 0.5.5

Version Notes

Supports Magento v1.6 and later

Download this release

Release Info

Developer Chris Wells
Extension Nexcessnet_Turpentine
Version 0.5.5
Comparing to
See all releases


Code changes from version 0.5.4 to 0.5.5

app/code/community/Nexcessnet/Turpentine/Helper/Ban.php CHANGED
@@ -30,9 +30,16 @@ class Nexcessnet_Turpentine_Helper_Ban extends Mage_Core_Helper_Abstract {
30
  public function getProductBanRegex( $product ) {
31
  $urlPatterns = array();
32
  foreach( $this->getParentProducts( $product ) as $parentProduct ) {
33
- $urlPatterns[] = $parentProduct->getUrlKey();
 
 
 
 
 
 
 
 
34
  }
35
- $urlPatterns[] = $product->getUrlKey();
36
  $pattern = sprintf( '(?:%s)', implode( '|', $urlPatterns ) );
37
  return $pattern;
38
  }
30
  public function getProductBanRegex( $product ) {
31
  $urlPatterns = array();
32
  foreach( $this->getParentProducts( $product ) as $parentProduct ) {
33
+ if ( $parentProduct->getUrlKey() ) {
34
+ $urlPatterns[] = $parentProduct->getUrlKey();
35
+ }
36
+ }
37
+ if ( $product->getUrlKey() ) {
38
+ $urlPatterns[] = $product->getUrlKey();
39
+ }
40
+ if ( empty($urlPatterns) ) {
41
+ $urlPatterns[] = "##_NEVER_MATCH_##";
42
  }
 
43
  $pattern = sprintf( '(?:%s)', implode( '|', $urlPatterns ) );
44
  return $pattern;
45
  }
app/code/community/Nexcessnet/Turpentine/Helper/Data.php CHANGED
@@ -292,6 +292,15 @@ class Nexcessnet_Turpentine_Helper_Data extends Mage_Core_Helper_Abstract {
292
  foreach( $blockNode->xpath( './block | ./reference' ) as $childBlockNode ) {
293
  $blockNames = array_merge( $blockNames,
294
  $this->_getChildBlockNames( $childBlockNode ) );
 
 
 
 
 
 
 
 
 
295
  }
296
  } else {
297
  $blockNames = array();
292
  foreach( $blockNode->xpath( './block | ./reference' ) as $childBlockNode ) {
293
  $blockNames = array_merge( $blockNames,
294
  $this->_getChildBlockNames( $childBlockNode ) );
295
+ if( $this->getLayout() instanceof Varien_Simplexml_Config ) {
296
+ foreach( $this->getLayout()->getNode()->xpath( sprintf(
297
+ '//reference[@name=\'%s\']', (string)$childBlockNode['name'] ) )
298
+ as $childBlockLayoutNode ) {
299
+ $blockNames = array_merge( $blockNames,
300
+ $this->_getChildBlockNames( $childBlockLayoutNode ) );
301
+
302
+ }
303
+ }
304
  }
305
  } else {
306
  $blockNames = array();
app/code/community/Nexcessnet/Turpentine/Helper/Varnish.php CHANGED
@@ -162,10 +162,11 @@ class Nexcessnet_Turpentine_Helper_Varnish extends Mage_Core_Helper_Abstract {
162
  * @return boolean
163
  */
164
  public function isBypassEnabled() {
165
- $cookieName = Mage::helper( 'turpentine' )->getBypassCookieName();
166
- $cookieValue = (bool)Mage::getModel( 'core/cookie' )->get($cookieName);
 
167
 
168
- return $cookieValue;
169
  }
170
 
171
  /**
162
  * @return boolean
163
  */
164
  public function isBypassEnabled() {
165
+ $bypassEnabled = (bool)Mage::getModel( 'core/cookie' )->get(
166
+ Mage::helper( 'turpentine/data' )->getBypassCookieName() ) ===
167
+ $this->getSecretHandshake();
168
 
169
+ return $bypassEnabled;
170
  }
171
 
172
  /**
app/code/community/Nexcessnet/Turpentine/Model/Dummy/Request.php CHANGED
@@ -40,7 +40,18 @@ class Nexcessnet_Turpentine_Model_Dummy_Request extends
40
  public function __construct( $uri=null ) {
41
  $this->_initFakeSuperGlobals();
42
  $this->_fixupFakeSuperGlobals( $uri );
43
- parent::__construct( $uri );
 
 
 
 
 
 
 
 
 
 
 
44
  }
45
 
46
  /**
@@ -542,7 +553,7 @@ class Nexcessnet_Turpentine_Model_Dummy_Request extends
542
  /**
543
  * Check this request against the cms, standard, and default routers to fill
544
  * the module/controller/action/route fields.
545
- *
546
  * TODO: This whole thing is a gigantic hack. Would be nice to have a
547
  * better solution.
548
  *
40
  public function __construct( $uri=null ) {
41
  $this->_initFakeSuperGlobals();
42
  $this->_fixupFakeSuperGlobals( $uri );
43
+ try {
44
+ parent::__construct( $uri );
45
+ } catch( Exception $e ) {
46
+ Mage::helper( 'turpentine/debug' )
47
+ ->logError( 'Bad URI given to dummy request: ' . $uri );
48
+ Mage::helper( 'turpentine/debug' )
49
+ ->logBackTrace();
50
+ Mage::logException( $e );
51
+ if( Mage::helper( 'turpentine/esi' )->getEsiDebugEnabled() ) {
52
+ throw $e;
53
+ }
54
+ }
55
  }
56
 
57
  /**
553
  /**
554
  * Check this request against the cms, standard, and default routers to fill
555
  * the module/controller/action/route fields.
556
+ *
557
  * TODO: This whole thing is a gigantic hack. Would be nice to have a
558
  * better solution.
559
  *
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php CHANGED
@@ -280,12 +280,17 @@ class Nexcessnet_Turpentine_Model_Observer_Ban extends Varien_Event_Observer {
280
  implode( '|', array_unique( $productIds ) ) );
281
  $patterns[] = sprintf( '/review/product/view/id/%d/',
282
  $review->getEntityId() );
283
- $patterns[] = sprintf( '(?:%s)', implode( '|',
284
- array_unique( array_map(
285
- create_function( '$p',
286
- 'return $p->getUrlModel()->formatUrlKey( $p->getName() );' ),
287
- $products ) )
288
- ) );
 
 
 
 
 
289
  $urlPattern = implode( '|', $patterns );
290
 
291
  $result = $this->_getVarnishAdmin()->flushUrl( $urlPattern );
280
  implode( '|', array_unique( $productIds ) ) );
281
  $patterns[] = sprintf( '/review/product/view/id/%d/',
282
  $review->getEntityId() );
283
+ $productPatterns = array();
284
+ foreach ( $products as $p ) {
285
+ $urlKey = $p->getUrlModel()->formatUrlKey( $p->getName() );
286
+ if ( $urlKey ) {
287
+ $productPatterns[] = $urlKey;
288
+ }
289
+ }
290
+ if ( !empty($productPatterns) ) {
291
+ $productPatterns = array_unique( $productPatterns );
292
+ $patterns[] = sprintf( '(?:%s)', implode( '|', $productPatterns ) );
293
+ }
294
  $urlPattern = implode( '|', $patterns );
295
 
296
  $result = $this->_getVarnishAdmin()->flushUrl( $urlPattern );
app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php CHANGED
@@ -329,9 +329,11 @@ class Nexcessnet_Turpentine_Model_Observer_Esi extends Varien_Event_Observer {
329
  foreach( $childBlocks as $blockName ) {
330
  foreach( $layout->getUpdate()->getHandles() as $handle ) {
331
  // check if this handle has any block or reference tags that
332
- // refer to this block or a child block
333
- if( $layoutXml->xpath( sprintf(
334
- '//%s//*[@name=\'%s\']', $handle, $blockName ) ) ) {
 
 
335
  $activeHandles[] = $handle;
336
  }
337
  }
329
  foreach( $childBlocks as $blockName ) {
330
  foreach( $layout->getUpdate()->getHandles() as $handle ) {
331
  // check if this handle has any block or reference tags that
332
+ // refer to this block or a child block, unless the handle name
333
+ // is blank
334
+ if( $handle !== '' &&
335
+ $layoutXml->xpath( sprintf(
336
+ '//%s//*[@name=\'%s\']', $handle, $blockName ) ) ) {
337
  $activeHandles[] = $handle;
338
  }
339
  }
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php CHANGED
@@ -549,10 +549,10 @@ if (req.http.User-Agent ~ "iP(?:hone|ad|od)|BlackBerry|Palm|Googlebot-Mobile|Mob
549
  set req.http.X-Normalized-User-Agent = "msie";
550
  } else if (req.http.User-Agent ~ "Firefox") {
551
  set req.http.X-Normalized-User-Agent = "firefox";
552
- } else if (req.http.User-Agent ~ "Safari") {
553
- set req.http.X-Normalized-User-Agent = "safari";
554
  } else if (req.http.User-Agent ~ "Chrome") {
555
  set req.http.X-Normalized-User-Agent = "chrome";
 
 
556
  } else if (req.http.User-Agent ~ "Opera") {
557
  set req.http.X-Normalized-User-Agent = "opera";
558
  } else {
549
  set req.http.X-Normalized-User-Agent = "msie";
550
  } else if (req.http.User-Agent ~ "Firefox") {
551
  set req.http.X-Normalized-User-Agent = "firefox";
 
 
552
  } else if (req.http.User-Agent ~ "Chrome") {
553
  set req.http.X-Normalized-User-Agent = "chrome";
554
+ } else if (req.http.User-Agent ~ "Safari") {
555
+ set req.http.X-Normalized-User-Agent = "safari";
556
  } else if (req.http.User-Agent ~ "Opera") {
557
  set req.http.X-Normalized-User-Agent = "opera";
558
  } else {
app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php CHANGED
@@ -137,8 +137,16 @@ class Nexcessnet_Turpentine_EsiController extends Mage_Core_Controller_Front_Act
137
  Mage::register( $key, $value, true );
138
  }
139
  foreach( $esiData->getComplexRegistry() as $key => $data ) {
140
- $value = Mage::getModel( $data['model'] )->load( $data['id'] );
141
- Mage::register( $key, $value, true );
 
 
 
 
 
 
 
 
142
  }
143
  $layout = Mage::getSingleton( 'core/layout' );
144
  Mage::getSingleton( 'core/design_package' )
@@ -156,6 +164,7 @@ class Nexcessnet_Turpentine_EsiController extends Mage_Core_Controller_Front_Act
156
  $esiData->getNameInLayout() ) ) );
157
  if( $blockNode instanceof Varien_Simplexml_Element ) {
158
  $nodesToGenerate = Mage::helper( 'turpentine/data' )
 
159
  ->getChildBlockNames( $blockNode );
160
  Mage::getModel( 'turpentine/shim_mage_core_layout' )
161
  ->shim_generateFullBlock( $blockNode );
137
  Mage::register( $key, $value, true );
138
  }
139
  foreach( $esiData->getComplexRegistry() as $key => $data ) {
140
+ $value = Mage::getModel( $data['model'] );
141
+ if( !is_object( $value ) ) {
142
+ Mage::helper( 'turpentine/debug' )->logWarn(
143
+ 'Failed to register key/model: %s as %s(%s)',
144
+ $key, $data['model'], $data['id'] );
145
+ continue;
146
+ } else {
147
+ $value->load( $data['id'] );
148
+ Mage::register( $key, $value, true );
149
+ }
150
  }
151
  $layout = Mage::getSingleton( 'core/layout' );
152
  Mage::getSingleton( 'core/design_package' )
164
  $esiData->getNameInLayout() ) ) );
165
  if( $blockNode instanceof Varien_Simplexml_Element ) {
166
  $nodesToGenerate = Mage::helper( 'turpentine/data' )
167
+ ->setLayout( $layout )
168
  ->getChildBlockNames( $blockNode );
169
  Mage::getModel( 'turpentine/shim_mage_core_layout' )
170
  ->shim_generateFullBlock( $blockNode );
app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php CHANGED
@@ -213,8 +213,14 @@ class Nexcessnet_Turpentine_Varnish_ManagementController
213
 
214
  switch( $type ) {
215
  case 'default':
216
- $cookieModel->set( $cookieName,
217
- Mage::helper( 'turpentine/varnish' )->getSecretHandshake() );
 
 
 
 
 
 
218
  $adminSession->addSuccess( Mage::helper( 'turpentine/data' )
219
  ->__( 'The Varnish bypass cookie has been successfully added.' ) );
220
  break;
213
 
214
  switch( $type ) {
215
  case 'default':
216
+ $cookieModel->set(
217
+ $cookieName,
218
+ Mage::helper( 'turpentine/varnish' )->getSecretHandshake(),
219
+ null, // period
220
+ null, // path
221
+ null, // domain
222
+ false, // secure
223
+ true ); // httponly
224
  $adminSession->addSuccess( Mage::helper( 'turpentine/data' )
225
  ->__( 'The Varnish bypass cookie has been successfully added.' ) );
226
  break;
app/code/community/Nexcessnet/Turpentine/etc/config.xml CHANGED
@@ -20,7 +20,7 @@
20
  <config>
21
  <modules>
22
  <Nexcessnet_Turpentine>
23
- <version>0.5.4</version>
24
  </Nexcessnet_Turpentine>
25
  </modules>
26
  <default>
20
  <config>
21
  <modules>
22
  <Nexcessnet_Turpentine>
23
+ <version>0.5.5</version>
24
  </Nexcessnet_Turpentine>
25
  </modules>
26
  <default>
app/code/community/Nexcessnet/Turpentine/misc/uuid.c CHANGED
@@ -12,7 +12,8 @@ void generate_uuid(char* buf) {
12
  long c = lrand48();
13
  long d = lrand48();
14
  pthread_mutex_unlock(&lrand_mutex);
15
- sprintf(buf, "frontend=%08lx-%04lx-%04lx-%04lx-%04lx%08lx",
 
16
  a,
17
  b & 0xffff,
18
  (b & ((long)0x0fff0000) >> 16) | 0x4000,
12
  long c = lrand48();
13
  long d = lrand48();
14
  pthread_mutex_unlock(&lrand_mutex);
15
+ // SID must match this regex for Kount compat /^\w{1,32}$/
16
+ sprintf(buf, "frontend=%08lx%04lx%04lx%04lx%04lx%08lx",
17
  a,
18
  b & 0xffff,
19
  (b & ((long)0x0fff0000) >> 16) | 0x4000,
app/code/community/Nexcessnet/Turpentine/misc/version-2.vcl CHANGED
@@ -41,19 +41,6 @@ C{
41
  {{debug_acl}}
42
 
43
  ## Custom Subroutines
44
- sub remove_cache_headers {
45
- # remove cache headers so we can set our own
46
- remove beresp.http.Cache-Control;
47
- remove beresp.http.Expires;
48
- remove beresp.http.Pragma;
49
- remove beresp.http.Cache;
50
- remove beresp.http.Age;
51
- }
52
-
53
- sub remove_double_slashes {
54
- # remove double slashes from the URL, for higher cache hit rate
55
- set req.url = regsub(req.url, "(.*)//+(.*)", "\1/\2");
56
- }
57
 
58
  sub generate_session {
59
  # generate a UUID and add `frontend=$UUID` to the Cookie header, or use SID
@@ -127,7 +114,8 @@ sub vcl_recv {
127
  return (pipe);
128
  }
129
 
130
- call remove_double_slashes;
 
131
 
132
  {{normalize_encoding}}
133
  {{normalize_user_agent}}
@@ -289,7 +277,11 @@ sub vcl_fetch {
289
  remove beresp.http.Set-Cookie;
290
  }
291
  # we'll set our own cache headers if we need them
292
- call remove_cache_headers;
 
 
 
 
293
 
294
  if (beresp.http.X-Turpentine-Esi == "1") {
295
  esi;
@@ -351,6 +343,9 @@ sub vcl_deliver {
351
  set resp.http.Set-Cookie = resp.http.Set-Cookie "; HttpOnly";
352
  remove resp.http.X-Varnish-Cookie-Expires;
353
  }
 
 
 
354
  set resp.http.X-Opt-Debug-Headers = "{{debug_headers}}";
355
  if (resp.http.X-Opt-Debug-Headers == "true" || client.ip ~ debug_acl ) {
356
  # debugging is on, give some extra info
41
  {{debug_acl}}
42
 
43
  ## Custom Subroutines
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  sub generate_session {
46
  # generate a UUID and add `frontend=$UUID` to the Cookie header, or use SID
114
  return (pipe);
115
  }
116
 
117
+ # remove double slashes from the URL, for higher cache hit rate
118
+ set req.url = regsuball(req.url, "(.*)//+(.*)", "\1/\2");
119
 
120
  {{normalize_encoding}}
121
  {{normalize_user_agent}}
277
  remove beresp.http.Set-Cookie;
278
  }
279
  # we'll set our own cache headers if we need them
280
+ remove beresp.http.Cache-Control;
281
+ remove beresp.http.Expires;
282
+ remove beresp.http.Pragma;
283
+ remove beresp.http.Cache;
284
+ remove beresp.http.Age;
285
 
286
  if (beresp.http.X-Turpentine-Esi == "1") {
287
  esi;
343
  set resp.http.Set-Cookie = resp.http.Set-Cookie "; HttpOnly";
344
  remove resp.http.X-Varnish-Cookie-Expires;
345
  }
346
+ if (req.http.X-Varnish-Esi-Method == "ajax" && req.http.X-Varnish-Esi-Access == "private") {
347
+ set resp.http.Cache-Control = "no-cache";
348
+ }
349
  set resp.http.X-Opt-Debug-Headers = "{{debug_headers}}";
350
  if (resp.http.X-Opt-Debug-Headers == "true" || client.ip ~ debug_acl ) {
351
  # debugging is on, give some extra info
app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl CHANGED
@@ -46,20 +46,6 @@ import std;
46
 
47
  ## Custom Subroutines
48
 
49
- sub remove_cache_headers {
50
- # remove cache headers so we can set our own
51
- unset beresp.http.Cache-Control;
52
- unset beresp.http.Expires;
53
- unset beresp.http.Pragma;
54
- unset beresp.http.Cache;
55
- unset beresp.http.Age;
56
- }
57
-
58
- sub remove_double_slashes {
59
- # remove double slashes from the URL, for higher cache hit rate
60
- set req.url = regsub(req.url, "(.*)//+(.*)", "\1/\2");
61
- }
62
-
63
  sub generate_session {
64
  # generate a UUID and add `frontend=$UUID` to the Cookie header, or use SID
65
  # from SID URL param
@@ -129,7 +115,8 @@ sub vcl_recv {
129
  return (pipe);
130
  }
131
 
132
- call remove_double_slashes;
 
133
 
134
  {{normalize_encoding}}
135
  {{normalize_user_agent}}
@@ -290,7 +277,11 @@ sub vcl_fetch {
290
  unset beresp.http.Set-Cookie;
291
  }
292
  # we'll set our own cache headers if we need them
293
- call remove_cache_headers;
 
 
 
 
294
 
295
  if (beresp.http.X-Turpentine-Esi == "1") {
296
  set beresp.do_esi = true;
@@ -351,6 +342,9 @@ sub vcl_deliver {
351
  set resp.http.Set-Cookie = resp.http.Set-Cookie + "; httponly";
352
  unset resp.http.X-Varnish-Cookie-Expires;
353
  }
 
 
 
354
  if ({{debug_headers}} || client.ip ~ debug_acl) {
355
  # debugging is on, give some extra info
356
  set resp.http.X-Varnish-Hits = obj.hits;
46
 
47
  ## Custom Subroutines
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  sub generate_session {
50
  # generate a UUID and add `frontend=$UUID` to the Cookie header, or use SID
51
  # from SID URL param
115
  return (pipe);
116
  }
117
 
118
+ # remove double slashes from the URL, for higher cache hit rate
119
+ set req.url = regsuball(req.url, "(.*)//+(.*)", "\1/\2");
120
 
121
  {{normalize_encoding}}
122
  {{normalize_user_agent}}
277
  unset beresp.http.Set-Cookie;
278
  }
279
  # we'll set our own cache headers if we need them
280
+ unset beresp.http.Cache-Control;
281
+ unset beresp.http.Expires;
282
+ unset beresp.http.Pragma;
283
+ unset beresp.http.Cache;
284
+ unset beresp.http.Age;
285
 
286
  if (beresp.http.X-Turpentine-Esi == "1") {
287
  set beresp.do_esi = true;
342
  set resp.http.Set-Cookie = resp.http.Set-Cookie + "; httponly";
343
  unset resp.http.X-Varnish-Cookie-Expires;
344
  }
345
+ if (req.http.X-Varnish-Esi-Method == "ajax" && req.http.X-Varnish-Esi-Access == "private") {
346
+ set resp.http.Cache-Control = "no-cache";
347
+ }
348
  if ({{debug_headers}} || client.ip ~ debug_acl) {
349
  # debugging is on, give some extra info
350
  set resp.http.X-Varnish-Hits = obj.hits;
app/design/adminhtml/default/default/template/turpentine/varnish_management.phtml CHANGED
@@ -78,39 +78,37 @@
78
  ->__('Download the generated VCL file.')?>
79
  </td>
80
  </tr>
81
- <?php if(Mage::helper( 'turpentine/varnish' )->isBypassEnabled() === false): ?>
82
- <tr>
83
  <td class="scope-label">
84
  <button
85
- onclick="setLocation('<?php echo $this->getSwitchNavigationUrl( 'default' ); ?>')"
86
  type="button"
87
- class="scalable delete">
88
  <span><?php echo Mage::helper( 'turpentine/data' )
89
- ->__('Activate Varnish Bypass') ?></span>
90
  </button>
91
  </td>
92
  <td class="scope-label">
93
  <?php echo Mage::helper( 'turpentine/data' )
94
- ->__('Create a cookie to bypass Varnish only for your session.')?>
95
  </td>
96
- </tr>
97
- <?php else: ?>
98
- <tr>
99
  <td class="scope-label">
100
  <button
101
- onclick="setLocation('<?php echo $this->getSwitchNavigationUrl( 'varnish' ); ?>')"
102
  type="button"
103
- class="scalable back">
104
  <span><?php echo Mage::helper( 'turpentine/data' )
105
- ->__('Deactivate Varnish Bypass') ?></span>
106
  </button>
107
  </td>
108
  <td class="scope-label">
109
  <?php echo Mage::helper( 'turpentine/data' )
110
- ->__('Remove the bypass cookie and use again Varnish.')?>
111
  </td>
112
- </tr>
113
- <?php endif; ?>
114
  </table>
115
  <?php echo $this->getChildHtml(); ?>
116
 
78
  ->__('Download the generated VCL file.')?>
79
  </td>
80
  </tr>
81
+ <tr>
82
+ <?php if( Mage::helper( 'turpentine/varnish' )->isBypassEnabled() ): ?>
83
  <td class="scope-label">
84
  <button
85
+ onclick="setLocation('<?php echo $this->getSwitchNavigationUrl( 'varnish' ); ?>')"
86
  type="button"
87
+ class="scalable back">
88
  <span><?php echo Mage::helper( 'turpentine/data' )
89
+ ->__('Deactivate Varnish Bypass') ?></span>
90
  </button>
91
  </td>
92
  <td class="scope-label">
93
  <?php echo Mage::helper( 'turpentine/data' )
94
+ ->__('Remove the bypass cookie and use again Varnish.')?>
95
  </td>
96
+ <?php else: ?>
 
 
97
  <td class="scope-label">
98
  <button
99
+ onclick="setLocation('<?php echo $this->getSwitchNavigationUrl( 'default' ); ?>')"
100
  type="button"
101
+ class="scalable delete">
102
  <span><?php echo Mage::helper( 'turpentine/data' )
103
+ ->__('Activate Varnish Bypass') ?></span>
104
  </button>
105
  </td>
106
  <td class="scope-label">
107
  <?php echo Mage::helper( 'turpentine/data' )
108
+ ->__('Create a cookie to bypass Varnish only for your session.')?>
109
  </td>
110
+ <?php endif; ?>
111
+ </tr>
112
  </table>
113
  <?php echo $this->getChildHtml(); ?>
114
 
app/design/frontend/base/default/template/turpentine/ajax.phtml CHANGED
@@ -36,31 +36,46 @@ if( $debugEnabled ) {
36
  * @link http://prototypejs.org/doc/latest/ajax/Ajax/Request/index.html
37
  * @link http://prototypejs.org/doc/latest/dom/Element/replace/index.html
38
  * @link http://madrobby.github.com/scriptaculous/effect-appear/
 
 
 
39
  */
40
- echo sprintf( '<div id="%s" style="display: none">
41
- <script type="text/javascript">
42
- new Ajax.Updater(
43
- "%s",
44
- "%s",
45
- {
46
- method: "get",
47
- evalScripts: true,
48
- %s: function(transport) {
49
- $("%s").appear({
50
- duration: 0.3
51
- });
52
- }
53
- }
54
- );
55
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  </div>
57
- ',
58
- $blockTag,
59
- $blockTag,
60
- $this->getEsiUrl(),
61
- ( $debugEnabled ? 'onComplete' : 'onSuccess' ),
62
- $blockTag
63
- );
64
  if( $debugEnabled ) {
65
  echo sprintf( '<!-- AJAX END [%s] -->', $this->getNameInLayout() ) . PHP_EOL;
66
  }
36
  * @link http://prototypejs.org/doc/latest/ajax/Ajax/Request/index.html
37
  * @link http://prototypejs.org/doc/latest/dom/Element/replace/index.html
38
  * @link http://madrobby.github.com/scriptaculous/effect-appear/
39
+ *
40
+ * @link http://api.jquery.com/jQuery.ajax/
41
+ * @link http://api.jquery.com/fadeIn/
42
  */
43
+ $_prototypeFunction = $debugEnabled ? 'onComplete' : 'onSuccess';
44
+ $_jQueryFunction = $debugEnabled ? 'always' : 'done';
45
+ echo <<<HTML
46
+ <div id="$blockTag" style="display: none">
47
+ <script type="text/javascript">
48
+ (function() {
49
+ var blockTag = {$this->helper('core')->jsonEncode($blockTag)}, esiUrl = {$this->helper('core')->jsonEncode($this->getEsiUrl())};
50
+ if (typeof Ajax === 'object' && typeof Ajax.Updater === 'function') {
51
+ new Ajax.Updater(
52
+ blockTag,
53
+ esiUrl,
54
+ {
55
+ method: "get",
56
+ evalScripts: true,
57
+ {$_prototypeFunction}: function() {
58
+ $(blockTag).appear({
59
+ duration: 0.3
60
+ });
61
+ }
62
+ }
63
+ );
64
+ } else if (typeof jQuery === 'function') {
65
+ jQuery.ajax(
66
+ {
67
+ url: esiUrl,
68
+ type: "get",
69
+ dataType: "html"
70
+ }
71
+ ).{$_jQueryFunction}(function() {
72
+ $(blockTag).fadeIn(300);
73
+ });
74
+ }
75
+ })();
76
+ </script>
77
  </div>
78
+ HTML;
 
 
 
 
 
 
79
  if( $debugEnabled ) {
80
  echo sprintf( '<!-- AJAX END [%s] -->', $this->getNameInLayout() ) . PHP_EOL;
81
  }
package.xml CHANGED
@@ -1 +1,2 @@
1
- <package><name>Nexcessnet_Turpentine</name><license uri="http://opensource.org/licenses/GPL-2.0">GPLv2</license><notes>Supports Magento v1.6 and later</notes><time>18:00:48</time><__packager>build_package.py v0.0.3</__packager><summary>Improves Magento support for Varnish caching and generates 2.1 and 3.0 compatible VCLs.</summary><stability>stable</stability><__commit_hash>80a17eaa84c76c89cbb8bb04c78cf83429c3d084</__commit_hash><version>0.5.4</version><extends /><contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file hash="a0bd4a5632b369b058c0ec5262e0cc49" name="turpentine.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="3c1bc5339a02d0539a84beeac0a2d9de" name="varnish_management.phtml" /></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file hash="abe5ef296ef7c06a672847c50b572473" name="turpentine_esi.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="b268c48251ccfccf5c775d3e85513584" name="esi.phtml" /><file hash="50798888953fd1550e4347c39e395d0a" name="notices.phtml" /><file hash="1b337a1cbca5b87a77a3f2419a517d87" name="ajax.phtml" /></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file hash="58848d4d90973bfd63b466ea181352a5" name="Nexcessnet_Turpentine.xml" /></dir></target><target name="magecommunity"><dir name="Nexcessnet"><dir name="Turpentine"><dir name="controllers"><file hash="a815b132370cd9738e0139d8c04dc2a0" name="EsiController.php" /><dir name="Varnish"><file hash="30411372e1b8e2f7b7474bb7104eb38d" name="ManagementController.php" /></dir></dir><dir name="Helper"><file hash="2d7286c589b7a3e2f8fe873bd12afe3c" name="Debug.php" /><file hash="821797dc5da419ae46bc4cb0bf201b04" name="Varnish.php" /><file hash="6c70ee047ffb07d99a48fb2ebdc1723d" name="Esi.php" /><file hash="97c11b135bcb8789ed9e21596559659f" name="Data.php" /><file hash="9af5e8d9caa1d1b2182e105786ecce65" name="Cron.php" /><file hash="8f0dd23f9a7b98d8254acf18b6750f1e" name="Ban.php" /></dir><dir name="Model"><file hash="c2cb79001524617febbfddf099d09f37" name="Session.php" /><dir name="Observer"><file hash="9d57fad69ff42b71c66ca26bc3372317" name="Debug.php" /><file hash="7244a8ce600e980d612409595b9b6b9b" name="Varnish.php" /><file hash="a0ced6415261abf6d2221fdcf79bfa51" name="Esi.php" /><file hash="a34e79218e8ca1fefad303b9399bda9d" name="Cron.php" /><file hash="bb03f536d3dc2e9dc9efadcd36bda6e6" name="Ban.php" /></dir><dir name="Dummy"><file hash="df083cae5d3ad5774abaa5def3049348" name="Request.php" /></dir><dir name="Config"><dir name="Select"><file hash="9348c5e58037fd97d89b84ccab4ef2d0" name="Toggle.php" /><file hash="dc472f34c25b1688cfa9fa206958c536" name="Version.php" /></dir></dir><dir name="PageCache"><dir name="Container"><file hash="139e8a9bfa209316036e798fff654a8a" name="Notices.php" /></dir></dir><dir name="Varnish"><file hash="fcb8a5582c6f920e910b417c671df6d2" name="Admin.php" /><dir name="Configurator"><file hash="970a058bf2a73a5774b004390fcfaa07" name="Version3.php" /><file hash="4fba0ac0b4837cabec5bbee428d229df" name="Version2.php" /><file hash="627e6251d7bb64afe83f48ee256c16c9" name="Abstract.php" /></dir><dir name="Admin"><file hash="f3d6924ebb2d87ae1feb9717e3aee27e" name="Socket.php" /></dir></dir><dir name="Shim"><dir name="Mage"><dir name="Core"><file hash="821bff6c2fb372e3ffb39abf6453b3f8" name="Layout.php" /><file hash="94d91f8ff1005ce3bf14c4935945563c" name="App.php" /><file hash="43754654bc3bbd046154573efd735dfa" name="Config.php" /></dir></dir></dir></dir><dir name="etc"><file hash="fbcd96b3ecb2aa1986de82ce8c63d9c0" name="config.xml" /><file hash="e9d86f2aa678c844107ca209d012d7fb" name="system.xml" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /></dir><dir name="misc"><file hash="f083d5fbf4634af60ed5bb257197834f" name="uuid.c" /><file hash="181bb1fcaa152953b1377d9ef463c038" name="version-2.vcl" /><file hash="c18396094ee7e640ca9de47f37d8b7ed" name="version-3.vcl" /></dir><dir name="Block"><file hash="e9b03d651a8da9b1d32c4fd2f4781792" name="Management.php" /><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><dir name="Core"><file hash="44a880185b08b2d6d74ca94591c9ddca" name="Messages.php" /></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file hash="a3cc4b92cb6a4956e28da798eb9e17df" name="Toolbar.php" /></dir></dir></dir></dir><dir name="sql" /></dir></dir></target></contents><dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies><authors><author><name>Chris Wells</name><user>nexcess_net</user><email>clwells@nexcess.net</email></author><author><name>Alex Headley</name><user>aheadley_nex</user><email>aheadley@nexcess.net</email></author></authors><date>2013-06-12</date><compatibile /><channel>community</channel><description>Turpentine is a Magento extension to improve Magento's compatibility with Varnish, a very-fast caching reverse-proxy. By default, Varnish doesn't cache requests with cookies and Magento sends the frontend cookie with every request causing a (near) zero hit-rate for Varnish's cache. Turpentine provides Varnish configuration files (VCLs) to work with Magento and modifies Magento's behaviour to significantly improve the cache hit rate.</description></package>
 
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <package><name>Nexcessnet_Turpentine</name><license uri="http://opensource.org/licenses/GPL-2.0">GPLv2</license><notes>Supports Magento v1.6 and later</notes><time>13:53:44</time><__packager>build_package.py v0.0.3</__packager><summary>Improves Magento support for Varnish caching and generates 2.1 and 3.0 compatible VCLs.</summary><stability>stable</stability><__commit_hash>95bf21d410e48b9315afff44449c6475f94d64bc</__commit_hash><version>0.5.5</version><extends /><contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file hash="a0bd4a5632b369b058c0ec5262e0cc49" name="turpentine.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="8bd4e7e4540ed816721907cb0ac03a02" name="varnish_management.phtml" /></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file hash="abe5ef296ef7c06a672847c50b572473" name="turpentine_esi.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="b268c48251ccfccf5c775d3e85513584" name="esi.phtml" /><file hash="50798888953fd1550e4347c39e395d0a" name="notices.phtml" /><file hash="252356c9ea115fca63e52d54f67d755f" name="ajax.phtml" /></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file hash="58848d4d90973bfd63b466ea181352a5" name="Nexcessnet_Turpentine.xml" /></dir></target><target name="magecommunity"><dir name="Nexcessnet"><dir name="Turpentine"><dir name="controllers"><file hash="30386eecb1914f4acfebbbeb1d961dbf" name="EsiController.php" /><dir name="Varnish"><file hash="f5e29a50bef74178fe041024fb4e43a9" name="ManagementController.php" /></dir></dir><dir name="Helper"><file hash="2d7286c589b7a3e2f8fe873bd12afe3c" name="Debug.php" /><file hash="164856b06e87dff0694cde08da4bb4a6" name="Varnish.php" /><file hash="6c70ee047ffb07d99a48fb2ebdc1723d" name="Esi.php" /><file hash="9aaf4cb5cf56bebda267fb8514547dec" name="Data.php" /><file hash="9af5e8d9caa1d1b2182e105786ecce65" name="Cron.php" /><file hash="6b637be4eac4c924fc1f02b2d49699c3" name="Ban.php" /></dir><dir name="Model"><file hash="c2cb79001524617febbfddf099d09f37" name="Session.php" /><dir name="Observer"><file hash="9d57fad69ff42b71c66ca26bc3372317" name="Debug.php" /><file hash="7244a8ce600e980d612409595b9b6b9b" name="Varnish.php" /><file hash="fab188479779fa36715de8219d200da0" name="Esi.php" /><file hash="a34e79218e8ca1fefad303b9399bda9d" name="Cron.php" /><file hash="704cf901bd456b51c263becd0f260d64" name="Ban.php" /></dir><dir name="Dummy"><file hash="2fc1189ace2d0e7383041d16a31df16b" name="Request.php" /></dir><dir name="Config"><dir name="Select"><file hash="9348c5e58037fd97d89b84ccab4ef2d0" name="Toggle.php" /><file hash="dc472f34c25b1688cfa9fa206958c536" name="Version.php" /></dir></dir><dir name="PageCache"><dir name="Container"><file hash="139e8a9bfa209316036e798fff654a8a" name="Notices.php" /></dir></dir><dir name="Varnish"><file hash="fcb8a5582c6f920e910b417c671df6d2" name="Admin.php" /><dir name="Configurator"><file hash="970a058bf2a73a5774b004390fcfaa07" name="Version3.php" /><file hash="4fba0ac0b4837cabec5bbee428d229df" name="Version2.php" /><file hash="ac5bbfdb2bdb563f1cf79efebb16705e" name="Abstract.php" /></dir><dir name="Admin"><file hash="f3d6924ebb2d87ae1feb9717e3aee27e" name="Socket.php" /></dir></dir><dir name="Shim"><dir name="Mage"><dir name="Core"><file hash="821bff6c2fb372e3ffb39abf6453b3f8" name="Layout.php" /><file hash="94d91f8ff1005ce3bf14c4935945563c" name="App.php" /><file hash="43754654bc3bbd046154573efd735dfa" name="Config.php" /></dir></dir></dir></dir><dir name="etc"><file hash="e544276572efd1f7e9c76c79b5b2a304" name="config.xml" /><file hash="e9d86f2aa678c844107ca209d012d7fb" name="system.xml" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /></dir><dir name="misc"><file hash="ba5d5c7263cd90eea3785953e3549041" name="uuid.c" /><file hash="b25a97a8b6d06e2a467bb3939bb66215" name="version-2.vcl" /><file hash="3663d91aa451b42fd3c91bcd6fefe8b5" name="version-3.vcl" /></dir><dir name="Block"><file hash="e9b03d651a8da9b1d32c4fd2f4781792" name="Management.php" /><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><dir name="Core"><file hash="44a880185b08b2d6d74ca94591c9ddca" name="Messages.php" /></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file hash="a3cc4b92cb6a4956e28da798eb9e17df" name="Toolbar.php" /></dir></dir></dir></dir><dir name="sql" /></dir></dir></target></contents><dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies><authors><author><name>Chris Wells</name><user>nexcess_net</user><email>clwells@nexcess.net</email></author><author><name>Alex Headley</name><user>aheadley_nex</user><email>aheadley@nexcess.net</email></author></authors><date>2013-11-20</date><compatibile /><channel>community</channel><description>Turpentine is a Magento extension to improve Magento's compatibility with Varnish, a very-fast caching reverse-proxy. By default, Varnish doesn't cache requests with cookies and Magento sends the frontend cookie with every request causing a (near) zero hit-rate for Varnish's cache. Turpentine provides Varnish configuration files (VCLs) to work with Magento and modifies Magento's behaviour to significantly improve the cache hit rate.</description></package>