Clean up how OAuth keys are handled

Connection defaults to osm.org URL and keys for the simple
case. Customization is done via connection.switch().

Externalize SourceSwitch's use of iD.data.keys.
This commit is contained in:
John Firebaugh
2013-04-17 17:43:25 -07:00
parent dca9bec450
commit ab56cc5207
5 changed files with 24 additions and 12 deletions

View File

@@ -2,13 +2,11 @@
{
"url": "http://www.openstreetmap.org",
"oauth_consumer_key": "5A043yRSEugj4DJ5TljuapfnrflWDte8jTOcWLlT",
"oauth_secret": "aB3jKq1TRsCOUrfOIZ6oQMEDmv2ptV76PA54NGLL",
"oauth_signature_method": "HMAC-SHA1"
"oauth_secret": "aB3jKq1TRsCOUrfOIZ6oQMEDmv2ptV76PA54NGLL"
},
{
"url": "http://api06.dev.openstreetmap.org",
"oauth_consumer_key": "zwQZFivccHkLs3a8Rq5CoS412fE5aPCXDw9DZj7R",
"oauth_secret": "aMnOOCwExO2XYtRVWJ1bI9QOdqh1cay2UgpbhA6p",
"oauth_signature_method": "HMAC-SHA1"
"oauth_secret": "aMnOOCwExO2XYtRVWJ1bI9QOdqh1cay2UgpbhA6p"
}
]

View File

@@ -217,7 +217,8 @@
d3.select("#about").insert('li', '.user-list')
.attr('class', 'source-switch')
.call(iD.ui.SourceSwitch(id));
.call(iD.ui.SourceSwitch(id)
.keys(iD.data.keys));
});
</script>
</body>

View File

@@ -1,15 +1,18 @@
iD.Connection = function(options) {
iD.Connection = function() {
var event = d3.dispatch('authenticating', 'authenticated', 'auth', 'loading', 'load', 'loaded'),
url = options.url || 'http://www.openstreetmap.org',
url = 'http://www.openstreetmap.org',
connection = {},
user = {},
inflight = {},
loadedTiles = {},
oauth = osmAuth(_.extend({
oauth = osmAuth({
url: 'http://www.openstreetmap.org',
oauth_consumer_key: '5A043yRSEugj4DJ5TljuapfnrflWDte8jTOcWLlT',
oauth_secret: 'aB3jKq1TRsCOUrfOIZ6oQMEDmv2ptV76PA54NGLL',
loading: authenticating,
done: authenticated
}, options)),
}),
ndStr = 'nd',
tagStr = 'tag',
memberStr = 'member',

View File

@@ -23,7 +23,7 @@ window.iD = function () {
container,
ui = iD.ui(context),
map = iD.Map(context),
connection = iD.Connection(iD.data.keys[0]);
connection = iD.Connection();
connection.on('load.context', function loadContext(err, result) {
history.merge(result);

View File

@@ -1,4 +1,6 @@
iD.ui.SourceSwitch = function(context) {
var keys;
function click() {
d3.event.preventDefault();
@@ -9,7 +11,7 @@ iD.ui.SourceSwitch = function(context) {
.classed('live');
context.connection()
.switch(live ? iD.data.keys[1] : iD.data.keys[0]);
.switch(live ? keys[1] : keys[0]);
context.map()
.flush();
@@ -19,7 +21,7 @@ iD.ui.SourceSwitch = function(context) {
.classed('live', !live);
}
return function(selection) {
var sourceSwitch = function(selection) {
selection.append('a')
.attr('href', '#')
.text(t('source_switch.live'))
@@ -27,4 +29,12 @@ iD.ui.SourceSwitch = function(context) {
.attr('tabindex', -1)
.on('click', click);
};
sourceSwitch.keys = function(_) {
if (!arguments.length) return keys;
keys = _;
return sourceSwitch;
};
return sourceSwitch;
};