Permalink
Browse files

Javascript execute type error

  • Loading branch information...
1 parent 9efa414 commit 261b6ede730cb918d1a1896fd34a536f9fb94c34 Daniel Park committed Oct 5, 2012
Showing with 0 additions and 61 deletions.
  1. +0 −61 hackernews/hackernews.submitted.xml
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
- <meta>
- <sampleQuery>select * from {table} where username = 'hn_username';</sampleQuery>
- <author>Matteo Scotuzzi (@scotu, matteo.scotuzzi@gmail.com), based on hackernews.frontpage.xml Tom Hughes-Croucher (@sh1mmer, croucher@yahoo-inc.com)</author>
- </meta>
- <bindings>
- <select itemPath="stories.story" produces="XML">
- <urls>
- <url>http://news.ycombinator.com/submitted</url>
- </urls>
- <inputs>
- <key id='username' type='xs:string' paramType='variable' required="true" />
- </inputs>
- <execute><![CDATA[
- url = "http://news.ycombinator.com/submitted?id="+username;
- page = y.query("select * from html where url='" + url + "'").results;
- table = page..table[2];
- rows = table..tr;
-
- output = <stories></stories>
- if(rows){
- /*
- * iterate three TRs at a time
- * each triplet represents one story
- * i is the title row, i+1 is the meta info, i+2 is a spacer
- */
- for(var i=0;i<90;i=i+3) {
- titleRow = rows[i]
- metaRow = rows[i+1]
- if(titleRow == undefined || metaRow == undefined){break;}
- title = titleRow..td[2].a;
- url = titleRow..td[2].a.@href;
- submitter = metaRow..a[0]
-
- score = /^\d+/.exec(metaRow..span[0].toString())[0]
-
- comments = /^\d+/.exec(metaRow..a[1].toString())
- if(comments) {
- comments = comments[0]
- } else {
- comments = 0;
- }
-
- id = /\d+$/.exec(metaRow..a[1].@href.toString())[0]
-
- story = <story></story>
- story.id = id;
- story.title = title.toString();
- story.url = url;
- story.submitter = submitter.toString();
- story.score = score;
- story.comments = comments;
- output.stories += story;
- }
- }
- response.object = output;
- ]]></execute>
- </select>
- </bindings>
-</table>

0 comments on commit 261b6ed

Please sign in to comment.