diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1fde536
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/build
+/deploy
\ No newline at end of file
diff --git a/fxos/manifest.webapp b/fxos/manifest.webapp
index 6557d23..2cf3a34 100755
--- a/fxos/manifest.webapp
+++ b/fxos/manifest.webapp
@@ -2,7 +2,7 @@
"name": "FoxCasts",
"description": "A fully-featured podcast app for your FirefoxOS device.",
- "version": "1.2.0",
+ "version": "1.3.0",
"launch_path": "/index.html",
"icons": {
"256": "/assets/icon-256.png",
diff --git a/icon.png b/icon.png
index b210019..bf2317b 100755
Binary files a/icon.png and b/icon.png differ
diff --git a/lib/xmlprequest/XmlpRequest.js b/lib/xmlprequest/XmlpRequest.js
new file mode 100644
index 0000000..b5979fd
--- /dev/null
+++ b/lib/xmlprequest/XmlpRequest.js
@@ -0,0 +1,79 @@
+/**
+ Allows for cross-domain JSONp style requests for XML documents, via YQL,
+ converted and returned in JSON format.
+ */
+
+enyo.kind({
+ name: "enyo.XmlpRequest",
+ kind: enyo.JsonpRequest,
+ published: {
+ /**
+ If true, on a query failure, it will re-query the XML url/params
+ to get the plain-text content and return it in the format of
+
+ {"error":"unescaped-plain-text-content"}
+ */
+ detailedErrors:true
+ },
+ //* @protected
+ callbackName: "callback",
+ //* @public
+ //* Executes the XML document request via YQL, with an optional parameters object
+ go: function(inParams) {
+ var parts = this.url.split("?");
+ var uri = parts.shift() || "";
+ var args = parts.join("?").split("&");
+ args.push(enyo.Ajax.objectToQuery(inParams || {}));
+ this.xmlUrl = [uri, args.join("&")].join("?");
+ this.url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'"
+ + encodeURIComponent(this.xmlUrl) + "'&format=json";
+ inParams = {};
+ this.inherited(arguments);
+ },
+ //* @protected
+ respond: function(inValue) {
+ if(inValue && inValue.query) {
+ inValue = inValue.query.results || undefined;
+ if(!inValue && this.detailedErrors) {
+ var fallbackUrl = "http://query.yahooapis.com/v1/public/yql?q=use%20%22http"
+ + "%3A%2F%2Fwww.datatables.org%2Fdata%2Fhtmlstring.xml%22%20"
+ + "as%20htmlstring%3B%20select%20*%20from%20htmlstring%20where"
+ + "%20url%3D'"+ encodeURIComponent(this.xmlUrl) + "'&format=json";
+ this.fallbackTextRequest = new enyo.JsonpRequest({url:fallbackUrl,
+ callbackName:"callback"});
+ this.fallbackTextRequest.response(this, "fallbackTextCallback");
+ this.fallbackTextRequest.go();
+ return;
+ }
+ }
+ this.inherited(arguments);
+ },
+ fallbackTextCallback: function(inSender, inResponse) {
+ if(inResponse && inResponse.query) {
+ inResponse = inResponse.query.results || undefined;
+ if(inResponse && inResponse.result) {
+ inResponse = inResponse.result;
+ //plain text is within auto-generated html, so extract it
+ var prefix = "\n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n "
+ var suffix = "
\n \n \n \n \n\n";
+ inResponse = inResponse.replace(prefix, "");
+
+ inResponse = inResponse.replace(suffix, "");
+ var iOpen = inResponse.indexOf("<");
+ var iClose = inResponse.lastIndexOf(">");
+
+ //if still contains html, we know it wasn't plain text to begin with
+ if(iOpen>-1 && iOpen 0) {
- this.podcast.summary = summary[0].textContent;
+ if(type == 'xml') {
+ var summary = response.getElementsByTagName("summary");
+ if (summary.length > 0) {
+ this.podcast.summary = summary[0].textContent;
+ } else {
+ this.podcast.summary = "No summary available.";
+ }
} else {
- this.podcast.summary = "No summary available.";
+ this.podcast.summary = response.rss.channel.summary || 'No summary available';
}
- this.episodes = ParseFeed(xml, this.podcast);
+ this.processEpisodes(response, type);
+ },
+ processEpisodes: function(response, type) {
+ this.episodes = ParseFeed(response, this.podcast, 0, type);
this.log("Found " + this.episodes.length + " episodes.");
// this.log(this.episodes[0]);
diff --git a/source/views/Search.js b/source/views/Search.js
index a8340a7..9c76654 100755
--- a/source/views/Search.js
+++ b/source/views/Search.js
@@ -38,13 +38,7 @@ enyo.kind({
var url = "https://itunes.apple.com/search?media=podcast&term=" + query;
- if (enyo.platform.webos) {
- var request = new enyo.JsonpRequest({
- url: url
- });
- request.response(this, "gotResults");
- request.go();
- } else {
+ if (enyo.platform.firefoxOS) {
var xmlhttp = new XMLHttpRequest({mozSystem: true});
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader("Content-type", "application/json");
@@ -52,20 +46,26 @@ enyo.kind({
xmlhttp.onreadystatechange = enyo.bind(this, function(response) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log(xmlhttp);
- this.gotResults(xmlhttp.response);
+ this.gotResults(xmlhttp.response.results);
}
});
xmlhttp.send();
- }
+ } else {
+ var request = new enyo.JsonpRequest({
+ url: url
+ });
+ request.response(enyo.bind(this, function(req, res) {
+ this.gotResults(res.results);
+ }));
+ request.go();
+ }
},
- gotResults: function(response) {
+ gotResults: function(results) {
this.$.spinner.setShowing(false);
-
- this.log(response);
- // response = JSON.parse(response);
- // this.log(response);
- this.results = response.results;
- var r = response.results;
+
+ this.log('gotResults', results);
+ this.results = results;
+ var r = results;
this.$.results.destroyClientControls();
diff --git a/source/views/Services.js b/source/views/Services.js
index 4294e3e..7b27a14 100644
--- a/source/views/Services.js
+++ b/source/views/Services.js
@@ -427,27 +427,40 @@ PodcastManager.updateNextPodcast = function() {
};
PodcastManager.requestPodcastRefresh = function(_this, podcast) {
- // console.log("PodcastManager.requestPodcastRefresh(): Event = " + podcast.name);
-
- var xmlhttp = new XMLHttpRequest({mozSystem: true});
- xmlhttp.open("GET", podcast.feedUrl, true);
- xmlhttp.responseType = "xml";
- xmlhttp.onreadystatechange = enyo.bind(this, function(response) {
- // this.log(response);
- if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
- var parser = new DOMParser();
- var xml = parser.parseFromString(xmlhttp.response, "text/xml");
- PodcastManager.processPodcastRefresh(_this, podcast, xml);
- }
- });
- xmlhttp.send();
+ console.log("PodcastManager.requestPodcastRefresh(): Event = " + podcast.name);
+
+ if (enyo.platform.firefoxOS) {
+ var xmlhttp = new XMLHttpRequest({mozSystem: true});
+ xmlhttp.open("GET", podcast.feedUrl, true);
+ xmlhttp.responseType = "xml";
+ xmlhttp.onreadystatechange = enyo.bind(this, function (response) {
+ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
+ // console.log(xmlhttp);
+ var parser = new DOMParser();
+ var xml = parser.parseFromString(xmlhttp.response, "text/xml");
+ // this.gotEpisodes(xml, 'xml');
+ PodcastManager.processPodcastRefresh(_this, podcast, xml);
+ }
+ });
+ xmlhttp.send();
+ } else {
+ console.log('Not FxOS');
+ var request = new enyo.XmlpRequest({
+ url: podcast.feedUrl
+ });
+ request.response(enyo.bind(this, function(inRequest, inResponse) {
+ console.log(inResponse);
+ // this.gotEpisodes(inResponse, 'json');
+ PodcastManager.processPodcastRefresh(_this, podcast, inResponse);
+ }));
+ request.go();
+ }
};
-PodcastManager.processPodcastRefresh = function(_this, podcast, xml) {
- // console.log("PodcastManager.processPodcastRefresh(): Event = " + podcast.name);
-
- var items = xml.getElementsByTagName("item");
- var episodes = ParseFeed(xml, podcast, podcast.latest);
+PodcastManager.processPodcastRefresh = function(_this, podcast, data) {
+ console.log("PodcastManager.processPodcastRefresh(): Event = " + podcast.name);
+
+ var episodes = ParseFeed(data, podcast, podcast.latest);
// No new episodes
if (episodes.length === 0) {
diff --git a/source/views/deploy.json b/source/views/deploy.json
new file mode 100644
index 0000000..c4ff58b
--- /dev/null
+++ b/source/views/deploy.json
@@ -0,0 +1,6 @@
+{
+ "enyo": "./enyo",
+ "packagejs": "./package.js",
+ "assets": ["./icon.png", "./index.html", "./assets", "./appinfo.json", "./framework_config.json"],
+ "libs": ["./lib/layout", "./lib/onyx", "./lib/xmlprequest"]
+}
\ No newline at end of file
diff --git a/tools/deploy.sh b/tools/deploy.sh
index 3f31170..1313489 100755
--- a/tools/deploy.sh
+++ b/tools/deploy.sh
@@ -66,5 +66,31 @@ while [ "$1" != "" ]; do
cp -a "$SRC/webOS/." "$DEST"
esac
+ case $1 in --luneos )
+ echo "Packaging for LuneOS"
+
+ # Copy LuneOS files
+ DEST="$SRC/deploy/"
+ cp -a "$SRC/luneos/." "$DEST"
+
+ # Package it as an ipk
+ palm-package -o ./deploy ./deploy
+ esac
+ case $1 in --luneos-deploy )
+ echo "Packaging for LuneOS"
+
+ # Copy LuneOS files
+ DEST="$SRC/deploy/"
+ cp -a "$SRC/luneos/." "$DEST"
+
+ # Package it as an ipk
+ palm-package -o ./deploy ./deploy
+
+ # Locate the new ipk and store in a variable
+ ipkLocation="$(find ./deploy -maxdepth 1 -name '*.ipk' -print -quit)"
+
+ # Copy the ipk over to the LuneOS emulator
+ scp -P 5522 $ipkLocation root@localhost:/media/internal
+ esac
shift
done
\ No newline at end of file