Skip to content

Commit

Permalink
ssl for YQL
Browse files Browse the repository at this point in the history
  • Loading branch information
zapbulon committed Mar 14, 2017
1 parent 1a787bf commit 614a6f8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/angular-feeds/angular-feeds.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* angular-feeds - v0.0.4 - 2017-01-17 12:29 PM
* angular-feeds - v0.0.4 - 2017-03-14 7:48 AM
* https://github.com/siddii/angular-feeds
*
* Copyright (c) 2017
Expand Down Expand Up @@ -73,4 +73,4 @@
@-webkit-keyframes spinner-fade {
from {opacity: 1;}
to {opacity: 0;}
}
}
24 changes: 11 additions & 13 deletions app/angular-feeds/angular-feeds.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* angular-feeds - v0.0.4 - 2017-01-23 12:29 PM
* angular-feeds - v0.0.4 - 2017-03-14 7:48 AM
* https://github.com/siddii/angular-feeds
*
* Copyright (c) 2017
Expand Down Expand Up @@ -54,7 +54,9 @@ function feedDirective (feedService, $compile, $templateCache, $http) {

function fetchFeed (url) {
feedService.getFeeds(url, $attrs.count).then(function (feedsObj) {
if ($attrs.templateUrl) {
if ($attrs.template && $templateCache.get($attrs.template)) {
renderTemplate($templateCache.get($attrs.template), feedsObj);
} else if ($attrs.templateUrl) {
$http.get($attrs.templateUrl, {cache: $templateCache}).success(function (templateHtml) {
renderTemplate(templateHtml, feedsObj);
});
Expand Down Expand Up @@ -109,7 +111,7 @@ angular
.module('feeds-services')
.factory('feedCache', feedCache);

function feedService ($q, $sce, feedCache) {
function feedService ($window, $q, $sce, feedCache) {

return {
getFeeds: getFeeds,
Expand All @@ -123,7 +125,6 @@ function feedService ($q, $sce, feedCache) {
}

function getFeeds (feedURL, count) {

var deferredFeedsFetch = $q.defer();

if (count === 0) {
Expand All @@ -140,22 +141,22 @@ function feedService ($q, $sce, feedCache) {

function fetchFeed (feedURL) {
try {
YUI().use('yql', performYQLQuery(feedURL))
YUI().use('yql', performYQLQuery(feedURL));
} catch (ex) {
deferredFeedsFetch.reject(ex);
}

}

function performYQLQuery (feedURL) {
return function (Y) {
var query = 'select * from feed(0,' + count + ') where url = "' + feedURL + '"';
Y.YQL(query, parseYQLResponse);
}
var query = 'select * from feed(0,' + count + ') where url = "' + feedURL + '"',
href = $window.location && $window.location.href ? $window.location.href : null,
proto = href && (href.toLowerCase().indexOf('https') === 0) ? 'https' : 'http';

Y.YQL(query, parseYQLResponse, {}, {proto: proto});
};
}


function parseYQLResponse (rawResponse) {

var response = [];
Expand All @@ -168,14 +169,11 @@ function feedService ($q, $sce, feedCache) {
}

resolve(response);

}

function resolve (withData) {
deferredFeedsFetch.resolve(withData);
}


}

function sanitizeFeedEntry (feedEntry) {
Expand Down
4 changes: 2 additions & 2 deletions app/angular-feeds/angular-feeds.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/angular-feeds/angular-feeds.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions src/scripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ angular
.module('feeds-services')
.factory('feedCache', feedCache);

function feedService ($q, $sce, feedCache) {
function feedService ($window, $q, $sce, feedCache) {

return {
getFeeds: getFeeds,
Expand All @@ -23,7 +23,6 @@ function feedService ($q, $sce, feedCache) {
}

function getFeeds (feedURL, count) {

var deferredFeedsFetch = $q.defer();

if (count === 0) {
Expand All @@ -40,22 +39,22 @@ function feedService ($q, $sce, feedCache) {

function fetchFeed (feedURL) {
try {
YUI().use('yql', performYQLQuery(feedURL))
YUI().use('yql', performYQLQuery(feedURL));
} catch (ex) {
deferredFeedsFetch.reject(ex);
}

}

function performYQLQuery (feedURL) {
return function (Y) {
var query = 'select * from feed(0,' + count + ') where url = "' + feedURL + '"';
Y.YQL(query, parseYQLResponse);
}
var query = 'select * from feed(0,' + count + ') where url = "' + feedURL + '"',
href = $window.location && $window.location.href ? $window.location.href : null,
proto = href && (href.toLowerCase().indexOf('https') === 0) ? 'https' : 'http';

Y.YQL(query, parseYQLResponse, {}, {proto: proto});
};
}


function parseYQLResponse (rawResponse) {

var response = [];
Expand All @@ -68,14 +67,11 @@ function feedService ($q, $sce, feedCache) {
}

resolve(response);

}

function resolve (withData) {
deferredFeedsFetch.resolve(withData);
}


}

function sanitizeFeedEntry (feedEntry) {
Expand Down

0 comments on commit 614a6f8

Please sign in to comment.