Created
September 3, 2010 19:15
-
-
Save lsmith/564394 to your computer and use it in GitHub Desktop.
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
<!doctype html> | |
<html> | |
<head> | |
<title>Test Page</title> | |
</head><body> | |
<input type="hidden" id="task1" value="Node loaded from YQL"> | |
<ul id="tasks"></ul> | |
<script src="/dev/yui/yui3/build/yui/yui-min.js"></script> | |
<!--script src="/dev/yui/yui3/build/loader/loader.js"></script--> | |
<script> | |
(function () { | |
var i = 23, | |
yql = "http://query.yahooapis.com/v1/public/yql?q=", | |
query = | |
encodeURIComponent('USE "http://lucassmith.name/pub/yql/rls.xml?v=' + i | |
+ '" AS yui;') + | |
encodeURIComponent('SELECT * FROM yui WHERE m = "') + "{m}" + | |
encodeURIComponent('" AND env = "') + "{env}" + | |
encodeURIComponent('" AND v = "') + "{v}" + | |
encodeURIComponent('" AND filt = "') + "{filt}" + | |
encodeURIComponent('";') + "&format=json&callback=YUI.unbox"; | |
YUI.unbox = function (o) { | |
payload = o.query.results.result; | |
if (payload) { | |
// Execute module YUI.add(...)s | |
if (payload.js && !/Undefined@/.test(payload.js)) { | |
eval(payload.js); | |
} | |
// Add css by inserting a <style> node ala Y.StyleSheet | |
if (payload.css && !/Undefined@/.test(payload.css)) { | |
var style = document.createElement('style'); | |
style.type = 'text/css'; | |
document.getElementsByTagName('head')[0].appendChild(style); | |
if (style.sheet) { | |
style.appendChild(document.createTextNode(payload.css)); | |
} else { | |
style.styleSheet.cssText = payload.css; | |
} | |
} | |
} | |
}; | |
YUI({ | |
filter : 'raw', | |
use_rls : true, | |
rls_base: yql, | |
rls_tmpl: query | |
}).use('node', function (Y) { | |
Y.one("#tasks").append("<li>" + Y.one("#task1").get("value") + "</li>"); | |
Y.one('body').append('<div id="slider"></div>'); | |
}); | |
})(); | |
</script> | |
</body> | |
</html> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> | |
<meta> | |
<author>Luke Smith</author> | |
<documentationURL>None</documentationURL> | |
<description>YUI 3 remote loader</description> | |
<!--sampleQuery>SELECT * FROM {table} WHERE a = 5 AND b = 10</sampleQuery--> | |
</meta> | |
<bindings> | |
<select itemPath="" produces="JSON"> | |
<inputs> | |
<key id="m" type="xs:string" paramType="variable" required="true"/> | |
<key id="env" type="xs:string" paramType="variable" required="true"/> | |
<key id="v" type="xs:string" paramType="variable" default="3.2.0pr1"/> | |
<key id="gv" type="xs:string" paramType="variable" default="gallery-2010.08.25-19-45"/> | |
<key id="lang" type="xs:string" paramType="variable" default="en"/> | |
<key id="filt" type="xs:string" paramType="variable" default="min"/> | |
<key id="2in3v" type="xs:string" paramType="variable" required="false"/> | |
<key id="2v" type="xs:string" paramType="variable" required="false"/> | |
<key id="filts" type="xs:string" paramType="variable" required="false"/> | |
<key id="tests" type="xs:string" paramType="variable" required="false"/> | |
</inputs> | |
<execute><![CDATA[ | |
var root = "http://yui.yahooapis.com/combo?", | |
seed = root + v + "/build/yui/yui-min.js&" + | |
v + "/build/loader/loader-min.js", | |
doc = { documentElement: {} }, | |
loaded = env.split(/,/), | |
Y, i; | |
response.object = { | |
requested: m, | |
ignored : env, | |
ver : v, | |
filter : filt | |
}; | |
try { | |
// Import the requested version of YUI and create an instance to | |
// leverage the Loader | |
y.include(seed); | |
Y = YUI({ | |
win : { document: doc }, | |
doc : doc, | |
filter : filt, | |
gallery: gv | |
}); | |
// Tricking Loader into thinking env modules are already loaded | |
for (i = loaded.length - 1; i >= 0; --i) { | |
YUI.Env.mods[loaded[i]] = { details: {} }; | |
} | |
// Get.script will receive the combo url with all the missing | |
// dependencies, so just make a rest call for the js content | |
// response | |
Y.Get.script = function (modURL) { | |
response.object.js = y.rest(modURL).get().response; | |
}; | |
// Same for CSS | |
Y.Get.css = function (skinURL, conf) { | |
response.object.css = y.rest(skinURL).get().response; | |
//conf.context.loadNext(); | |
}; | |
// use() the modules to trigger Loader to do the dependency | |
// resolution eventually routing to Get.script (above). | |
Y.use.apply(Y, m.split(/,/)); | |
Y = null; | |
} | |
catch (e) { | |
response.object.error = error; | |
} | |
// Step 4. Profit | |
]]></execute> | |
</select> | |
</bindings> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment