mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
build icon url server side
This commit is contained in:
@@ -40,29 +40,7 @@ module.directive('favicon', function() {
|
||||
url : '='
|
||||
},
|
||||
replace : true,
|
||||
template : '<img ng-src="{{iconUrl()}}" class="favicon" onError="this.src=\'images/default_favicon.gif\'"></img>',
|
||||
controller : ['$scope', function($scope) {
|
||||
|
||||
$scope.iconUrl = function() {
|
||||
var url = $scope.url;
|
||||
|
||||
var current = window.location.href;
|
||||
var baseUrl = current.substring(0, current.lastIndexOf('#'));
|
||||
var defaultIcon = baseUrl + 'images/default_favicon.gif';
|
||||
if (!url) {
|
||||
return defaultIcon;
|
||||
}
|
||||
|
||||
var index = Math.max(url.length, url.lastIndexOf('?'));
|
||||
|
||||
var iconUrl = '//getfavicon.appspot.com/';
|
||||
iconUrl += encodeURIComponent(url.substring(0, index));
|
||||
iconUrl += '?defaulticon=none';
|
||||
return iconUrl;
|
||||
};
|
||||
|
||||
|
||||
}]
|
||||
template : '<img ng-src="{{url}}" class="favicon" onError="this.src=\'images/default_favicon.gif\'"></img>'
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</div>
|
||||
<a ng-click="feedClicked(feed.id)" class="feed-link"
|
||||
ng-class="{error: feed.message && feed.errorCount > 10, selected: (feed.id == selectedId && selectedType == 'feed'), unread: feed.unread }">
|
||||
<favicon url="feed.feedLink" />
|
||||
<favicon url="feed.iconUrl" />
|
||||
{{feed.name}} {{feedCountLabel(feed)}}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<i ng-class="{'icon-star icon-star-yellow': entry.starred, 'icon-star-empty': !entry.starred}"
|
||||
class="pointer"></i>
|
||||
</span>
|
||||
<favicon url="entry.feedLink" />
|
||||
<favicon url="entry.iconUrl" />
|
||||
{{entry.feedName}}
|
||||
</span>
|
||||
<span class="entry-date visible-desktop">{{entry.date | entryDate}}</span>
|
||||
|
||||
Reference in New Issue
Block a user