summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-09-14 04:17:32 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-09-14 04:17:32 +0200
commit242fdbf9fcc39795fe5567eadcb55c6709b303c5 (patch)
tree6c85a9836080997bf223341e11eecdac3c51ac1e
parent721ae0b8bbde9716ed9073439805fd6497abf508 (diff)
add import articles
-rw-r--r--controller/feedcontroller.php4
-rw-r--r--css/navigation.css2
-rw-r--r--db/feedmapper.php6
-rw-r--r--js/build/app.js142
-rw-r--r--js/build/app.min.js2
-rw-r--r--js/controller/SettingsController.js53
-rw-r--r--js/directive/NewsReadFile.js1
-rw-r--r--js/service/ItemResource.js11
-rw-r--r--js/service/OPMLImporter.js86
-rw-r--r--js/tests/unit/controller/SettingsControllerSpec.js101
-rw-r--r--js/tests/unit/service/ItemResourceSpec.js15
-rw-r--r--js/tests/unit/service/OPMLImporterSpec.js31
-rw-r--r--templates/part.navigation.feed.php1
-rw-r--r--templates/part.settings.php36
-rw-r--r--tests/unit/controller/FeedControllerTest.php13
15 files changed, 445 insertions, 59 deletions
diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php
index 0bd49837a..c09349b15 100644
--- a/controller/feedcontroller.php
+++ b/controller/feedcontroller.php
@@ -244,7 +244,9 @@ class FeedController extends Controller {
public function import($json) {
$feed = $this->feedService->importArticles($json, $this->userId);
- $params = [];
+ $params = [
+ 'starred' => $this->itemService->starredCount($this->userId)
+ ];
if($feed) {
$params['feeds'] = [$feed];
diff --git a/css/navigation.css b/css/navigation.css
index 4dd96503b..6202a5c7e 100644
--- a/css/navigation.css
+++ b/css/navigation.css
@@ -84,7 +84,7 @@
}
#app-navigation .icon-rss {
- background-image: url('../img/rss.svg');
+ background-image: url('../img/rss.svg') !important;
}
#app-navigation .unread > a {
diff --git a/db/feedmapper.php b/db/feedmapper.php
index dde806208..9753ed718 100644
--- a/db/feedmapper.php
+++ b/db/feedmapper.php
@@ -122,11 +122,7 @@ class FeedMapper extends Mapper implements IMapper {
'`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
$params = [$hash, $userId];
- $row = $this->findOneQuery($sql, $params);
- $feed = new Feed();
- $feed->fromRow($row);
-
- return $feed;
+ return $this->findEntity($sql, $params);
}
diff --git a/js/build/app.js b/js/build/app.js
index 7ebbd7638..4fd50165c 100644
--- a/js/build/app.js
+++ b/js/build/app.js
@@ -617,10 +617,12 @@ app.controller('NavigationController',
}]);
app.controller('SettingsController',
-["$route", "SettingsResource", "FeedResource", function ($route, SettingsResource, FeedResource) {
+["$route", "$q", "SettingsResource", "ItemResource", "OPMLParser", "OPMLImporter", "Publisher", function ($route, $q, SettingsResource, ItemResource, OPMLParser,
+ OPMLImporter, Publisher) {
'use strict';
- this.importing = false;
+ this.isOPMLImporting = false;
+ this.isArticlesImporting = false;
this.opmlImportError = false;
this.articleImportError = false;
@@ -632,30 +634,57 @@ app.controller('SettingsController',
}
};
-
this.toggleSetting = function (key) {
set(key, !this.getSetting(key));
};
-
this.getSetting = function (key) {
return SettingsResource.get(key);
};
+ this.importOPML = function (content) {
+ this.opmlImportError = false;
+ this.articleImportError = false;
- this.feedSize = function () {
- return FeedResource.size();
- };
+ try {
+ this.isOPMLImporting = false;
+ var parsedContent = OPMLParser.parse(content);
+ var self = this;
+ var jobSize = 5;
- // TBD
- this.importOpml = function (content) {
- console.log(content);
- };
+ OPMLImporter.importFolders(parsedContent)
+ .then(function (feedQueue) {
+ return OPMLImporter.importFeedQueue(feedQueue, jobSize);
+ }).finally(function () {
+ self.isOPMLImporting = false;
+ });
+ } catch (error) {
+ this.isOPMLImporting = false;
+ this.opmlImportError = true;
+ }
+ };
this.importArticles = function (content) {
- console.log(content);
+ this.opmlImportError = false;
+ this.articleImportError = false;
+
+ try {
+ this.isArticlesImporting = true;
+ var articles = JSON.parse(content);
+
+ var self = this;
+ ItemResource.importArticles(articles).success(function (data) {
+ Publisher.publishAll(data);
+ }).finally(function () {
+ self.isArticlesImporting = false;
+ });
+
+ } catch (error) {
+ this.articleImportError = true;
+ this.isArticlesImporting = false;
+ }
};
}]);
@@ -1255,6 +1284,17 @@ app.factory('ItemResource', ["Resource", "$http", "BASE_URL", "ITEM_BATCH_SIZE",
};
+ ItemResource.prototype.importArticles = function (json) {
+ return this.http({
+ url: this.BASE_URL + '/feeds/import/articles',
+ method: 'POST',
+ data: {
+ json: json
+ }
+ });
+ };
+
+
return new ItemResource($http, BASE_URL, ITEM_BATCH_SIZE);
}]);
app.service('Loading', function () {
@@ -1275,6 +1315,83 @@ app.service('Loading', function () {
};
});
+app.service('OPMLImporter', ["FeedResource", "FolderResource", "$q", function (FeedResource, FolderResource, $q) {
+ 'use strict';
+ var startFeedJob = function (queue) {
+ var deferred = $q.defer();
+
+ if (queue.lenght > 0) {
+ var feed = queue.pop();
+ var url = feed.url;
+ var title = feed.title;
+ var folderId = 0;
+ var folderName = feed.folderName;
+
+ if (folderName !== undefined &&
+ FeedResource.get(folderName) !== undefined) {
+ folderId = FeedResource.get(feed.folderName).id;
+ }
+
+ // make sure to not add already existing feeds
+ if (url !== undefined && FeedResource.get(url) === undefined) {
+ FeedResource.create(url, folderId, title)
+ .finally(function () {
+ startFeedJob(queue);
+ });
+ }
+ } else {
+ deferred.resolve();
+ }
+
+ return deferred.promise;
+ };
+
+ this.importFolders = function (content) {
+ // assumption: folders are fast to create and we dont need a queue for
+ // them
+ var feedQueue = [];
+ var folderPromises = [];
+ content.folders.forEach(function (folder) {
+ if (folder.name !== undefined) {
+ // skip already created folders
+ if (FolderResource.get(folder.name) !== undefined) {
+ folderPromises.push(FolderResource.create(folder.name));
+ }
+
+ folder.feeds.forEach(function (feed) {
+ feed.folderName = folder.name;
+ feedQueue.push(feed);
+ });
+ }
+ });
+ feedQueue = feedQueue.concat(content.feeds);
+
+ var deferred = $q.defer();
+
+ $q.all(folderPromises).finally(function () {
+ deferred.resolve(feedQueue);
+ });
+
+ return deferred.promise;
+ };
+
+ this.importFeedQueue = function (feedQueue, jobSize) {
+ // queue feeds to prevent server slowdown
+ var deferred = $q.defer();
+
+ var jobPromises = [];
+ for (var i=0; i<jobSize; i+=1) {
+ jobPromises.push(startFeedJob(feedQueue));
+ }
+
+ $q.all(jobPromises).then(function () {
+ deferred.resolve();
+ });
+
+ return deferred.promise;
+ };
+
+}]);
app.service('OPMLParser', function () {
'use strict';
@@ -1858,7 +1975,6 @@ app.directive('newsReadFile', function () {
var reader = new FileReader();
reader.onload = function (event) {
- elem[0].value = 0;
// FIXME: is there a more flexible solution where we dont have
// to bind the file to scope?
scope.$fileContent = event.target.result;
diff --git a/js/build/app.min.js b/js/build/app.min.js
index bf010592d..d929db139 100644
--- a/js/build/app.min.js
+++ b/js/build/app.min.js
@@ -1 +1 @@
-!function(a,b,c,d,e,f,g){"use strict";var h=c.module("News",["ngRoute","ngSanitize"]);h.config(["$routeProvider","$provide","$httpProvider",function(a,b,c){var d={FEED:0,FOLDER:1,STARRED:2,SUBSCRIPTIONS:3,SHARED:4};b.constant("REFRESH_RATE",60),b.constant("ITEM_BATCH_SIZE",50),b.constant("BASE_URL",e.generateUrl("/apps/news")),b.constant("FEED_TYPE",d),b.factory("CSRFInterceptor",["$q","BASE_URL",function(a,b){return{request:function(c){return 0===c.url.indexOf(b)&&(c.headers.requesttoken=f),c||a.when(c)}}}]),c.interceptors.push("CSRFInterceptor");var h=function(a){return{data:["$http","$route","$q","BASE_URL","ITEM_BATCH_SIZE",function(b,c,d,e,f){var h={type:a,limit:f};c.current.params.id!==g&&(h.id=c.current.params.id);var i=d.defer();return b({url:e+"/items",method:"GET",params:h}).success(function(a){i.resolve(a)}),i.promise}]}};a.when("/items",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.SUBSCRIPTIONS),type:d.SUBSCRIPTIONS}).when("/items/starred",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.STARRED),type:d.STARRED}).when("/items/feeds/:id",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.FEED),type:d.FEED}).when("/items/folders/:id",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.FOLDER),type:d.FOLDER})}]),h.run(["$rootScope","$location","$http","$q","$interval","Loading","ItemResource","FeedResource","FolderResource","SettingsResource","Publisher","BASE_URL","FEED_TYPE","REFRESH_RATE",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){f.setLoading("global",!0),k.subscribe(g).toChannels(["items","newestItemId","starred"]),k.subscribe(i).toChannels(["folders"]),k.subscribe(h).toChannels(["feeds"]),k.subscribe(j).toChannels(["settings"]);var o=d.defer();c.get(l+"/settings").success(function(a){k.publishAll(a),o.resolve()});var p=d.defer(),q=b.path();c.get(l+"/feeds/active").success(function(a){var c;switch(a.activeFeed.type){case m.FEED:c="/items/feeds/"+a.activeFeed.id;break;case m.FOLDER:c="/items/folders/"+a.activeFeed.id;break;case m.STARRED:c="/items/starred";break;default:c="/items"}/^\/items(\/(starred|feeds\/\d+|folders\/\d+))?\/?$/.test(q)||b.path(c),p.resolve()});var r=d.defer();c.get(l+"/folders").success(function(a){k.publishAll(a),r.resolve()});var s=d.defer();c.get(l+"/feeds").success(function(a){k.publishAll(a),s.resolve()}),d.all([o.promise,p.promise,s.promise,r.promise]).then(function(){f.setLoading("global",!1)}),e(function(){c.get(l+"/feeds"),c.get(l+"/folders")},1e3*n),a.$on("$routeChangeStart",function(){f.setLoading("content",!0)}),a.$on("$routeChangeSuccess",function(){f.setLoading("content",!1)}),a.$on("$routeChangeError",function(){b.path("/items")})}]),h.controller("AppController",["Loading","FeedResource","FolderResource",function(a,b,c){this.loading=a,this.isFirstRun=function(){return 0===b.size()&&0===c.size()}}]),h.controller("ContentController",["Publisher","FeedResource","ItemResource","SettingsResource","data","$route","$routeParams","FEED_TYPE",function(a,b,c,d,e,f,h,i){c.clear(),a.publishAll(e),this.isAutoPagingEnabled=!0,this.getItems=function(){return c.getAll()},this.toggleStar=function(a){c.toggleStar(a)},this.toggleItem=function(a){this.isCompactView()&&(a.show=!a.show)},this.markRead=function(a){var d=c.get(a);d.keepUnread||d.unread!==!0||(c.markItemRead(a),b.markItemOfFeedRead(d.feedId))},this.getFeed=function(a){return b.getById(a)},this.toggleKeepUnread=function(a){var d=c.get(a);d.unread||(b.markItemOfFeedUnread(d.feedId),c.markItemRead(a,!1)),d.keepUnread=!d.keepUnread},this.orderBy=function(){return d.get("oldestFirst")?"id":"-id"},this.isCompactView=function(){return d.get("compact")},this.autoPagingEnabled=function(){return this.isAutoPagingEnabled},this.markReadEnabled=function(){return!d.get("preventReadOnScroll")},this.scrollRead=function(a){var d=[],e=[];a.forEach(function(a){var b=c.get(a);b.keepUnread||(d.push(a),e.push(b.feedId))}),d.length>0&&(b.markItemsOfFeedsRead(e),c.markItemsRead(d))},this.isFeed=function(){return f.current.$$route.type===i.FEED},this.autoPage=function(){if(!this.isAutoPagingEnabled)return void(this.autoPageAgain=!0);this.isAutoPagingEnabled=!1,this.autoPageAgain=!1;var b=f.current.$$route.type,e=h.id,g=d.get("oldestFirst"),i=this;c.autoPage(b,e,g).success(function(b){a.publishAll(b),b.items.length>0&&(i.isAutoPagingEnabled=!0),i.isAutoPagingEnabled&&i.autoPageAgain&&i.autoPage()}).error(function(){i.isAutoPagingEnabled=!0})},this.getRelativeDate=function(a){if(a!==g&&""!==a){var b=d.get("language"),c=moment.unix(a).locale(b).fromNow()+"";return c}return""}}]),h.controller("NavigationController",["$route","FEED_TYPE","FeedResource","FolderResource","ItemResource","SettingsResource","Publisher","$rootScope","$location","$q",function(a,b,c,d,e,f,h,i,j,k){this.feedError="",this.folderError="",this.getFeeds=function(){return c.getAll()},this.getFolders=function(){return d.getAll()},this.markFolderRead=function(a){c.markFolderRead(a),c.getByFolderId(a).forEach(function(a){e.markFeedRead(a.id)})},this.markFeedRead=function(a){e.markFeedRead(a),c.markFeedRead(a)},this.markRead=function(){e.markRead(),c.markRead()},this.isShowAll=function(){return f.get("showAll")},this.getFeedsOfFolder=function(a){return c.getByFolderId(a)},this.getUnreadCount=function(){return c.getUnreadCount()},this.getFeedUnreadCount=function(a){var b=c.getById(a);return b!==g?b.unreadCount:0},this.getFolderUnreadCount=function(a){return c.getFolderUnreadCount(a)},this.getStarredCount=function(){return e.getStarredCount()},this.toggleFolder=function(a){d.toggleOpen(a)},this.hasFeeds=function(a){return c.getFolderUnreadCount(a)!==g},this.subFeedActive=function(d){var e=a.current.$$route.type;if(e===b.FEED){var f=c.getById(a.current.params.id);if(f!==g&&f.folderId===d)return!0}return!1},this.isSubscriptionsActive=function(){return a.current&&a.current.$$route.type===b.SUBSCRIPTIONS},this.isStarredActive=function(){return a.current&&a.current.$$route.type===b.STARRED},this.isFolderActive=function(c){var d=parseInt(a.current.params.id,10);return a.current&&a.current.$$route.type===b.FOLDER&&d===c},this.isFeedActive=function(c){var d=parseInt(a.current.params.id,10);return a.current&&a.current.$$route.type===b.FEED&&d===c},this.folderNameExists=function(a){return a=a||"",d.get(a.trim())!==g},this.feedUrlExists=function(a){return a=a||"",a=a.trim(),c.get(a)!==g||c.get("http://"+a)!==g},this.createFeed=function(a){var b=this;this.newFolder=!1,this.addingFeed=!0;var e=a.newFolder,f=a.existingFolder||{id:0};e===g?(f.getsFeed=!0,c.create(a.url,f.id,g).then(function(a){h.publishAll(a),j.path("/items/feeds/"+a.feeds[0].id+"/")}).finally(function(){f.getsFeed=g,a.url="",b.addingFeed=!1})):d.create(e).then(function(c){h.publishAll(c),a.existingFolder=d.get(c.folders[0].name),a.newFolder=g,b.createFeed(a)})},this.createFolder=function(a){var b=this;this.addingFolder=!0,d.create(a.name).then(function(a){h.publishAll(a)}).finally(function(){b.addingFolder=!1,a.name=""})},this.moveFeed=function(b,d){var e=!1,f=c.getById(b);f.folderId!==d&&((this.isFolderActive(f.folderId)||this.isFolderActive(d))&&(e=!0),c.move(b,d),e&&a.reload())},this.renameFeed=function(a){c.rename(a.id,a.title),a.editing=!1},this.renameFolder=function(a,b){a.renameError="",this.renamingFolder=!0;var c=this;a.name===b?(a.renameError="",a.editing=!1,this.renamingFolder=!1):d.rename(a.name,b).then(function(){a.renameError="",a.editing=!1},function(b){a.renameError=b}).finally(function(){c.renamingFolder=!1})},this.reversiblyDeleteFeed=function(b){c.reversiblyDelete(b.id).finally(function(){a.reload()})},this.undoDeleteFeed=function(b){c.undoDelete(b.id).finally(function(){a.reload()})},this.deleteFeed=function(a){c.delete(a.url)},this.reversiblyDeleteFolder=function(b){k.all(c.reversiblyDeleteFolder(b.id),d.reversiblyDelete(b.name)).finally(function(){a.reload()})},this.undoDeleteFolder=function(b){k.all(c.undoDeleteFolder(b.id),d.undoDelete(b.name)).finally(function(){a.reload()})},this.deleteFolder=function(a){c.deleteFolder(a.id),d.delete(a.name)};var l=this;i.$on("moveFeedToFolder",function(a,b){l.moveFeed(b.feedId,b.folderId)})}]),h.controller("SettingsController",["$route","SettingsResource","FeedResource",function(a,b,c){this.importing=!1,this.opmlImportError=!1,this.articleImportError=!1;var d=function(c,d){b.set(c,d),["showAll","oldestFirst","compact"].indexOf(c)>=0&&a.reload()};this.toggleSetting=function(a){d(a,!this.getSetting(a))},this.getSetting=function(a){return b.get(a)},this.feedSize=function(){return c.size()},this.importOpml=function(a){console.log(a)},this.importArticles=function(a){console.log(a)}}]),h.filter("trustUrl",["$sce",function(a){return function(b){return a.trustAsResourceUrl(b)}}]),h.filter("unreadCountFormatter",function(){return function(a){return a>999?"999+":a}}),h.factory("FeedResource",["Resource","$http","BASE_URL","$q",function(a,b,c,d){var e=function(b,c,d){a.call(this,b,c,"url"),this.ids={},this.unreadCount=0,this.folderUnreadCount={},this.folderIds={},this.$q=d};return e.prototype=Object.create(a.prototype),e.prototype.receive=function(b){a.prototype.receive.call(this,b),this.updateUnreadCache(),this.updateFolderCache()},e.prototype.updateUnreadCache=function(){this.unreadCount=0,this.folderUnreadCount={};var a=this;this.values.forEach(function(b){b.deleted||(b.unreadCount&&(a.unreadCount+=b.unreadCount),b.folderId!==g&&(a.folderUnreadCount[b.folderId]=a.folderUnreadCount[b.folderId]||0,a.folderUnreadCount[b.folderId]+=b.unreadCount))})},e.prototype.updateFolderCache=function(){this.folderIds={};var a=this;this.values.forEach(function(b){a.folderIds[b.folderId]=a.folderIds[b.folderId]||[],a.folderIds[b.folderId].push(b)})},e.prototype.add=function(b){a.prototype.add.call(this,b),b.id!==g&&(this.ids[b.id]=this.hashMap[b.url])},e.prototype.markRead=function(){this.values.forEach(function(a){a.unreadCount=0}),this.unreadCount=0,this.folderUnreadCount={}},e.prototype.markFeedRead=function(a){this.ids[a].unreadCount=0,this.updateUnreadCache()},e.prototype.markFolderRead=function(a){this.values.forEach(function(b){b.folderId===a&&(b.unreadCount=0)}),this.updateUnreadCache()},e.prototype.markItemOfFeedRead=function(a){this.ids[a].unreadCount-=1,this.updateUnreadCache()},e.prototype.markItemsOfFeedsRead=function(a){var b=this;a.forEach(function(a){b.ids[a].unreadCount-=1}),this.updateUnreadCache()},e.prototype.markItemOfFeedUnread=function(a){this.ids[a].unreadCount+=1,this.updateUnreadCache()},e.prototype.getUnreadCount=function(){return this.unreadCount},e.prototype.getFolderUnreadCount=function(a){return this.folderUnreadCount[a]},e.prototype.getByFolderId=function(a){return this.folderIds[a]||[]},e.prototype.getById=function(a){return this.ids[a]},e.prototype.rename=function(a,b){return this.http({method:"POST",url:this.BASE_URL+"/feeds/"+a+"/rename",data:{feedTitle:b}})},e.prototype.move=function(a,b){var c=this.getById(a);return c.folderId=b,this.updateFolderCache(),this.updateUnreadCache(),this.http({method:"POST",url:this.BASE_URL+"/feeds/"+c.id+"/move",data:{parentFolderId:b}})},e.prototype.create=function(a,b,c){a=a.trim(),a.startsWith("http")||(a="http://"+a),c!==g&&(c=c.trim());var d={url:a,folderId:b||0,title:c||a,unreadCount:0};this.add(d),this.updateFolderCache();var e=this.$q.defer();return this.http({method:"POST",url:this.BASE_URL+"/feeds",data:{url:a,parentFolderId:b||0,title:c}}).success(function(a){e.resolve(a)}).error(function(a){d.faviconLink="",d.error=a.message,e.reject()}),e.promise},e.prototype.reversiblyDelete=function(a,b){var c=this.getById(a);return c&&(c.deleted=!0),b!==!1&&this.updateUnreadCache(),this.http.delete(this.BASE_URL+"/feeds/"+a)},e.prototype.reversiblyDeleteFolder=function(a){var b=this,c=[];this.getByFolderId(a).forEach(function(a){c.push(b.reversiblyDelete(a.id,!1))}),this.updateUnreadCache();var d=this.$q.all(c);return d.promise},e.prototype.delete=function(b,c){var d=this.get(b);return d.id&&delete this.ids[d.id],a.prototype.delete.call(this,b),c!==!1&&(this.updateUnreadCache(),this.updateFolderCache()),d},e.prototype.deleteFolder=function(a){var b=this;this.getByFolderId(a).forEach(function(a){b.delete(a.url,!1)}),this.updateUnreadCache(),this.updateFolderCache()},e.prototype.undoDelete=function(a,b){var c=this.getById(a);return c&&(c.deleted=!1),b!==!1&&this.updateUnreadCache(),this.http.post(this.BASE_URL+"/feeds/"+a+"/restore")},e.prototype.undoDeleteFolder=function(a){var b=this,c=[];this.getByFolderId(a).forEach(function(a){c.push(b.undoDelete(a.id,!1))}),this.updateUnreadCache();var d=this.$q.all(c);return d.promise},new e(b,c,d)}]),h.factory("FolderResource",["Resource","$http","BASE_URL","$q",function(a,b,c,d){var e=function(b,c,d){a.call(this,b,c,"name"),this.deleted=null,this.$q=d};return e.prototype=Object.create(a.prototype),e.prototype.toggleOpen=function(a){var b=this.get(a);return b.opened=!b.opened,this.http({url:this.BASE_URL+"/folders/"+b.id+"/open",method:"POST",data:{folderId:b.id,open:b.opened}})},e.prototype.rename=function(a,b){var c=this.get(a),d=this.$q.defer(),e=this;return this.http({url:this.BASE_URL+"/folders/"+c.id+"/rename",method:"POST",data:{folderName:b}}).success(function(){c.name=b,delete e.hashMap[a],e.hashMap[b]=c,d.resolve()}).error(function(a){d.reject(a.message)}),d.promise},e.prototype.create=function(a){a=a.trim();var b={name:a};this.add(b);var c=this.$q.defer();return this.http({url:this.BASE_URL+"/folders",method:"POST",data:{folderName:a}}).success(function(a){c.resolve(a)}).error(function(a){b.error=a.message}),c.promise},e.prototype.reversiblyDelete=function(a){var b=this.get(a),c=b.id;return b.deleted=!0,this.http.delete(this.BASE_URL+"/folders/"+c)},e.prototype.undoDelete=function(a){var b=this.get(a),c=b.id;return b.deleted=!1,this.http.post(this.BASE_URL+"/folders/"+c+"/restore")},new e(b,c,d)}]),h.factory("ItemResource",["Resource","$http","BASE_URL","ITEM_BATCH_SIZE",function(a,b,c,d){var e=function(b,c,d){a.call(this,b,c),this.batchSize=d,this.clear()};return e.prototype=Object.create(a.prototype),e.prototype.clear=function(){this.starredCount=0,this.lowestId=0,this.highestId=0,a.prototype.clear.call(this)},e.prototype.receive=function(b,c){switch(c){case"newestItemId":this.newestItemId=b;break;case"starred":this.starredCount=b;break;default:var d=this;b.forEach(function(a){0===d.lowestId&&(d.lowestId=a.id),0===d.highestId&&(d.highestId=a.id),a.id>d.highestId&&(d.highestId=a.id),a.id<d.lowestId&&(d.lowestId=a.id)}),a.prototype.receive.call(this,b,c)}},e.prototype.getNewestItemId=function(){return this.newestItemId},e.prototype.getStarredCount=function(){return this.starredCount},e.prototype.star=function(a,b){b===g&&(b=!0);var c=this.get(a),d=this.BASE_URL+"/items/"+c.feedId+"/"+c.guidHash+"/star";return c.starred=b,b?this.starredCount+=1:this.starredCount-=1,this.http({url:d,method:"POST",data:{isStarred:b}})},e.prototype.toggleStar=function(a){this.get(a).starred?this.star(a,!1):this.star(a,!0)},e.prototype.markItemRead=function(a,b){return b===g&&(b=!0),this.get(a).unread=!b,this.http({url:this.BASE_URL+"/items/"+a+"/read",method:"POST",data:{isRead:b}})},e.prototype.markItemsRead=function(a){var b=this;return a.forEach(function(a){b.get(a).unread=!1}),this.http({url:this.BASE_URL+"/items/read/multiple",method:"POST",data:{itemIds:a}})},e.prototype.markFeedRead=function(a,b){b===g&&(b=!0);var c=this.values.filter(function(b){return b.feedId===a});return c.forEach(function(a){a.unread=!b}),this.http.post(this.BASE_URL+"/feeds/"+a+"/read",{highestItemId:this.getNewestItemId()})},e.prototype.markRead=function(){return this.values.forEach(function(a){a.unread=!1}),this.http({url:this.BASE_URL+"/items/read",method:"POST",data:{highestItemId:this.getNewestItemId()}})},e.prototype.autoPage=function(a,b,c){var d;return d=c?this.highestId:this.lowestId,this.http({url:this.BASE_URL+"/items",method:"GET",params:{type:a,id:b,offset:d,limit:this.batchSize,oldestFirst:c}})},new e(b,c,d)}]),h.service("Loading",function(){this.loading={global:!1,content:!1,autopaging:!1},this.setLoading=function(a,b){this.loading[a]=b},this.isLoading=function(a){return this.loading[a]}}),h.service("OPMLParser",function(){var a=function(a){var b=a.attr("xmlUrl")||a.attr("htmlUrl"),c=a.attr("title")||a.attr("text")||b;return b===g?{type:"folder",name:c,feeds:[]}:{type:"feed",name:c,url:b}},b=function(c,e,f){for(var g=0;g<c.length;g+=1){var h=d(c[g]),i=a(h);"feed"===i.type?e.feeds.push(i):f?(b(h.children("outline"),i,!1),e.folders.push(i)):b(h.children("outline"),e,!1)}return e};this.parse=function(a){a=d.parseXML(a);var c=d(a).find("body > outline"),e={feeds:[],folders:[]};return b(c,e,!0)}}),h.service("Publisher",function(){this.channels={},this.subscribe=function(a){var b=this;return{toChannels:function(c){c.forEach(function(c){b.channels[c]=b.channels[c]||[],b.channels[c].push(a)})}}},this.publishAll=function(a){var b=this;Object.keys(a).forEach(function(c){var d=b.channels[c];d!==g&&d.forEach(function(b){b.receive(a[c],c)})})}}),h.factory("Resource",function(){var a=function(a,b,c){this.id=c||"id",this.values=[],this.hashMap={},this.http=a,this.BASE_URL=b};return a.prototype.receive=function(a){var b=this;a.forEach(function(a){b.add(a)})},a.prototype.add=function(a){var b=this.hashMap[a[this.id]];b===g?(this.values.push(a),this.hashMap[a[this.id]]=a):Object.keys(a).forEach(function(c){b[c]=a[c]})},a.prototype.size=function(){return this.values.length},a.prototype.get=function(a){return this.hashMap[a]},a.prototype.delete=function(a){var b=this,c=this.values.findIndex(function(c){return c[b.id]===a});c!==g&&this.values.splice(c,1),this.hashMap[a]!==g&&delete this.hashMap[a]},a.prototype.clear=function(){for(this.hashMap={};this.values.length>0;)this.values.pop()},a.prototype.getAll=function(){return this.values},a}),h.service("SettingsResource",["$http","BASE_URL",function(a,b){this.settings={language:"en",showAll:!1,compact:!1,oldestFirst:!1,preventReadOnScroll:!1},this.defaultLanguageCode="en",this.supportedLanguageCodes=["ar-ma","ar","bg","ca","cs","cv","da","de","el","en-ca","en-gb","eo","es","et","eu","fi","fr-ca","fr","gl","he","hi","hu","id","is","it","ja","ka","ko","lv","ms-my","nb","ne","nl","pl","pt-br","pt","ro","ru","sk","sl","sv","th","tr","tzm-la","tzm","uk","zh-cn","zh-tw"],this.receive=function(a){var b=this;Object.keys(a).forEach(function(c){var d=a[c];"language"===c&&(d=b.processLanguageCode(d)),b.settings[c]=d})},this.get=function(a){return this.settings[a]},this.set=function(c,d){return this.settings[c]=d,a({url:b+"/settings",method:"PUT",data:this.settings})},this.processLanguageCode=function(a){return a=a.replace("_","-").toLowerCase(),this.supportedLanguageCodes.indexOf(a)<0&&(a=a.split("-")[0]),this.supportedLanguageCodes.indexOf(a)<0&&(a=this.defaultLanguageCode),a}}]),function(a,b,c){var d=function(a){return!(a.is("input")||a.is("select")||a.is("textarea")||a.is("checkbox"))},e=function(a){return!(a.shiftKey||a.altKey||a.ctrlKey||a.metaKey)},f=function(a,b){var d=a.find(".item");d.each(function(a,d){return d=c(d),d.height()+d.position().top>30?(b(d),!1):void 0})},g=function(a){f(a,function(a){a.find(".toggle-keep-unread").trigger("click")})},h=function(a){f(a,function(a){a.find(".star").trigger("click")})},i=function(a){f(a,function(a){a.find(".utils").trigger("click")})},j=function(b){f(b,function(b){b.trigger("click"),a.open(b.find(".external:visible").attr("href"),"_blank")})},k=function(a,b,c){a.scrollTop(b.offset().top-a.offset().top+a.scrollTop()),c&&f(a,function(a){a.hasClass("open")||a.find(".utils").trigger("click")})},l=function(a,b){var d=a.find(".item"),e=!1;d.each(function(d,f){return f=c(f),f.position().top>1?(k(a,f,b),e=!0,!1):void 0}),e||a.scrollTop(a.prop("scrollHeight"))},m=function(a,b){var d=a.find(".item"),e=!1;d.each(function(d,f){if(f=c(f),f.position().top>=0){var g=f.prev();return g.length>0&&k(a,g,b),e=!0,!1}}),!e&&d.length>0&&k(a,d.last())};c(b).keyup(function(a){if(d(c(":focus"))&&e(a)){var b=a.keyCode,f=c("#app-content"),k=c("#app-content-wrapper > .compact").length>0;[74,78,39].indexOf(b)>=0?(a.preventDefault(),l(f,k)):[75,80,37].indexOf(b)>=0?(a.preventDefault(),m(f,k)):[85].indexOf(b)>=0?(a.preventDefault(),g(f)):[69].indexOf(b)>=0?(a.preventDefault(),i(f)):[73,83,76].indexOf(b)>=0?(a.preventDefault(),h(f)):[72].indexOf(b)>=0?(a.preventDefault(),h(f),l(f)):[79].indexOf(b)>=0&&(a.preventDefault(),j(f))}})}(a,b,d),h.run(["$document","$rootScope",function(a,b){a.click(function(a){b.$broadcast("documentClicked",a)})}]),h.directive("appNavigationEntryUtils",function(){return{restrict:"C",link:function(a,b){var c=b.siblings(".app-navigation-entry-menu"),e=d(b).find(".app-navigation-entry-utils-menu-button button");e.click(function(){c.toggleClass("open")}),a.$on("documentClicked",function(a,b){b.target!==e[0]&&c.removeClass("open")})}}}),h.directive("newsAudio",function(){return{restrict:"E",scope:{src:"@",type:"@"},transclude:!0,template:'<audio controls="controls" preload="none" ng-hide="cantPlay()"><source ng-src="{{ src|trustUrl }}"></audio><a ng-href="{{ src|trustUrl }}" class="button" ng-show="cantPlay()" ng-transclude></a>',link:function(a,b){var c=b.children().children("source")[0],d=!1;c.addEventListener("error",function(){a.$apply(function(){d=!0})}),a.cantPlay=function(){return d}}}}),h.directive("newsAutoFocus",["$timeout",function(a){return function(b,c,e){var f=c;e.newsAutoFocus&&(f=d(e.newsAutoFocus)),a(function(){f.focus()},0)}}]),h.directive("newsBindHtmlUnsafe",function(){return function(a,b,c){a.$watch(c.newsBindHtmlUnsafe,function(){b.html(a.$eval(c.newsBindHtmlUnsafe))})}}),h.directive("newsDraggable",function(){return function(a,b,d){var e=a.$eval(d.newsDraggable);c.isDefined(e)?b.draggable(e):b.draggable(),d.$observe("newsDraggableDisable",function(a){b.draggable("true"===a?"disable":"enable")})}}),h.directive("newsDroppable",["$rootScope",function(a){return function(b,c,e){var f={accept:".feed",hoverClass:"drag-and-drop",greedy:!0,drop:function(f,g){d(".drag-and-drop").removeClass("drag-and-drop");var h={folderId:parseInt(c.data("id"),10),feedId:parseInt(d(g.draggable).data("id"),10)};a.$broadcast("moveFeedToFolder",h),b.$apply(e.droppable)}};c.droppable(f)}}]),h.directive("newsFocus",["$timeout","$interpolate",function(a,b){return function(c,e,f){e.click(function(){var e=d(b(f.newsFocus)(c));a(function(){e.focus()},500)})}}]),h.directive("newsReadFile",function(){return function(a,b,c){b.change(function(){var d=b[0].files[0],e=new FileReader;e.onload=function(d){b[0].value=0,a.$fileContent=d.target.result,a.$apply(c.newsReadFile)},e.readAsText(d)})}}),h.directive("newsScroll",["$timeout",function(a){var b,c=function(a,b,c){for(var e=0,f=b.find(".item"),g=f.length-1;g>=0;g-=1){var h=d(f[g]);if(e>=a)break;if(h.position().top<0){c.$apply(c.newsScrollAutoPage);break}e+=1}},e=function(a,b,c){if(a){var e=[],f=b.find(".item:not(.read)");f.each(function(a,b){var c=d(b);return c.position().top<=-50?void e.push(parseInt(c.data("id"),10)):!1}),c.itemIds=e,c.$apply(c.newsScrollMarkRead)}};return{restrict:"A",scope:{newsScroll:"@",newsScrollAutoPage:"&",newsScrollMarkRead:"&",newsScrollEnabledMarkRead:"=",newsScrollMarkReadTimeout:"@",newsScrollTimeout:"@",newsScrollAutoPageWhenLeft:"@"},link:function(f,h){var i=!0,j=h;f.newsScroll&&(j=d(f.newsScroll));var k=f.newsScrollTimeout||1,l=f.newsScrollMarkReadTimeout||1,m=f.newsScrollAutoPageWhenLeft||50,n=function(){i&&(i=!1,a(function(){i=!0},100*k),c(m,h,f),b&&a.cancel(b),b=a(function(){e(f.newsScrollEnabledMarkRead,h,f),b=g},1e3*l))};j.on("scroll",n),f.$on("$destroy",function(){j.off("scroll",n)})}}}]),h.directive("newsStopPropagation",function(){return{restrict:"A",link:function(a,b){b.bind("click",function(a){a.stopPropagation()})}}}),h.directive("newsTimeout",["$timeout",function(a){return{restrict:"A",scope:{newsTimeout:"&"},link:function(b){var c=7,d=a(b.newsTimeout,1e3*c);b.$on("$destroy",function(){a.cancel(d)})}}}]),h.directive("newsTitleUnreadCount",["$window",function(a){var b=a.document.title;return{restrict:"E",scope:{unreadCount:"@"},link:function(c,d,e){e.$observe("unreadCount",function(c){var d=b.split("-");"0"!==c&&(a.document.title=d[0]+"("+c+") - "+d[1])})}}}]),h.directive("newsTriggerClick",function(){return function(a,b,c){b.click(function(){d(c.newsTriggerClick).trigger("click")})}})}(window,document,angular,jQuery,OC,oc_requesttoken); \ No newline at end of file
+!function(a,b,c,d,e,f,g){"use strict";var h=c.module("News",["ngRoute","ngSanitize"]);h.config(["$routeProvider","$provide","$httpProvider",function(a,b,c){var d={FEED:0,FOLDER:1,STARRED:2,SUBSCRIPTIONS:3,SHARED:4};b.constant("REFRESH_RATE",60),b.constant("ITEM_BATCH_SIZE",50),b.constant("BASE_URL",e.generateUrl("/apps/news")),b.constant("FEED_TYPE",d),b.factory("CSRFInterceptor",["$q","BASE_URL",function(a,b){return{request:function(c){return 0===c.url.indexOf(b)&&(c.headers.requesttoken=f),c||a.when(c)}}}]),c.interceptors.push("CSRFInterceptor");var h=function(a){return{data:["$http","$route","$q","BASE_URL","ITEM_BATCH_SIZE",function(b,c,d,e,f){var h={type:a,limit:f};c.current.params.id!==g&&(h.id=c.current.params.id);var i=d.defer();return b({url:e+"/items",method:"GET",params:h}).success(function(a){i.resolve(a)}),i.promise}]}};a.when("/items",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.SUBSCRIPTIONS),type:d.SUBSCRIPTIONS}).when("/items/starred",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.STARRED),type:d.STARRED}).when("/items/feeds/:id",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.FEED),type:d.FEED}).when("/items/folders/:id",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.FOLDER),type:d.FOLDER})}]),h.run(["$rootScope","$location","$http","$q","$interval","Loading","ItemResource","FeedResource","FolderResource","SettingsResource","Publisher","BASE_URL","FEED_TYPE","REFRESH_RATE",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){f.setLoading("global",!0),k.subscribe(g).toChannels(["items","newestItemId","starred"]),k.subscribe(i).toChannels(["folders"]),k.subscribe(h).toChannels(["feeds"]),k.subscribe(j).toChannels(["settings"]);var o=d.defer();c.get(l+"/settings").success(function(a){k.publishAll(a),o.resolve()});var p=d.defer(),q=b.path();c.get(l+"/feeds/active").success(function(a){var c;switch(a.activeFeed.type){case m.FEED:c="/items/feeds/"+a.activeFeed.id;break;case m.FOLDER:c="/items/folders/"+a.activeFeed.id;break;case m.STARRED:c="/items/starred";break;default:c="/items"}/^\/items(\/(starred|feeds\/\d+|folders\/\d+))?\/?$/.test(q)||b.path(c),p.resolve()});var r=d.defer();c.get(l+"/folders").success(function(a){k.publishAll(a),r.resolve()});var s=d.defer();c.get(l+"/feeds").success(function(a){k.publishAll(a),s.resolve()}),d.all([o.promise,p.promise,s.promise,r.promise]).then(function(){f.setLoading("global",!1)}),e(function(){c.get(l+"/feeds"),c.get(l+"/folders")},1e3*n),a.$on("$routeChangeStart",function(){f.setLoading("content",!0)}),a.$on("$routeChangeSuccess",function(){f.setLoading("content",!1)}),a.$on("$routeChangeError",function(){b.path("/items")})}]),h.controller("AppController",["Loading","FeedResource","FolderResource",function(a,b,c){this.loading=a,this.isFirstRun=function(){return 0===b.size()&&0===c.size()}}]),h.controller("ContentController",["Publisher","FeedResource","ItemResource","SettingsResource","data","$route","$routeParams","FEED_TYPE",function(a,b,c,d,e,f,h,i){c.clear(),a.publishAll(e),this.isAutoPagingEnabled=!0,this.getItems=function(){return c.getAll()},this.toggleStar=function(a){c.toggleStar(a)},this.toggleItem=function(a){this.isCompactView()&&(a.show=!a.show)},this.markRead=function(a){var d=c.get(a);d.keepUnread||d.unread!==!0||(c.markItemRead(a),b.markItemOfFeedRead(d.feedId))},this.getFeed=function(a){return b.getById(a)},this.toggleKeepUnread=function(a){var d=c.get(a);d.unread||(b.markItemOfFeedUnread(d.feedId),c.markItemRead(a,!1)),d.keepUnread=!d.keepUnread},this.orderBy=function(){return d.get("oldestFirst")?"id":"-id"},this.isCompactView=function(){return d.get("compact")},this.autoPagingEnabled=function(){return this.isAutoPagingEnabled},this.markReadEnabled=function(){return!d.get("preventReadOnScroll")},this.scrollRead=function(a){var d=[],e=[];a.forEach(function(a){var b=c.get(a);b.keepUnread||(d.push(a),e.push(b.feedId))}),d.length>0&&(b.markItemsOfFeedsRead(e),c.markItemsRead(d))},this.isFeed=function(){return f.current.$$route.type===i.FEED},this.autoPage=function(){if(!this.isAutoPagingEnabled)return void(this.autoPageAgain=!0);this.isAutoPagingEnabled=!1,this.autoPageAgain=!1;var b=f.current.$$route.type,e=h.id,g=d.get("oldestFirst"),i=this;c.autoPage(b,e,g).success(function(b){a.publishAll(b),b.items.length>0&&(i.isAutoPagingEnabled=!0),i.isAutoPagingEnabled&&i.autoPageAgain&&i.autoPage()}).error(function(){i.isAutoPagingEnabled=!0})},this.getRelativeDate=function(a){if(a!==g&&""!==a){var b=d.get("language"),c=moment.unix(a).locale(b).fromNow()+"";return c}return""}}]),h.controller("NavigationController",["$route","FEED_TYPE","FeedResource","FolderResource","ItemResource","SettingsResource","Publisher","$rootScope","$location","$q",function(a,b,c,d,e,f,h,i,j,k){this.feedError="",this.folderError="",this.getFeeds=function(){return c.getAll()},this.getFolders=function(){return d.getAll()},this.markFolderRead=function(a){c.markFolderRead(a),c.getByFolderId(a).forEach(function(a){e.markFeedRead(a.id)})},this.markFeedRead=function(a){e.markFeedRead(a),c.markFeedRead(a)},this.markRead=function(){e.markRead(),c.markRead()},this.isShowAll=function(){return f.get("showAll")},this.getFeedsOfFolder=function(a){return c.getByFolderId(a)},this.getUnreadCount=function(){return c.getUnreadCount()},this.getFeedUnreadCount=function(a){var b=c.getById(a);return b!==g?b.unreadCount:0},this.getFolderUnreadCount=function(a){return c.getFolderUnreadCount(a)},this.getStarredCount=function(){return e.getStarredCount()},this.toggleFolder=function(a){d.toggleOpen(a)},this.hasFeeds=function(a){return c.getFolderUnreadCount(a)!==g},this.subFeedActive=function(d){var e=a.current.$$route.type;if(e===b.FEED){var f=c.getById(a.current.params.id);if(f!==g&&f.folderId===d)return!0}return!1},this.isSubscriptionsActive=function(){return a.current&&a.current.$$route.type===b.SUBSCRIPTIONS},this.isStarredActive=function(){return a.current&&a.current.$$route.type===b.STARRED},this.isFolderActive=function(c){var d=parseInt(a.current.params.id,10);return a.current&&a.current.$$route.type===b.FOLDER&&d===c},this.isFeedActive=function(c){var d=parseInt(a.current.params.id,10);return a.current&&a.current.$$route.type===b.FEED&&d===c},this.folderNameExists=function(a){return a=a||"",d.get(a.trim())!==g},this.feedUrlExists=function(a){return a=a||"",a=a.trim(),c.get(a)!==g||c.get("http://"+a)!==g},this.createFeed=function(a){var b=this;this.newFolder=!1,this.addingFeed=!0;var e=a.newFolder,f=a.existingFolder||{id:0};e===g?(f.getsFeed=!0,c.create(a.url,f.id,g).then(function(a){h.publishAll(a),j.path("/items/feeds/"+a.feeds[0].id+"/")}).finally(function(){f.getsFeed=g,a.url="",b.addingFeed=!1})):d.create(e).then(function(c){h.publishAll(c),a.existingFolder=d.get(c.folders[0].name),a.newFolder=g,b.createFeed(a)})},this.createFolder=function(a){var b=this;this.addingFolder=!0,d.create(a.name).then(function(a){h.publishAll(a)}).finally(function(){b.addingFolder=!1,a.name=""})},this.moveFeed=function(b,d){var e=!1,f=c.getById(b);f.folderId!==d&&((this.isFolderActive(f.folderId)||this.isFolderActive(d))&&(e=!0),c.move(b,d),e&&a.reload())},this.renameFeed=function(a){c.rename(a.id,a.title),a.editing=!1},this.renameFolder=function(a,b){a.renameError="",this.renamingFolder=!0;var c=this;a.name===b?(a.renameError="",a.editing=!1,this.renamingFolder=!1):d.rename(a.name,b).then(function(){a.renameError="",a.editing=!1},function(b){a.renameError=b}).finally(function(){c.renamingFolder=!1})},this.reversiblyDeleteFeed=function(b){c.reversiblyDelete(b.id).finally(function(){a.reload()})},this.undoDeleteFeed=function(b){c.undoDelete(b.id).finally(function(){a.reload()})},this.deleteFeed=function(a){c.delete(a.url)},this.reversiblyDeleteFolder=function(b){k.all(c.reversiblyDeleteFolder(b.id),d.reversiblyDelete(b.name)).finally(function(){a.reload()})},this.undoDeleteFolder=function(b){k.all(c.undoDeleteFolder(b.id),d.undoDelete(b.name)).finally(function(){a.reload()})},this.deleteFolder=function(a){c.deleteFolder(a.id),d.delete(a.name)};var l=this;i.$on("moveFeedToFolder",function(a,b){l.moveFeed(b.feedId,b.folderId)})}]),h.controller("SettingsController",["$route","$q","SettingsResource","ItemResource","OPMLParser","OPMLImporter","Publisher",function(a,b,c,d,e,f,g){this.isOPMLImporting=!1,this.isArticlesImporting=!1,this.opmlImportError=!1,this.articleImportError=!1;var h=function(b,d){c.set(b,d),["showAll","oldestFirst","compact"].indexOf(b)>=0&&a.reload()};this.toggleSetting=function(a){h(a,!this.getSetting(a))},this.getSetting=function(a){return c.get(a)},this.importOPML=function(a){this.opmlImportError=!1,this.articleImportError=!1;try{this.isOPMLImporting=!1;var b=e.parse(a),c=this,d=5;f.importFolders(b).then(function(a){return f.importFeedQueue(a,d)}).finally(function(){c.isOPMLImporting=!1})}catch(g){this.isOPMLImporting=!1,this.opmlImportError=!0}},this.importArticles=function(a){this.opmlImportError=!1,this.articleImportError=!1;try{this.isArticlesImporting=!0;var b=JSON.parse(a),c=this;d.importArticles(b).success(function(a){g.publishAll(a)}).finally(function(){c.isArticlesImporting=!1})}catch(e){this.articleImportError=!0,this.isArticlesImporting=!1}}}]),h.filter("trustUrl",["$sce",function(a){return function(b){return a.trustAsResourceUrl(b)}}]),h.filter("unreadCountFormatter",function(){return function(a){return a>999?"999+":a}}),h.factory("FeedResource",["Resource","$http","BASE_URL","$q",function(a,b,c,d){var e=function(b,c,d){a.call(this,b,c,"url"),this.ids={},this.unreadCount=0,this.folderUnreadCount={},this.folderIds={},this.$q=d};return e.prototype=Object.create(a.prototype),e.prototype.receive=function(b){a.prototype.receive.call(this,b),this.updateUnreadCache(),this.updateFolderCache()},e.prototype.updateUnreadCache=function(){this.unreadCount=0,this.folderUnreadCount={};var a=this;this.values.forEach(function(b){b.deleted||(b.unreadCount&&(a.unreadCount+=b.unreadCount),b.folderId!==g&&(a.folderUnreadCount[b.folderId]=a.folderUnreadCount[b.folderId]||0,a.folderUnreadCount[b.folderId]+=b.unreadCount))})},e.prototype.updateFolderCache=function(){this.folderIds={};var a=this;this.values.forEach(function(b){a.folderIds[b.folderId]=a.folderIds[b.folderId]||[],a.folderIds[b.folderId].push(b)})},e.prototype.add=function(b){a.prototype.add.call(this,b),b.id!==g&&(this.ids[b.id]=this.hashMap[b.url])},e.prototype.markRead=function(){this.values.forEach(function(a){a.unreadCount=0}),this.unreadCount=0,this.folderUnreadCount={}},e.prototype.markFeedRead=function(a){this.ids[a].unreadCount=0,this.updateUnreadCache()},e.prototype.markFolderRead=function(a){this.values.forEach(function(b){b.folderId===a&&(b.unreadCount=0)}),this.updateUnreadCache()},e.prototype.markItemOfFeedRead=function(a){this.ids[a].unreadCount-=1,this.updateUnreadCache()},e.prototype.markItemsOfFeedsRead=function(a){var b=this;a.forEach(function(a){b.ids[a].unreadCount-=1}),this.updateUnreadCache()},e.prototype.markItemOfFeedUnread=function(a){this.ids[a].unreadCount+=1,this.updateUnreadCache()},e.prototype.getUnreadCount=function(){return this.unreadCount},e.prototype.getFolderUnreadCount=function(a){return this.folderUnreadCount[a]},e.prototype.getByFolderId=function(a){return this.folderIds[a]||[]},e.prototype.getById=function(a){return this.ids[a]},e.prototype.rename=function(a,b){return this.http({method:"POST",url:this.BASE_URL+"/feeds/"+a+"/rename",data:{feedTitle:b}})},e.prototype.move=function(a,b){var c=this.getById(a);return c.folderId=b,this.updateFolderCache(),this.updateUnreadCache(),this.http({