Skip to content

Commit

Permalink
Add cordova file url support
Browse files Browse the repository at this point in the history
  • Loading branch information
pointful-mikkel committed Jan 12, 2016
1 parent ca253f9 commit 85e9dad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions modules/miso.util.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ module.exports = {
return typeof m.route.param(key) !== "undefined"? m.route.param(key): def;
},

// Get cordova or normal relative url
url: function(relativeUrl){
var myCordova = typeof cordova !== "undefined"? cordova: {
file: {
applicationDirectory: ""
}
};
return myCordova.file.applicationDirectory + relativeUrl;
},

// Get info for an action from the params
routeInfo: function(params){
/*
Expand Down
10 changes: 10 additions & 0 deletions modules/miso.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ module.exports = {
obj.query[key]: def;
},

// Get cordova or normal relative url
url: function(relativeUrl){
var myCordova = typeof cordova !== "undefined"? cordova: {
file: {
applicationDirectory: ""
}
};
return myCordova.file.applicationDirectory + relativeUrl;
},

// Testing ready binder
// NOTE: We somehow need to share this with the createRoute method...
readyBinderFactory: function(){
Expand Down
2 changes: 1 addition & 1 deletion system/api/api_endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function(app, apiType, apiPath, apiRequirePath){
};

// CORS headers to allow Cordova to work
// TODO: Limit to required domain
// TODO: Limit to allowed origin
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS");
res.header("Access-Control-Allow-Headers", "Content-type,Accept,X-Custom-Header");
Expand Down

0 comments on commit 85e9dad

Please sign in to comment.