Created
April 26, 2011 02:55
-
-
Save scott2449/941713 to your computer and use it in GitHub Desktop.
ref.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
var target = defaultObject || it; | |
//================================================================================================================================================= | |
// BEGIN - Customizations to produce real RESTful URIs instead from representation hierarchy instead of the shameless excuse for URIs dojo is producing | |
//================================================================================================================================================= | |
var targUrl = prefix.substring(0, prefix.length - 1);; | |
var stack = new Array(); | |
var crawler = target; | |
if( crawler.__parent && crawler.__parent.id ){ | |
if(id && id.indexOf('#')>-1){ | |
stack.push(id.substr(id.lastIndexOf('#'))); | |
}else{ | |
stack.push("Attributes/"+it[idAttribute]); | |
} | |
} | |
else{stack.push(it[idAttribute]);} //push the target objects identifier to the stack, if the parent is a first level resource add /Attributes | |
while(crawler.__parent){ | |
stack.push(crawler.__parent.id || crawler.__parent.__id.substr(crawler.__parent.__id.lastIndexOf('#')+1)); //Push the parents id or absolute (jsonref) id to the stack | |
crawler = crawler.__parent; | |
} | |
while(stack.length > 0){ | |
var curr = stack.pop(); | |
if(curr){ | |
targUrl+=(curr.indexOf('#')>-1?'':'/')+ curr; //pop them all off to build RESTful URI | |
} | |
} | |
id = targUrl; | |
//================================================================================================================================================= | |
// END - Customizations to produce real RESTful URIs instead from representation hierarchy instead of the shameless excuse for URIs dojo is producing | |
//================================================================================================================================================= | |
if(id !== undefined){ // if there is an id available... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment