Skip to content

Commit

Permalink
Fixed initial view load
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer-Lahav committed Aug 25, 2011
1 parent 132d54e commit b077e3d
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 18 deletions.
8 changes: 4 additions & 4 deletions clients/view/js/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

var options = {

nativeDomain: postmile.domain,
nativeDomain: postmile.web.domain,
nativeClientId: 'postmile.view',
clientProfileURI: 'client.json',
loginURI: 'https://' + postmile.domain + '/login',
authorizationEndpointURI: 'https://' + postmile.domain + '/oauth/authorize',
issueEndpointURI: 'https://' + postmile.domain + '/oauth/issue'
loginURI: postmile.web.uri + '/login',
authorizationEndpointURI: postmile.web.uri + '/oauth/authorize',
issueEndpointURI: postmile.web.uri + '/oauth/issue'
};


Expand Down
6 changes: 3 additions & 3 deletions clients/view/js/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function bindInviteOverlay() {
// needs to be URL encoded since it's a query param
var message = encodeURIComponent( inviteMessage.get( 'value' ) ) ;

var uri = "http://api." + postmile.domain + "/sled/" + gsled.sled.id + "/participants?message=" + message ;
var uri = postmile.api.uri + "/sled/" + gsled.sled.id + "/participants?message=" + message ;

var newParticipants = inviteEmails.get( 'value' ).replace(/^\s+|\s+$/g,"") ;
newParticipants = newParticipants.split( ',' ) ;
Expand Down Expand Up @@ -464,8 +464,8 @@ function bindManageOverlay() {
}
} ;

var askRemove = function( arg ) {
var uri = "http://api." + postmile.domain + "/sled/" + gsled.sled.id + "/participants" ;
var askRemove = function( arg ) {
var uri = postmile.api.uri + "/sled/" + gsled.sled.id + "/participants";
deleteJson( uri, json, confirmRemove ) ;
} ;
askHeader = participants.length > 1 ? 'Remove Participants?' : 'Remove Participant?' ;
Expand Down
6 changes: 3 additions & 3 deletions clients/view/js/loadsled.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ preBody = function() {
}
}

getJson("http://api." + postmile.domain + "/sled/" + initialSledId + "/tasks", gotTasks);
getJson("http://api." + postmile.domain + "/sled/" + initialSledId, gotSled);
getJson(postmile.api.uri + "/sled/" + initialSledId + "/tasks", gotTasks);
getJson(postmile.api.uri + "/sled/" + initialSledId, gotSled);
}

if( fragSled ) {
confirmActiveSled( { activesled: fragSled } );
} else {
getJson("http://api." + postmile.domain + "/storage/activesled", confirmActiveSled); // sync these:?
getJson(postmile.api.uri + "/storage/activesled", confirmActiveSled); // sync these:?
}

}
Expand Down
4 changes: 2 additions & 2 deletions clients/view/js/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function xFire( e, a1, a2, a3 ) {
}

if (uri.indexOf('http://') !== 0 && uri.indexOf('https://') !== 0) {
uri = 'http://api.' + postmile.domain + '/' + uri;
uri = postmile.api.uri + '/' + uri;
}

// Calculate Signature
Expand Down Expand Up @@ -118,7 +118,7 @@ function xFire( e, a1, a2, a3 ) {
} ;
if (jsonResponse.message === 'Insufficient TOS accepted') {
// getCredentials(function () {}/*, true*/); // not refreshCredentials();
window.location = 'https://' + postmile.domain + '/login';
window.location = postmile.api.uri + '/login';
} else {
xFire( 'sled:askJoinCurrentSled', true, retryRequest ) ;
}
Expand Down
2 changes: 1 addition & 1 deletion clients/view/js/sled-load-min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clients/view/js/sled.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,14 @@ YUI.add('sledsled', function (Y) {
var logout = Y.one("#account-menu #logout");
if (logout) {
logout.on('click', function (e) {
window.location = "https://" + postmile.domain + "/logout";
window.location = postmile.api.uri + "/logout";
});
}

var account = Y.one("#account-menu #accountsettings");
if (account) {
account.on('click', function (e) {
window.location = "https://" + postmile.domain + "/account";
window.location = postmile.api.uri + "/account";
});
}

Expand Down
2 changes: 1 addition & 1 deletion clients/view/js/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ function updateSuggestions( message ) {

function bind( ) {

socket = new io.Socket('api.' + postmile.domain, { port: 80, rememberTransport: false });
socket = new io.Socket(postmile.api.domain, { port: postmile.api.port, rememberTransport: false });

socket.on('connect', function () {
Y.log( 'Connected!' ) ;
Expand Down
7 changes: 6 additions & 1 deletion web/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

var Email = require('./email');
var Config = require('./config');
var Utils = require('./utils');


// Welcome page
Expand Down Expand Up @@ -84,7 +85,11 @@ exports.feedback = function (req, res, next) {

exports.config = function (req, res, next) {

res.api.result = 'var postmile = { domain: \'' + Config.host.web.domain + '\', scheme: \'' + Config.host.web.scheme + '\' };';
var config = Utils.clone(Config.host);
config.web.uri = Config.host.uri('web');
config.web.api = Config.host.uri('api');

res.api.result = 'var postmile = ' + JSON.stringify(config) + ';';
res.api.isAPI = true;
next();
};
31 changes: 31 additions & 0 deletions web/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,37 @@ exports.getTimestamp = function () {
};


// Clone object or array

exports.clone = function (obj) {

if (obj === null ||
obj === undefined) {

return null;
}

var newObj = (obj instanceof Array) ? [] : {};

for (var i in obj) {

if (obj.hasOwnProperty(i)) {

if (obj[i] && typeof obj[i] === 'object') {

newObj[i] = exports.clone(obj[i]);
}
else {

newObj[i] = obj[i];
}
}
}

return newObj;
};


// Validate email address

exports.checkEmail = function (email) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion web/views/developer.jade
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
.part API Test Utility

.text An
a(href: '/test/api') API test utility
a(href: '/developer/console') API test utility
| is available to assist in learning and experimenting with the Sled API. The utility includes easy to read source code which can be
| copied and used for writing JavaScript-based clients. It also includes basic
a(href: '#stream') streaming updates
Expand Down

0 comments on commit b077e3d

Please sign in to comment.