Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
houyhnhnm committed Feb 13, 2012
2 parents a06fdd6 + e05def8 commit ba29205ccd60a3563089c6ff98c4264f91c80e2f
View
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
- <sampleQuery>select * from {table} where account='sam@sampullara.com'</sampleQuery>
+ <sampleQuery>select * from {table} where account='pfefferle@notizblog.org'</sampleQuery>
</meta>
<bindings>
<select itemPath="" produces="XML">
<urls>
- <url>http://webfinger/</url>
+ <url>http://code.google.com/p/webfinger/</url>
</urls>
<inputs>
<key id='account' type='xs:string' paramType='variable' required='true'/>
@@ -23,18 +23,21 @@ if (split.length != 2) {
var id = split[0];
var domain = split[1];
// Check for the host-meta
-var hostmeta = y.rest("http://" + domain + "/.well-known/host-meta").contentType("application/xml").get();
+var hostmeta = y.rest("http://" + domain + "/.well-known/host-meta").accept("application/xrd+xml").contentType("application/xml").get();
if (hostmeta.status != 200) {
response.object = <error>status: {hostmeta.status}</error>;
y.exit();
}
+
hostmeta = hostmeta.response;
if (!(hostmeta.respo instanceof XML)) {
hostmeta = hostmeta.substring(hostmeta.indexOf("?>") + 2).replace("{", "<![CDATA[{]" + "]>");
hostmeta = eval("var a__ = " + hostmeta + ";a__;");
}
-default xml namespace = 'http://host-meta.net/xrd/1.0';
-var host = hostmeta..Host;
+
+hostmeta = y.xmlToJson(hostmeta);
+
+var host = hostmeta.XRD.Host;
if (!host) {
response.object = <error><message>Host not found</message><hostmeta>{hostmeta.response}</hostmeta></error>;
y.exit();
@@ -43,28 +46,33 @@ if (host != domain) {
response.object = <error><message>Domain mismatch</message><hostmeta>{hostmeta.response}</hostmeta></error>;
y.exit();
}
-default xml namespace = 'http://docs.oasis-open.org/ns/xri/xrd-1.0';
-var links = hostmeta.Link;
+
+var links = hostmeta.XRD.Link;
for (var i in links) {
- var link = links[i];
- var rels = link.Rel;
- for (var j in rels) {
- var rel = rels[j];
- if (rel.toLowerCase() == "http://webfinger.info/rel/service" || rel.toLowerCase() == "describedby") {
- var url = link.URITemplate.toString().replace("{%id}", encodeURI(account));
- url = url.replace("{%uri}", encodeURI("acct:" + account));
- url = url.replace("{id}", account);
- url = url.replace("{uri}", "acct:" + account);
- url = url.replace("{userInfo}", id);
- url = url.replace("{%userInfo}", encodeURI(id));
- url = url.replace("{host}", domain);
- url = url.replace("{%host}", encodeURI(domain));
- response.object = y.rest(url).get().response;
- y.exit();
- }
- }
+ var link = links[i];
+ var rel = link.rel;
+ if (rel.toLowerCase() == "lrdd") {
+ var url = link.template.replace("{%id}", encodeURI(account));
+ url = url.replace("{%uri}", encodeURI("acct:" + account));
+ url = url.replace("{id}", account);
+ url = url.replace("{uri}", "acct:" + account);
+ url = url.replace("{userInfo}", id);
+ url = url.replace("{%userInfo}", encodeURI(id));
+ url = url.replace("{host}", domain);
+ url = url.replace("{%host}", encodeURI(domain));
+
+ var webfinger = y.rest(url).accept("application/xrd+xml").contentType("application/xml").get();
+
+ if (webfinger.status == 200) {
+ response.object = webfinger.response;
+ y.exit();
+ }
+ }
}
+
+response.object = <error><message>webfinger not found</message><account>{account}</account></error>;
+y.exit();
]]></execute>
</select>
</bindings>
-</table>
+</table>
View
@@ -0,0 +1,21 @@
+# YQL tables for the ProgrammableWeb API
+
+This is an incomplete set of YQL tables for the [ProgrammableWeb API](http://api.programmableweb.com/). Make sure to read the API documentation in order to explore the full potential of this API.
+
+# Examples
+
+## Find mashups of an API
+
+ SELECT * FROM pw.mashups
+ WHERE apis="google-maps" AND apikey="YOUR_API_KEY"
+
+## Display ProgrammableWeb Members from San Francisco
+
+ SELECT * FROM pw.members
+ WHERE query="San Francisco" AND apikey="YOUR_API_KEY"
+
+## Retrieve Data of Multiple ProgrammableWeb Members
+
+ SELECT * FROM pw.members
+ WHERE (username="jmusser" OR username="duvander" OR username="spier")
+ AND apikey="YOUR_API_KEY"
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <author>Sebastian Spier (http://twitter.com/#!/sebastianspier/)</author>
+ <description></description>
+ <documentationURL>http://api.programmableweb.com/apireference</documentationURL>
+ <sampleQuery>SELECT * FROM {table}</sampleQuery>
+ <sampleQuery>SELECT id,title FROM {table} WHERE q="thumbnail"</sampleQuery>
+ </meta>
+ <bindings>
+
+ <select itemPath="feed.entry" produces="XML">
+ <urls>
+ <url env="all">http://api.programmableweb.com/apis</url>
+ </urls>
+ <paging model="page">
+ <start id="page" default="0" />
+ <pagesize id="pagesize" max="30" />
+ <total default="20" />
+ </paging>
+ <inputs>
+ <!-- fix calls to always respond with XML -->
+ <key id="alt" type="xs:string" paramType="query" default="xml" const="true"/>
+ <!-- fix the version to 1.0 -->
+ <key id="version" type="xs:string" paramType="query" default="1.0" const="true"/>
+ <!-- the apikey to use. username/password could be used for authentication as well but is not recommended as they would be sent in plain text -->
+ <key id="apikey" type="xs:string" paramType="query" required="true"/>
+
+ <key id="q" type="xs:string" paramType="query"/>
+ <key id="sort" type="xs:string" paramType="query"/>
+ </inputs>
+ </select>
+
+ </bindings>
+</table>
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <author>Sebastian Spier (http://twitter.com/#!/sebastianspier/)</author>
+ <description></description>
+ <documentationURL>http://api.programmableweb.com/apireference</documentationURL>
+ <sampleQuery>SELECT * FROM {table}</sampleQuery>
+ <sampleQuery>SELECT * FROM {table} WHERE maxdays=2</sampleQuery>
+ <sampleQuery>SELECT id,title,link FROM {table} WHERE q="guardian"</sampleQuery>
+ <sampleQuery>SELECT * FROM {table} WHERE apis="google-maps"</sampleQuery>
+ </meta>
+ <bindings>
+
+ <select itemPath="feed.entry" produces="XML">
+ <urls>
+ <url env="all">http://api.programmableweb.com/mashups</url>
+ </urls>
+ <paging model="page">
+ <start id="page" default="0" />
+ <pagesize id="pagesize" max="30" />
+ <total default="20" />
+ </paging>
+ <inputs>
+ <!-- fix calls to always respond with XML -->
+ <key id="alt" type="xs:string" paramType="query" default="xml" const="true"/>
+ <!-- fix the version to 1.0 -->
+ <key id="version" type="xs:string" paramType="query" default="1.0" const="true"/>
+ <!-- the apikey to use. username/password could be used for authentication as well but is not recommended as they would be sent in plain text -->
+ <key id="apikey" type="xs:string" paramType="query" required="true"/>
+
+ <key id="q" as="query" type="xs:string" paramType="query"/>
+ <key id="sort" type="xs:string" paramType="query" default="popular"/>
+
+ <key id="maxdays" type="xs:string" paramType="query"/>
+
+ <!-- TODO takes multiple values -->
+ <key id="apis" type="xs:string" paramType="query"/>
+ </inputs>
+ </select>
+
+ </bindings>
+</table>
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <author>Sebastian Spier (http://twitter.com/#!/sebastianspier/)</author>
+ <description></description>
+ <documentationURL>http://api.programmableweb.com/apireference</documentationURL>
+ <sampleQuery>SELECT * FROM {table}</sampleQuery>
+ <sampleQuery>SELECT * FROM {table} WHERE username="spier"</sampleQuery>
+ <sampleQuery>SELECT * FROM {table} WHERE q="San Francisco"</sampleQuery>
+ </meta>
+ <bindings>
+
+ <!-- request for a specific member -->
+ <select itemPath="feed.entry" produces="XML">
+ <urls>
+ <url env="all">http://api.programmableweb.com/members/{username}</url>
+ </urls>
+ <paging model="page">
+ <start id="page" default="0" />
+ <pagesize id="pagesize" max="30" />
+ <total default="20" />
+ </paging>
+ <inputs>
+ <!-- fix calls to always respond with XML -->
+ <key id="alt" type="xs:string" paramType="query" default="xml" const="true"/>
+ <!-- fix the version to 1.0 -->
+ <key id="version" type="xs:string" paramType="query" default="1.0" const="true"/>
+ <!-- the apikey to use. username/password could be used for authentication as well but is not recommended as they would be sent in plain text -->
+ <key id="apikey" type="xs:string" paramType="query" required="true"/>
+
+ <key id="username" type="xs:string" paramType="path" required="true"/>
+ </inputs>
+ </select>
+
+
+ <!-- member search -->
+ <select itemPath="feed.entry" produces="XML">
+ <urls>
+ <url env="all">http://api.programmableweb.com/members</url>
+ </urls>
+ <paging model="page">
+ <start id="page" default="0" />
+ <pagesize id="pagesize" max="30" />
+ <total default="20" />
+ </paging>
+ <inputs>
+ <!-- fix calls to always respond with XML -->
+ <key id="alt" type="xs:string" paramType="query" default="xml" const="true"/>
+ <!-- fix the version to 1.0 -->
+ <key id="version" type="xs:string" paramType="query" default="1.0" const="true"/>
+ <!-- the apikey to use. username/password could be used for authentication as well but is not recommended as they would be sent in plain text -->
+ <key id="apikey" type="xs:string" paramType="query" required="true"/>
+
+ <key id="q" as="query" type="xs:string" paramType="query"/>
+ <key id="sort" type="xs:string" paramType="query"/>
+
+ <!-- TODO takes multiple values -->
+ <key id="apis" type="xs:string" paramType="query"/>
+ <key id="filter" type="xs:string" paramType="query"/>
+ <key id="tags" type="xs:string" paramType="query"/>
+ </inputs>
+ </select>
+
+
+
+ </bindings>
+</table>
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <author>Sebastian Spier (http://twitter.com/#!/sebastianspier/)</author>
+ <description></description>
+ <documentationURL>http://api.programmableweb.com/apireference</documentationURL>
+ <sampleQuery>SELECT * FROM {table}</sampleQuery>
+ <sampleQuery>SELECT * FROM {table} WHERE q="SMS"</sampleQuery>
+ </meta>
+ <bindings>
+
+ <select itemPath="feed.entry" produces="XML">
+ <urls>
+ <url env="all">http://api.programmableweb.com/widgets</url>
+ </urls>
+ <paging model="page">
+ <start id="page" default="0" />
+ <pagesize id="pagesize" max="30" />
+ <total default="20" />
+ </paging>
+ <inputs>
+ <!-- fix calls to always respond with XML -->
+ <key id="alt" type="xs:string" paramType="query" default="xml" const="true"/>
+ <!-- fix the version to 1.0 -->
+ <key id="version" type="xs:string" paramType="query" default="1.0" const="true"/>
+ <!-- the apikey to use. username/password could be used for authentication as well but is not recommended as they would be sent in plain text -->
+ <key id="apikey" type="xs:string" paramType="query" required="true"/>
+
+ <key id="q" type="xs:string" paramType="query"/>
+ <key id="sort" type="xs:string" paramType="query"/>
+
+ <key id="maxdays" type="xs:string" paramType="query"/>
+ </inputs>
+ </select>
+
+ </bindings>
+</table>
View
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <author>Ryan Seddon</author>
+ <documentationURL>http://github.com/ryanseddon/SUX#readme</documentationURL>
+ <sampleQuery>SELECT * FROM {table} WHERE url='{urls:["http://goo.gl/5S9S"]}';</sampleQuery>
+ </meta>
+ <bindings>
+ <select itemPath="" produces="XML">
+ <inputs>
+ <key id='url' type='xs:string' paramType='variable' required="true" />
+ </inputs>
+ <execute><![CDATA[
+ var req = {},
+ remoteRequest,
+ resp = [];
+
+ eval("url="+url);
+
+ if(typeof url.urls === "string") {
+ getExpandedUrl(url.urls);
+ } else if(typeof url.urls === "object") {
+ for(var i = 0, len = url.urls.length; i<len; i++) {
+ getExpandedUrl(url.urls[i]);
+ }
+ } else {
+ req.error = "Something went wrong";
+ }
+
+ response.object = {"expanded": resp};
+
+ function getExpandedUrl(url) {
+ remoteRequest = y.rest(url);
+ remoteRequest.followRedirects(false);
+ req.response = remoteRequest.get();
+ resp.push((req.response.headers.location) ? req.response.headers.location : url);
+ }
+ ]]></execute>
+ </select>
+ </bindings>
+</table>
@@ -77,7 +77,7 @@
var strikePrice;
var optionSymbol;
var optionType;
- var last;
+ var lastPrice;
var change;
var changeDir;
var bid;
@@ -88,7 +88,7 @@
var openIntStr;
var optTypeMatch;
-
+
for each ( var tr in results )
{
strikePrice = parseFloat( tr.td[0].a.strong.text() );
@@ -104,12 +104,12 @@
optionType = optTypeMatch[1];
}
- lastPrice = tr.td[2].strong.span.text();
+ lastPrice = tr.td[2].strong.text();
change = tr.td[3].span.strong.text();
changeDir = tr.td[3].span.img.@alt.toString();
- bid = parseFloat( tr.td[4].span.text() );
- ask = parseFloat( tr.td[5].span.text() );
- volStr = tr.td[6].span.text();
+ bid = parseFloat( tr.td[4].p.text() );
+ ask = parseFloat( tr.td[5].p.text() );
+ volStr = tr.td[6].p.text();
vol = volStr.toInt();
openIntStr = tr.td[7].p.text();
openInt = openIntStr.toInt();

0 comments on commit ba29205

Please sign in to comment.