summaryrefslogtreecommitdiffstats
path: root/js/build/app/services/businesslayer
diff options
context:
space:
mode:
Diffstat (limited to 'js/build/app/services/businesslayer')
-rw-r--r--js/build/app/services/businesslayer/businesslayer.js54
-rw-r--r--js/build/app/services/businesslayer/feedbusinesslayer.js233
-rw-r--r--js/build/app/services/businesslayer/folderbusinesslayer.js241
-rw-r--r--js/build/app/services/businesslayer/itembusinesslayer.js144
-rw-r--r--js/build/app/services/businesslayer/starredbusinesslayer.js66
-rw-r--r--js/build/app/services/businesslayer/subscriptionsbusinesslayer.js84
6 files changed, 822 insertions, 0 deletions
diff --git a/js/build/app/services/businesslayer/businesslayer.js b/js/build/app/services/businesslayer/businesslayer.js
new file mode 100644
index 000000000..71056c0aa
--- /dev/null
+++ b/js/build/app/services/businesslayer/businesslayer.js
@@ -0,0 +1,54 @@
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+(function() {
+ angular.module('News').factory('_BusinessLayer', function() {
+ var BusinessLayer;
+ BusinessLayer = (function() {
+ function BusinessLayer(_activeFeed, _persistence, _itemModel, _type) {
+ this._activeFeed = _activeFeed;
+ this._persistence = _persistence;
+ this._itemModel = _itemModel;
+ this._type = _type;
+ }
+
+ BusinessLayer.prototype.load = function(id) {
+ this._itemModel.clear();
+ this._persistence.getItems(this._type, id, 0);
+ return this._activeFeed.handle({
+ id: id,
+ type: this._type
+ });
+ };
+
+ BusinessLayer.prototype.isActive = function(id) {
+ return this._activeFeed.getType() === this._type && this._activeFeed.getId() === id;
+ };
+
+ return BusinessLayer;
+
+ })();
+ return BusinessLayer;
+ });
+
+}).call(this);
diff --git a/js/build/app/services/businesslayer/feedbusinesslayer.js b/js/build/app/services/businesslayer/feedbusinesslayer.js
new file mode 100644
index 000000000..31a04adb5
--- /dev/null
+++ b/js/build/app/services/businesslayer/feedbusinesslayer.js
@@ -0,0 +1,233 @@
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+(function() {
+ var __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ angular.module('News').factory('FeedBusinessLayer', [
+ '_BusinessLayer', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', 'NewLoading', '_ExistsError', 'Utils', '$rootScope', 'NewestItem', function(_BusinessLayer, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel, NewLoading, _ExistsError, Utils, $rootScope, NewestItem) {
+ var FeedBusinessLayer;
+ FeedBusinessLayer = (function(_super) {
+ __extends(FeedBusinessLayer, _super);
+
+ function FeedBusinessLayer(_showAll, _feedModel, persistence, activeFeed, feedType, itemModel, _newLoading, _utils, _$rootScope, _newestItem) {
+ this._showAll = _showAll;
+ this._feedModel = _feedModel;
+ this._newLoading = _newLoading;
+ this._utils = _utils;
+ this._$rootScope = _$rootScope;
+ this._newestItem = _newestItem;
+ FeedBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Feed);
+ this._feedType = feedType;
+ }
+
+ FeedBusinessLayer.prototype.getUnreadCount = function(feedId) {
+ return this._feedModel.getFeedUnreadCount(feedId);
+ };
+
+ FeedBusinessLayer.prototype.getFeedsOfFolder = function(folderId) {
+ return this._feedModel.getAllOfFolder(folderId);
+ };
+
+ FeedBusinessLayer.prototype.getFolderUnreadCount = function(folderId) {
+ return this._feedModel.getFolderUnreadCount(folderId);
+ };
+
+ FeedBusinessLayer.prototype.getAllUnreadCount = function() {
+ return this._feedModel.getUnreadCount();
+ };
+
+ FeedBusinessLayer.prototype["delete"] = function(feedId) {
+ var data, feed,
+ _this = this;
+ feed = this._feedModel.removeById(feedId);
+ data = {
+ undoCallback: function() {
+ _this._persistence.restoreFeed(feedId, function() {});
+ return _this._persistence.getAllFeeds();
+ },
+ caption: feed.title
+ };
+ this._$rootScope.$broadcast('undoMessage', data);
+ return this._persistence.deleteFeed(feedId);
+ };
+
+ FeedBusinessLayer.prototype.markRead = function(feedId) {
+ var feed, item, newestItemId, _i, _len, _ref;
+ feed = this._feedModel.getById(feedId);
+ newestItemId = this._newestItem.getId();
+ if (angular.isDefined(feed) && newestItemId !== 0) {
+ feed.unreadCount = 0;
+ _ref = this._itemModel.getAll();
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ item = _ref[_i];
+ if (item.feedId === feed.id) {
+ item.setRead();
+ }
+ }
+ return this._persistence.setFeedRead(feedId, newestItemId);
+ }
+ };
+
+ FeedBusinessLayer.prototype.getNumberOfFeeds = function() {
+ return this._feedModel.size();
+ };
+
+ FeedBusinessLayer.prototype.noFeeds = function() {
+ return this.getNumberOfFeeds() === 0;
+ };
+
+ FeedBusinessLayer.prototype.isVisible = function(feedId) {
+ if (this.isActive(feedId) || this._showAll.getShowAll()) {
+ return true;
+ } else {
+ return this._feedModel.getFeedUnreadCount(feedId) > 0;
+ }
+ };
+
+ FeedBusinessLayer.prototype.move = function(feedId, folderId) {
+ var feed;
+ feed = this._feedModel.getById(feedId);
+ if (angular.isDefined(feed) && feed.folderId !== folderId) {
+ this._feedModel.update({
+ id: feedId,
+ folderId: folderId,
+ url: feed.url
+ });
+ return this._persistence.moveFeed(feedId, folderId);
+ }
+ };
+
+ FeedBusinessLayer.prototype.setShowAll = function(showAll) {
+ var callback,
+ _this = this;
+ this._showAll.setShowAll(showAll);
+ callback = function() {
+ _this._itemModel.clear();
+ _this._newLoading.increase();
+ return _this._persistence.getItems(_this._activeFeed.getType(), _this._activeFeed.getId(), 0, function() {
+ return _this._newLoading.decrease();
+ });
+ };
+ if (showAll) {
+ return this._persistence.userSettingsReadShow(callback);
+ } else {
+ return this._persistence.userSettingsReadHide(callback);
+ }
+ };
+
+ FeedBusinessLayer.prototype.isShowAll = function() {
+ return this._showAll.getShowAll();
+ };
+
+ FeedBusinessLayer.prototype.getAll = function() {
+ return this._feedModel.getAll();
+ };
+
+ FeedBusinessLayer.prototype.getFeedLink = function(feedId) {
+ var feed;
+ feed = this._feedModel.getById(feedId);
+ if (angular.isDefined(feed)) {
+ return feed.link;
+ }
+ };
+
+ FeedBusinessLayer.prototype.create = function(url, parentId, onSuccess, onFailure) {
+ var feed, success,
+ _this = this;
+ if (parentId == null) {
+ parentId = 0;
+ }
+ if (onSuccess == null) {
+ onSuccess = null;
+ }
+ if (onFailure == null) {
+ onFailure = null;
+ }
+ onSuccess || (onSuccess = function() {});
+ onFailure || (onFailure = function() {});
+ parentId = parseInt(parentId, 10);
+ if (angular.isUndefined(url) || url.trim() === '') {
+ throw new Error('Url must not be empty');
+ }
+ url = url.trim();
+ if (url.indexOf('http') !== 0) {
+ url = 'http://' + url;
+ }
+ if (this._feedModel.getByUrl(url)) {
+ throw new _ExistsError('Exists already');
+ }
+ feed = {
+ title: url,
+ url: url,
+ folderId: parentId,
+ unreadCount: 0,
+ faviconLink: 'url(' + this._utils.imagePath('core', 'loading.gif') + ')'
+ };
+ this._feedModel.add(feed);
+ success = function(response) {
+ if (response.status === 'error') {
+ feed.error = response.msg;
+ return onFailure();
+ } else {
+ return onSuccess(response.data);
+ }
+ };
+ return this._persistence.createFeed(url, parentId, success);
+ };
+
+ FeedBusinessLayer.prototype.markErrorRead = function(url) {
+ return this._feedModel.removeByUrl(url);
+ };
+
+ FeedBusinessLayer.prototype.importGoogleReader = function(json) {
+ var feed, onSuccess, url,
+ _this = this;
+ url = 'http://owncloud/googlereader';
+ if (angular.isUndefined(this._feedModel.getByUrl(url))) {
+ feed = {
+ title: 'Google Reader',
+ url: url,
+ folderId: 0,
+ unreadCount: 0,
+ faviconLink: 'url(' + this._utils.imagePath('core', 'loading.gif') + ')'
+ };
+ this._feedModel.add(feed);
+ }
+ onSuccess = function(response) {
+ var id;
+ id = response.data.feeds[0].id;
+ return _this.load(id);
+ };
+ return this._persistence.importGoogleReader(json, onSuccess);
+ };
+
+ return FeedBusinessLayer;
+
+ })(_BusinessLayer);
+ return new FeedBusinessLayer(ShowAll, FeedModel, Persistence, ActiveFeed, FeedType, ItemModel, NewLoading, Utils, $rootScope, NewestItem);
+ }
+ ]);
+
+}).call(this);
diff --git a/js/build/app/services/businesslayer/folderbusinesslayer.js b/js/build/app/services/businesslayer/folderbusinesslayer.js
new file mode 100644
index 000000000..126198429
--- /dev/null
+++ b/js/build/app/services/businesslayer/folderbusinesslayer.js
@@ -0,0 +1,241 @@
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+(function() {
+ var __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ angular.module('News').factory('FolderBusinessLayer', [
+ '_BusinessLayer', 'FolderModel', 'FeedBusinessLayer', 'Persistence', 'FeedType', 'ActiveFeed', 'ItemModel', 'ShowAll', '_ExistsError', 'OPMLParser', 'NewestItem', 'FeedModel', '$rootScope', function(_BusinessLayer, FolderModel, FeedBusinessLayer, Persistence, FeedType, ActiveFeed, ItemModel, ShowAll, _ExistsError, OPMLParser, NewestItem, FeedModel, $rootScope) {
+ var FolderBusinessLayer;
+ FolderBusinessLayer = (function(_super) {
+ __extends(FolderBusinessLayer, _super);
+
+ function FolderBusinessLayer(_folderModel, _feedBusinessLayer, _showAll, activeFeed, persistence, _feedType, itemModel, _opmlParser, _newestItem, _feedModel, _$rootScope) {
+ this._folderModel = _folderModel;
+ this._feedBusinessLayer = _feedBusinessLayer;
+ this._showAll = _showAll;
+ this._feedType = _feedType;
+ this._opmlParser = _opmlParser;
+ this._newestItem = _newestItem;
+ this._feedModel = _feedModel;
+ this._$rootScope = _$rootScope;
+ FolderBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, this._feedType.Folder);
+ }
+
+ FolderBusinessLayer.prototype.getById = function(folderId) {
+ return this._folderModel.getById(folderId);
+ };
+
+ FolderBusinessLayer.prototype["delete"] = function(folderId) {
+ var data, feed, feeds, folder, _i, _len, _ref,
+ _this = this;
+ feeds = [];
+ _ref = this._feedBusinessLayer.getFeedsOfFolder(folderId);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ feed = _ref[_i];
+ feeds.push(this._feedModel.removeById(feed.id));
+ }
+ folder = this._folderModel.removeById(folderId);
+ data = {
+ undoCallback: function() {
+ return _this._persistence.restoreFolder(folderId, function() {
+ _this._persistence.getAllFeeds();
+ return _this._persistence.getAllFolders();
+ });
+ },
+ caption: folder.name
+ };
+ this._$rootScope.$broadcast('undoMessage', data);
+ return this._persistence.deleteFolder(folderId);
+ };
+
+ FolderBusinessLayer.prototype.hasFeeds = function(folderId) {
+ return this._feedBusinessLayer.getFeedsOfFolder(folderId).length;
+ };
+
+ FolderBusinessLayer.prototype.open = function(folderId) {
+ var folder;
+ folder = this._folderModel.getById(folderId);
+ if (angular.isDefined(folder)) {
+ if (!folder.opened) {
+ folder.opened = true;
+ return this._persistence.openFolder(folder.id);
+ }
+ }
+ };
+
+ FolderBusinessLayer.prototype.toggleFolder = function(folderId) {
+ var folder;
+ folder = this._folderModel.getById(folderId);
+ if (angular.isDefined(folder)) {
+ folder.opened = !folder.opened;
+ if (folder.opened) {
+ return this._persistence.openFolder(folder.id);
+ } else {
+ return this._persistence.collapseFolder(folder.id);
+ }
+ }
+ };
+
+ FolderBusinessLayer.prototype.markRead = function(folderId) {
+ var feed, folder, item, newestItemId, _i, _j, _len, _len1, _ref, _ref1;
+ newestItemId = this._newestItem.getId();
+ folder = this._folderModel.getById(folderId);
+ if (newestItemId !== 0 && angular.isDefined(folder)) {
+ _ref = this._feedBusinessLayer.getFeedsOfFolder(folderId);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ feed = _ref[_i];
+ feed.unreadCount = 0;
+ _ref1 = this._itemModel.getAll();
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ item = _ref1[_j];
+ if (item.feedId === feed.id) {
+ item.setRead();
+ }
+ }
+ }
+ return this._persistence.setFolderRead(folderId, newestItemId);
+ }
+ };
+
+ FolderBusinessLayer.prototype.getUnreadCount = function(folderId) {
+ return this._feedBusinessLayer.getFolderUnreadCount(folderId);
+ };
+
+ FolderBusinessLayer.prototype.isVisible = function(folderId) {
+ var feed, _i, _len, _ref;
+ if (this._showAll.getShowAll()) {
+ return true;
+ } else {
+ if (this.isActive(folderId) || this._feedBusinessLayer.getFolderUnreadCount(folderId) > 0) {
+ return true;
+ }
+ if (this._activeFeed.getType() === this._feedType.Feed) {
+ _ref = this._feedBusinessLayer.getFeedsOfFolder(folderId);
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ feed = _ref[_i];
+ if (feed.id === this._activeFeed.getId()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ };
+
+ FolderBusinessLayer.prototype.getAll = function() {
+ return this._folderModel.getAll();
+ };
+
+ FolderBusinessLayer.prototype.create = function(folderName, onSuccess, onFailure) {
+ var folder, success,
+ _this = this;
+ if (onSuccess == null) {
+ onSuccess = null;
+ }
+ if (onFailure == null) {
+ onFailure = null;
+ }
+ onSuccess || (onSuccess = function() {});
+ onFailure || (onFailure = function() {});
+ if (angular.isUndefined(folderName) || folderName.trim() === '') {
+ throw new Error('Folder name must not be empty');
+ }
+ folderName = folderName.trim();
+ if (this._folderModel.getByName(folderName)) {
+ throw new _ExistsError('Exists already');
+ }
+ folder = {
+ name: folderName,
+ opened: true
+ };
+ this._folderModel.add(folder);
+ success = function(response) {
+ if (response.status === 'error') {
+ folder.error = response.msg;
+ return onFailure();
+ } else {
+ return onSuccess(response.data);
+ }
+ };
+ return this._persistence.createFolder(folderName, 0, success);
+ };
+
+ FolderBusinessLayer.prototype.markErrorRead = function(folderName) {
+ return this._folderModel.removeByName(folderName);
+ };
+
+ FolderBusinessLayer.prototype["import"] = function(xml) {
+ var opml;
+ opml = this._opmlParser.parseXML(xml);
+ return this._importElement(opml, 0);
+ };
+
+ FolderBusinessLayer.prototype._importElement = function(opml, parentFolderId) {
+ var item, _i, _len, _ref, _results,
+ _this = this;
+ _ref = opml.getItems();
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ item = _ref[_i];
+ _results.push((function(item) {
+ var error, folder;
+ if (item.isFolder()) {
+ try {
+ return _this.create(item.getName(), function(data) {
+ return _this._importElement(item, data.folders[0].id);
+ });
+ } catch (_error) {
+ error = _error;
+ if (error instanceof _ExistsError) {
+ folder = _this._folderModel.getByName(item.getName());
+ _this.open(folder.id);
+ return _this._importElement(item, folder.id);
+ } else {
+ return console.info(error);
+ }
+ }
+ } else {
+ try {
+ return _this._feedBusinessLayer.create(item.getUrl(), parentFolderId);
+ } catch (_error) {
+ error = _error;
+ if (!error instanceof _ExistsError) {
+ return console.info(error);
+ }
+ }
+ }
+ })(item));
+ }
+ return _results;
+ };
+
+ return FolderBusinessLayer;
+
+ })(_BusinessLayer);
+ return new FolderBusinessLayer(FolderModel, FeedBusinessLayer, ShowAll, ActiveFeed, Persistence, FeedType, ItemModel, OPMLParser, NewestItem, FeedModel, $rootScope);
+ }
+ ]);
+
+}).call(this);
diff --git a/js/build/app/services/businesslayer/itembusinesslayer.js b/js/build/app/services/businesslayer/itembusinesslayer.js
new file mode 100644
index 000000000..2c482408a
--- /dev/null
+++ b/js/build/app/services/businesslayer/itembusinesslayer.js
@@ -0,0 +1,144 @@
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+(function() {
+ angular.module('News').factory('ItemBusinessLayer', [
+ 'ItemModel', 'FeedModel', 'Persistence', 'ActiveFeed', 'FeedType', 'StarredBusinessLayer', 'NewestItem', function(ItemModel, FeedModel, Persistence, ActiveFeed, FeedType, StarredBusinessLayer, NewestItem) {
+ var ItemBusinessLayer;
+ ItemBusinessLayer = (function() {
+ function ItemBusinessLayer(_itemModel, _feedModel, _persistence, _activeFeed, _feedType, _starredBusinessLayer, _newestItem) {
+ this._itemModel = _itemModel;
+ this._feedModel = _feedModel;
+ this._persistence = _persistence;
+ this._activeFeed = _activeFeed;
+ this._feedType = _feedType;
+ this._starredBusinessLayer = _starredBusinessLayer;
+ this._newestItem = _newestItem;
+ }
+
+ ItemBusinessLayer.prototype.getAll = function() {
+ return this._itemModel.getAll();
+ };
+
+ ItemBusinessLayer.prototype.noFeedActive = function() {
+ return this._activeFeed.getType() !== this._feedType.Feed;
+ };
+
+ ItemBusinessLayer.prototype.isKeptUnread = function(itemId) {
+ var item;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item) && angular.isDefined(item.keptUnread)) {
+ return item.keptUnread;
+ }
+ return false;
+ };
+
+ ItemBusinessLayer.prototype.toggleKeepUnread = function(itemId) {
+ var item;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item) && !item.keptUnread) {
+ item.keptUnread = true;
+ if (item.isRead()) {
+ return this.setUnread(itemId);
+ }
+ } else {
+ return item.keptUnread = false;
+ }
+ };
+
+ ItemBusinessLayer.prototype.toggleStarred = function(itemId) {
+ var item;
+ item = this._itemModel.getById(itemId);
+ if (item.isStarred()) {
+ item.setUnstarred();
+ this._starredBusinessLayer.decreaseCount();
+ return this._persistence.unstarItem(item.feedId, item.guidHash);
+ } else {
+ item.setStarred();
+ this._starredBusinessLayer.increaseCount();
+ return this._persistence.starItem(item.feedId, item.guidHash);
+ }
+ };
+
+ ItemBusinessLayer.prototype.setRead = function(itemId) {
+ var feed, item, keptUnread;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item)) {
+ keptUnread = angular.isDefined(item.keptUnread) && item.keptUnread;
+ if (!(item.isRead() || keptUnread)) {
+ item.setRead();
+ this._persistence.readItem(itemId);
+ feed = this._feedModel.getById(item.feedId);
+ if (angular.isDefined(feed)) {
+ return feed.unreadCount -= 1;
+ }
+ }
+ }
+ };
+
+ ItemBusinessLayer.prototype.setUnread = function(itemId) {
+ var feed, item;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item)) {
+ if (item.isRead()) {
+ item.setUnread();
+ this._persistence.unreadItem(itemId);
+ feed = this._feedModel.getById(item.feedId);
+ if (angular.isDefined(feed)) {
+ return feed.unreadCount += 1;
+ }
+ }
+ }
+ };
+
+ ItemBusinessLayer.prototype.getFeedTitle = function(itemId) {
+ var feed, item;
+ item = this._itemModel.getById(itemId);
+ if (angular.isDefined(item)) {
+ feed = this._feedModel.getById(item.feedId);
+ if (angular.isDefined(feed)) {
+ return feed.title;
+ }
+ }
+ };
+
+ ItemBusinessLayer.prototype.loadNext = function(callback) {
+ var lowestItemId;
+ lowestItemId = this._itemModel.getLowestId();
+ if (lowestItemId !== 0) {
+ return this._persistence.getItems(this._activeFeed.getType(), this._activeFeed.getId(), lowestItemId, callback);
+ } else {
+ return callback();
+ }
+ };
+
+ ItemBusinessLayer.prototype.loadNew = function() {};
+
+ return ItemBusinessLayer;
+
+ })();
+ return new ItemBusinessLayer(ItemModel, FeedModel, Persistence, ActiveFeed, FeedType, StarredBusinessLayer, NewestItem);
+ }
+ ]);
+
+}).call(this);
diff --git a/js/build/app/services/businesslayer/starredbusinesslayer.js b/js/build/app/services/businesslayer/starredbusinesslayer.js
new file mode 100644
index 000000000..9985aa24a
--- /dev/null
+++ b/js/build/app/services/businesslayer/starredbusinesslayer.js
@@ -0,0 +1,66 @@
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+(function() {
+ var __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ angular.module('News').factory('StarredBusinessLayer', [
+ '_BusinessLayer', 'StarredCount', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', function(_BusinessLayer, StarredCount, Persistence, ActiveFeed, FeedType, ItemModel) {
+ var StarredBusinessLayer;
+ StarredBusinessLayer = (function(_super) {
+ __extends(StarredBusinessLayer, _super);
+
+ function StarredBusinessLayer(_starredCount, feedType, persistence, activeFeed, itemModel) {
+ this._starredCount = _starredCount;
+ StarredBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Starred);
+ }
+
+ StarredBusinessLayer.prototype.isVisible = function() {
+ if (this.isActive(0)) {
+ return true;
+ } else {
+ return this._starredCount.getStarredCount() > 0;
+ }
+ };
+
+ StarredBusinessLayer.prototype.getUnreadCount = function() {
+ return this._starredCount.getStarredCount();
+ };
+
+ StarredBusinessLayer.prototype.increaseCount = function() {
+ return this._starredCount.setStarredCount(this._starredCount.getStarredCount() + 1);
+ };
+
+ StarredBusinessLayer.prototype.decreaseCount = function() {
+ return this._starredCount.setStarredCount(this._starredCount.getStarredCount() - 1);
+ };
+
+ return StarredBusinessLayer;
+
+ })(_BusinessLayer);
+ return new StarredBusinessLayer(StarredCount, FeedType, Persistence, ActiveFeed, ItemModel);
+ }
+ ]);
+
+}).call(this);
diff --git a/js/build/app/services/businesslayer/subscriptionsbusinesslayer.js b/js/build/app/services/businesslayer/subscriptionsbusinesslayer.js
new file mode 100644
index 000000000..45462ed24
--- /dev/null
+++ b/js/build/app/services/businesslayer/subscriptionsbusinesslayer.js
@@ -0,0 +1,84 @@
+// Generated by CoffeeScript 1.6.3
+/*
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+(function() {
+ var __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ angular.module('News').factory('SubscriptionsBusinessLayer', [
+ '_BusinessLayer', 'FeedBusinessLayer', 'Persistence', 'ShowAll', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', 'NewestItem', function(_BusinessLayer, FeedBusinessLayer, Persistence, ShowAll, ActiveFeed, FeedType, ItemModel, FeedModel, NewestItem) {
+ var SubscriptionsBusinessLayer;
+ SubscriptionsBusinessLayer = (function(_super) {
+ __extends(SubscriptionsBusinessLayer, _super);
+
+ function SubscriptionsBusinessLayer(_feedBusinessLayer, _showAll, feedType, persistence, activeFeed, itemModel, _feedModel, _newestItem) {
+ this._feedBusinessLayer = _feedBusinessLayer;
+ this._showAll = _showAll;
+ this._feedModel = _feedModel;
+ this._newestItem = _newestItem;
+ SubscriptionsBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, feedType.Subscriptions);
+ }
+
+ SubscriptionsBusinessLayer.prototype.isVisible = function() {
+ var visible;
+ if (this.isActive(0) && this._feedBusinessLayer.getNumberOfFeeds() > 0) {
+ return true;
+ }
+ if (this._showAll.getShowAll()) {
+ return this._feedBusinessLayer.getNumberOfFeeds() > 0;
+ } else {
+ visible = this._feedBusinessLayer.getNumberOfFeeds() > 0 && this._feedBusinessLayer.getAllUnreadCount() > 0;
+ return visible;
+ }
+ };
+
+ SubscriptionsBusinessLayer.prototype.markRead = function() {
+ var feed, item, newestItemId, _i, _j, _len, _len1, _ref, _ref1;
+ newestItemId = this._newestItem.getId();
+ if (newestItemId !== 0) {
+ _ref = this._feedModel.getAll();
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ feed = _ref[_i];
+ feed.unreadCount = 0;
+ }
+ _ref1 = this._itemModel.getAll();
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ item = _ref1[_j];
+ item.setRead();
+ }
+ return this._persistence.setAllRead(newestItemId);
+ }
+ };
+
+ SubscriptionsBusinessLayer.prototype.getUnreadCount = function() {
+ return this._feedBusinessLayer.getAllUnreadCount();
+ };
+
+ return SubscriptionsBusinessLayer;
+
+ })(_BusinessLayer);
+ return new SubscriptionsBusinessLayer(FeedBusinessLayer, ShowAll, FeedType, Persistence, ActiveFeed, ItemModel, FeedModel, NewestItem);
+ }
+ ]);
+
+}).call(this);