Skip to content

Commit

Permalink
Merge pull request yql#429 from clarle/applinks
Browse files Browse the repository at this point in the history
Add YQL table for App Links index
  • Loading branch information
pjdonnelly committed Jun 17, 2014
2 parents 0b231ae + fc266ab commit 053e0d6
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions applinks/applinks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Clarence Leung</author>
<description>YQL index for App Links metadata</description>
<documentationURL>http://applinks.org/documentation/</documentationURL>
<sampleQuery>SELECT url, android.url from applinks WHERE url IN ("movietickets.com", "pinterest.com")</sampleQuery>
</meta>
<bindings>
<select itemPath="" produces="XML">
<urls>
<url></url>
</urls>
<inputs>
<key id="url" type="xs:string" paramType="variable" required="true" />
</inputs>
<execute>
<![CDATA[
var url = inputs['url'],
platforms = ['ios', 'iphone', 'ipad', 'android', 'windows_phone', 'web'],
query = y.query("select * from html where url = \"" + url
+ "\" and compat = 'html5' and xpath='//meta[contains(@property, \"al:\")]'")
.format('json');
var data = query.results.meta,
applinks = { url: url },
output = {},
i, j;
for (i = 0; i < platforms.length; i++) {
var platform = platforms[i];
applinks[platform] = {};
}
for (j = 0; j < data.length; j++) {
var item = data[j],
metadata = item.property.split(':'),
itemPlatform = metadata[1],
property = metadata[2];
applinks[itemPlatform][property] = item.content;
}
output.applinks = applinks;
response.object = output;
]]>
</execute>
</select>
</bindings>
</table>

0 comments on commit 053e0d6

Please sign in to comment.