Skip to content

Commit

Permalink
Merge pull request #44 from euforic/TIMOB-14644
Browse files Browse the repository at this point in the history
[TIMOB-14644] Liveview does not read files from platform specific folder.
  • Loading branch information
Christian Sullivan committed Jul 25, 2013
2 parents d3e20ca + 0a97ad7 commit 1d38821
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions build/liveview.js
Expand Up @@ -17,7 +17,7 @@ function Process() {
this.moduleLoadList = [];
this.versions = {};
this.arch = Ti.Platform.architecture;
this.platform = Ti.Platform.name;
this.platform = Ti.Platform.osname;
this.hardware = ('' + Ti.Platform.model).replace('google_');
}

Expand Down Expand Up @@ -468,7 +468,7 @@ Module.connectServer = function() {

Module.include = function(ctx,id) {
var file = id.replace('.js', '');
var src = Module.prototype._getRemoteSource(file,10000);
var src = Module.prototype._getRemoteSource(file,1000);
eval.call(ctx,src);
};

Expand Down Expand Up @@ -538,6 +538,7 @@ Module.prototype._getRemoteSource = function(file,timeout){
var file = 'http://' + Module._url + ':' + Module._port + '/' + (file || this.id) + '.js';
request.cache = false;
request.open("GET", file);
request.setRequestHeader('x-platform', process.platform);
request.send();
while(!rsp){
if (request.readyState === 4 ) {
Expand Down
2 changes: 1 addition & 1 deletion build/liveview.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/fserver.js
Expand Up @@ -143,6 +143,8 @@ FServer.start = function(opts) {
// create static file server
var fServer = http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname;
var requestPlatform = request.headers['x-platform'];
var platformFilepath = join(RESOURCE_DIR, requestPlatform, uri);
var filename = join(RESOURCE_DIR, uri);

if (uri === '/') {
Expand All @@ -155,6 +157,12 @@ FServer.start = function(opts) {
return;
}

debug(util.inspect(request.headers));

filename = (fs.existsSync(platformFilepath))
? platformFilepath
: filename;

fs.exists(filename, function(exists) {
fileCount[filename] = (fileCount[filename] || 0) + 1;

Expand Down
2 changes: 1 addition & 1 deletion lib/platform/process.js
Expand Up @@ -12,7 +12,7 @@ function Process() {
this.moduleLoadList = [];
this.versions = {};
this.arch = Ti.Platform.architecture;
this.platform = Ti.Platform.name;
this.platform = Ti.Platform.osname;
this.hardware = ('' + Ti.Platform.model).replace('google_');
}

Expand Down
3 changes: 2 additions & 1 deletion lib/platform/require.js
Expand Up @@ -154,7 +154,7 @@ Module.connectServer = function() {

Module.include = function(ctx,id) {
var file = id.replace('.js', '');
var src = Module.prototype._getRemoteSource(file,10000);
var src = Module.prototype._getRemoteSource(file,1000);
eval.call(ctx,src);
};

Expand Down Expand Up @@ -224,6 +224,7 @@ Module.prototype._getRemoteSource = function(file,timeout){
var file = 'http://' + Module._url + ':' + Module._port + '/' + (file || this.id) + '.js';
request.cache = false;
request.open("GET", file);
request.setRequestHeader('x-platform', process.platform);
request.send();
while(!rsp){
if (request.readyState === 4 ) {
Expand Down

0 comments on commit 1d38821

Please sign in to comment.