| 1 |
define(["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/declare", "dojox/data/GoogleSearchStore"], |
| 2 |
function(dojo, lang, declare, GoogleSearchStore) { |
| 3 |
|
| 4 |
dojo.experimental("dojox.data.GoogleFeedStore"); |
| 5 |
|
| 6 |
var Search = GoogleSearchStore.Search; |
| 7 |
|
| 8 |
return declare("dojox.data.GoogleFeedStore", Search,{ |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
_type: "", |
| 25 |
_googleUrl: "http://ajax.googleapis.com/ajax/services/feed/load", |
| 26 |
_attributes: ["title", "link", "author", "published", |
| 27 |
"content", "summary", "categories"], |
| 28 |
_queryAttrs: { |
| 29 |
"url":"q" |
| 30 |
}, |
| 31 |
|
| 32 |
getFeedValue: function(attribute, defaultValue){ |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
var values = this.getFeedValues(attribute, defaultValue); |
| 37 |
if(lang.isArray(values)){ |
| 38 |
return values[0]; |
| 39 |
} |
| 40 |
return values; |
| 41 |
}, |
| 42 |
|
| 43 |
getFeedValues: function(attribute, defaultValue){ |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
if(!this._feedMetaData){ |
| 48 |
return defaultValue; |
| 49 |
} |
| 50 |
return this._feedMetaData[attribute] || defaultValue; |
| 51 |
}, |
| 52 |
|
| 53 |
_processItem: function(item, request) { |
| 54 |
this.inherited(arguments); |
| 55 |
item["summary"] = item["contentSnippet"]; |
| 56 |
item["published"] = item["publishedDate"]; |
| 57 |
}, |
| 58 |
|
| 59 |
_getItems: function(data){ |
| 60 |
if(data['feed']){ |
| 61 |
this._feedMetaData = { |
| 62 |
title: data.feed.title, |
| 63 |
desc: data.feed.description, |
| 64 |
url: data.feed.link, |
| 65 |
author: data.feed.author |
| 66 |
}; |
| 67 |
return data.feed.entries; |
| 68 |
} |
| 69 |
return null; |
| 70 |
}, |
| 71 |
|
| 72 |
_createContent: function(query, callback, request){ |
| 73 |
var cb = this.inherited(arguments); |
| 74 |
cb.num = (request.count || 10) + (request.start || 0); |
| 75 |
return cb; |
| 76 |
} |
| 77 |
}); |
| 78 |
|
| 79 |
}); |