From 66af1dd3e5aa80b257ba711600d112752ecaf655 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 17 Feb 2012 00:19:48 -0800 Subject: Adding Chrome webRequest intercept Need to add logic to resolve file's actual URL dynamically. --- js/controllers/document-controller.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index b1a22c1b..9785d824 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -56,12 +56,37 @@ DocumentController = exports.DocumentController = Montage.create(Component, { this.eventManager.addEventListener("executeSave", this, false); this.eventManager.addEventListener("recordStyleChanged", this, false); + + + } }, + + + handleWebRequest: { + value: function (request) { + if (request.url.indexOf('js/document/templates/montage-html') !== -1) { + + console.log(request); + + //TODO: Figure out why active document is not available here + + /* +if (request.url.indexOf('calculator.css') !== -1) { + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+'/calculator/components/calculator.reel/calculator.css'}; + } +*/ + } + } + }, + handleAppLoaded: { value: function() { // + + chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: [""]}, ["blocking"]); + } }, -- cgit v1.2.3 From a42c536c2b3209afc058eabd31167bd0aa6f71c8 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 17 Feb 2012 13:40:38 -0800 Subject: Adding webRequest redirects for iFrame templates --- js/controllers/document-controller.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 9785d824..5e2a6461 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -14,7 +14,7 @@ var Montage = require("montage/core/core").Montage, DocumentController; //////////////////////////////////////////////////////////////////////// // -DocumentController = exports.DocumentController = Montage.create(Component, { +var DocumentController = exports.DocumentController = Montage.create(Component, { hasTemplate: { value: false }, @@ -22,6 +22,10 @@ DocumentController = exports.DocumentController = Montage.create(Component, { _documents: { value: [] }, + + _hackRootFlag: { + value: false + }, _activeDocument: { value: null }, _iframeCounter: { value: 1, enumerable: false }, @@ -71,11 +75,13 @@ DocumentController = exports.DocumentController = Montage.create(Component, { //TODO: Figure out why active document is not available here - /* -if (request.url.indexOf('calculator.css') !== -1) { - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+'/calculator/components/calculator.reel/calculator.css'}; + if (this._hackRootFlag) { + + //console.log(request.url.split('/')[request.url.split('/').length-1]); + //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]); + + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; } -*/ } } }, @@ -205,6 +211,9 @@ if (request.url.indexOf('calculator.css') !== -1) { // openDocument: { value: function(doc) { + + // + this.documentHackReference = doc; // switch (doc.extension) { case 'html': case 'html': @@ -302,7 +311,6 @@ if (request.url.indexOf('calculator.css') !== -1) { _onOpenDocument: { value: function(doc){ //var data = DocumentManager.activeDocument; - this._hideCurrentDocument(); this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); -- cgit v1.2.3