mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
rewrite iframes to use https if commafeed uses https
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
var module = angular.module('commafeed.filters', []);
|
var module = angular.module('commafeed.filters', []);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* smart date formatter
|
||||||
|
*/
|
||||||
module.filter('entryDate', function() {
|
module.filter('entryDate', function() {
|
||||||
return function(timestamp, defaultValue) {
|
return function(timestamp, defaultValue) {
|
||||||
if (!timestamp) {
|
if (!timestamp) {
|
||||||
@@ -18,22 +21,52 @@ module.filter('entryDate', function() {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rewrites iframes to use https if commafeed uses https
|
||||||
|
*/
|
||||||
|
module.filter('iframeHttpsRewrite', function() {
|
||||||
|
return function(html) {
|
||||||
|
var result = html;
|
||||||
|
if (location.protocol === 'https:') {
|
||||||
|
var wrapper = $('<div></div>').html(html);
|
||||||
|
$('iframe', wrapper).each(function(i, elem) {
|
||||||
|
var e = $(elem);
|
||||||
|
e.attr('src', e.attr('src').replace(/^http:\/\//i, 'https://'));
|
||||||
|
});
|
||||||
|
result = wrapper.html();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* escapes the url
|
||||||
|
*/
|
||||||
module.filter('escape', function() {
|
module.filter('escape', function() {
|
||||||
return encodeURIComponent;
|
return encodeURIComponent;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a trusted html content
|
||||||
|
*/
|
||||||
module.filter('trustHtml', ['$sce', function($sce) {
|
module.filter('trustHtml', ['$sce', function($sce) {
|
||||||
return function(val) {
|
return function(val) {
|
||||||
return $sce.trustAsHtml(val);
|
return $sce.trustAsHtml(val);
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a trusted url
|
||||||
|
*/
|
||||||
module.filter('trustUrl', ['$sce', function($sce) {
|
module.filter('trustUrl', ['$sce', function($sce) {
|
||||||
return function(val) {
|
return function(val) {
|
||||||
return $sce.trustAsResourceUrl(val);
|
return $sce.trustAsResourceUrl(val);
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add the 'highlight-search' class to text matching keywords
|
||||||
|
*/
|
||||||
module.filter('highlight', function() {
|
module.filter('highlight', function() {
|
||||||
return function(html, keywords) {
|
return function(html, keywords) {
|
||||||
if (keywords) {
|
if (keywords) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="entry-body-content">
|
<div class="entry-body-content">
|
||||||
<div ng-bind-html="entry.content | trustHtml | highlight:keywords"></div>
|
<div ng-bind-html="entry.content | iframeHttpsRewrite| highlight:keywords | trustHtml"></div>
|
||||||
<div class="entry-enclosure" ng-if="entry.enclosureType">
|
<div class="entry-enclosure" ng-if="entry.enclosureType">
|
||||||
<video controls ng-if="entry.enclosureType && entry.enclosureType.indexOf('video') == 0">
|
<video controls ng-if="entry.enclosureType && entry.enclosureType.indexOf('video') == 0">
|
||||||
<source ng-src="{{entry.enclosureUrl | trustUrl}}" type="{{entry.enclosureType}}" />
|
<source ng-src="{{entry.enclosureUrl | trustUrl}}" type="{{entry.enclosureType}}" />
|
||||||
|
|||||||
Reference in New Issue
Block a user