Permalink
Browse files

Externalize api06 URL

  • Loading branch information...
1 parent e122552 commit 5199e0f4027717ef52e70b4060fe0f8c58f684fb @jfirebaugh jfirebaugh committed Dec 29, 2012
Showing with 28 additions and 26 deletions.
  1. +3 −1 index.html
  2. +3 −1 index_packaged.html
  3. +7 −9 js/id/connection.js
  4. +1 −2 js/id/id.js
  5. +7 −8 js/id/oauth.js
  6. +7 −5 test/spec/oauth.js
View
@@ -93,6 +93,8 @@
</head>
<body>
<div id="iD"></div><script>
- var id = iD(document.getElementById('iD'));
+ var id = iD();
+ id.connection().url('http://api06.dev.openstreetmap.org');
+ d3.select("#iD").call(id);
</script></body>
</html>
View
@@ -16,6 +16,8 @@
</head>
<body>
<div id="iD"></div><script>
- var id = iD(document.getElementById('iD'));
+ var id = iD();
+ id.connection().url('http://api06.dev.openstreetmap.org');
+ d3.select("#iD").call(id);
</script></body>
</html>
View
@@ -1,16 +1,16 @@
iD.Connection = function() {
var event = d3.dispatch('auth', 'load'),
- apiURL = 'http://www.openstreetmap.org',
+ url = 'http://www.openstreetmap.org',
connection = {},
refNodes = {},
user = {},
inflight = [],
loadedTiles = {},
- oauth = iD.OAuth().api(apiURL);
+ oauth = iD.OAuth();
function bboxUrl(b) {
- return apiURL + '/api/0.6/map?bbox=' + [b[0][0],b[1][1],b[1][0],b[0][1]];
+ return url + '/api/0.6/map?bbox=' + [b[0][0],b[1][1],b[1][0],b[0][1]];
}
function bboxFromAPI(box, callback) {
@@ -139,7 +139,7 @@ iD.Connection = function() {
}
connection.userUrl = function(username) {
- return apiURL + "/user/" + username;
+ return url + "/user/" + username;
};
function tileAtZoom(t, distance) {
@@ -196,9 +196,9 @@ iD.Connection = function() {
}
connection.url = function(_) {
- if (!arguments.length) return apiURL;
- apiURL = _;
- oauth.api(_);
+ if (!arguments.length) return url;
+ url = _;
+ oauth.url(_);
return connection;
};
@@ -231,9 +231,7 @@ iD.Connection = function() {
connection.loadTiles = _.debounce(loadTiles, 100);
connection.userDetails = userDetails;
connection.authenticated = authenticated;
-
connection.objectData = objectData;
- connection.apiURL = apiURL;
return d3.rebind(connection, event, 'on');
};
View
@@ -1,6 +1,5 @@
window.iD = function(container) {
- var connection = iD.Connection()
- .url('http://api06.dev.openstreetmap.org'),
+ var connection = iD.Connection(),
history = iD.History(),
map = iD.Map()
.connection(connection)
View
@@ -1,6 +1,5 @@
iD.OAuth = function() {
- var baseurl = 'http://api06.dev.openstreetmap.org',
- apibase = 'http://api06.dev.openstreetmap.org',
+ var baseurl = 'http://www.openstreetmap.org',
oauth_secret = 'aMnOOCwExO2XYtRVWJ1bI9QOdqh1cay2UgpbhA6p',
oauth = {};
@@ -24,9 +23,9 @@ iD.OAuth = function() {
// token getter/setter, namespaced to the current `apibase` value.
function token(k, x) {
if (arguments.length == 2) {
- localStorage[keyclean(apibase) + k] = x;
+ localStorage[keyclean(baseurl) + k] = x;
}
- return localStorage[keyclean(apibase) + k];
+ return localStorage[keyclean(baseurl) + k];
}
oauth.authenticated = function() {
@@ -45,7 +44,7 @@ iD.OAuth = function() {
o.oauth_token = token('oauth_token');
}
o = timenonce(o);
- var url = apibase + options.path;
+ var url = baseurl + options.path;
var oauth_token_secret = token('oauth_token_secret');
o.oauth_signature = ohauth.signature(oauth_secret, oauth_token_secret,
ohauth.baseString(options.method, url, o));
@@ -129,9 +128,9 @@ iD.OAuth = function() {
};
- oauth.api = function(_) {
- if (!arguments.length) return apibase;
- apibase = _;
+ oauth.url = function(_) {
+ if (!arguments.length) return baseurl;
+ baseurl = _;
return oauth;
};
View
@@ -1,19 +1,21 @@
-describe('OAuth', function() {
+describe('iD.OAuth', function() {
var o;
+
beforeEach(function() {
o = iD.OAuth();
});
+
describe('#logout', function() {
it('can log out and will no longer be authenticated', function() {
expect(o.logout()).to.equal(o);
expect(o.authenticated()).not.to.be.ok;
});
});
- describe('#api', function() {
+
+ describe('#url', function() {
it('gets and sets url', function() {
- expect(o.api('foo')).to.equal(o);
- expect(o.api()).to.equal('foo');
+ expect(o.url('foo')).to.equal(o);
+ expect(o.url()).to.equal('foo');
});
});
-
});

0 comments on commit 5199e0f

Please sign in to comment.