1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

Fix some minor Celerity / ShapedRequest bugs:

- Force celerity to do disk reads in dev.
  - Clean up some ShapedRequest clownery.
This commit is contained in:
epriestley 2011-05-11 03:42:02 -07:00
parent c51eb2696d
commit 3b8ff34f9b
5 changed files with 30 additions and 15 deletions

View file

@ -349,4 +349,13 @@ return array(
// unlikely that you need to modify this.
'celerity.resource-hash' => 'd9455ea150622ee044f7931dabfa52aa',
// In a development environment, it is desirable to force static resources
// (CSS and JS) to be read from disk on every request, so that edits to them
// appear when you reload the page even if you haven't updated the resource
// maps. This setting ensures requests will be verified against the state on
// disk. Generally, you should leave this off in production (caching behavior
// and performance improve with it off) but turn it on in development. (These
// settings are the defaults.)
'celerity.force-disk-reads' => false,
);

View file

@ -19,5 +19,6 @@
return array(
'darkconsole.enabled' => true,
'celerity.force-disk-reads' => true,
) + phabricator_read_config_file('default');

View file

@ -390,7 +390,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-differential-show-more' =>
array(
'uri' => '/res/7a844635/rsrc/js/application/differential/behavior-show-more.js',
'uri' => '/res/9cbf1c9c/rsrc/js/application/differential/behavior-show-more.js',
'type' => 'js',
'requires' =>
array(
@ -867,7 +867,7 @@ celerity_register_resource_map(array(
),
'phabricator-shaped-request' =>
array(
'uri' => '/res/1f0ef02b/rsrc/js/application/core/ShapedRequest.js',
'uri' => '/res/7b1522d3/rsrc/js/application/core/ShapedRequest.js',
'type' => 'js',
'requires' =>
array(
@ -1005,7 +1005,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/ac70e6b7/core.pkg.css',
'type' => 'css',
),
'b17926e1' =>
'c5d10dfe' =>
array (
'name' => 'differential.pkg.js',
'symbols' =>
@ -1016,7 +1016,7 @@ celerity_register_resource_map(array(
3 => 'javelin-behavior-differential-show-more',
4 => 'javelin-behavior-differential-diff-radios',
),
'uri' => '/res/pkg/b17926e1/differential.pkg.js',
'uri' => '/res/pkg/c5d10dfe/differential.pkg.js',
'type' => 'js',
),
),
@ -1042,11 +1042,11 @@ celerity_register_resource_map(array(
'diffusion-commit-view-css' => '03ef179e',
'javelin-behavior' => '7d23deb1',
'javelin-behavior-aphront-basic-tokenizer' => '33f413ef',
'javelin-behavior-differential-diff-radios' => 'b17926e1',
'javelin-behavior-differential-edit-inline-comments' => 'b17926e1',
'javelin-behavior-differential-feedback-preview' => 'b17926e1',
'javelin-behavior-differential-populate' => 'b17926e1',
'javelin-behavior-differential-show-more' => 'b17926e1',
'javelin-behavior-differential-diff-radios' => 'c5d10dfe',
'javelin-behavior-differential-edit-inline-comments' => 'c5d10dfe',
'javelin-behavior-differential-feedback-preview' => 'c5d10dfe',
'javelin-behavior-differential-populate' => 'c5d10dfe',
'javelin-behavior-differential-show-more' => 'c5d10dfe',
'javelin-behavior-workflow' => '122a6b6d',
'javelin-dom' => '7d23deb1',
'javelin-event' => '7d23deb1',

View file

@ -38,7 +38,8 @@ class CelerityResourceController extends AphrontController {
throw new Exception("Only CSS and JS resources may be served.");
}
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
!PhabricatorEnv::getEnvConfig('celerity.force-disk-reads')) {
// Return a "304 Not Modified". We don't care about the value of this
// field since we never change what resource is served by a given URI.
return $this->makeResponseCacheable(new Aphront304Response());

View file

@ -51,9 +51,11 @@ JX.install('PhabricatorShapedRequest', {
var request = new JX.Request(this._uri, JX.bind(this, function(r) {
this._callback(r);
this._min = new Date().getTime() + this._rateLimit;
this._min = new Date().getTime() + this.getRateLimit();
this._defer && this._defer.stop();
this._defer = JX.defer(JX.bind(this, this.trigger), this._rateLimit);
this._defer = JX.defer(
JX.bind(this, this.trigger),
this.getRateLimit());
}));
request.listen('finally', JX.bind(this, function() {
this._request = null;
@ -62,7 +64,9 @@ JX.install('PhabricatorShapedRequest', {
request.setTimeout(this.getFrequency());
request.send();
} else {
this._defer = JX.defer(JX.bind(this, this.trigger), this._frequency);
this._defer = JX.defer(
JX.bind(this, this.trigger),
this.getFrequency());
}
},
@ -82,7 +86,7 @@ JX.install('PhabricatorShapedRequest', {
},
properties : {
rateLimit : 250,
frequency : 750
rateLimit : 500,
frequency : 1000
}
});