build icon url server side

This commit is contained in:
Athou
2013-05-26 15:36:55 +02:00
parent c6a8c288ce
commit 5124a092d3
9 changed files with 84 additions and 34 deletions

View File

@@ -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>'
};
});

View File

@@ -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>

View File

@@ -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>