diff options
Diffstat (limited to 'js/app/services')
38 files changed, 0 insertions, 3092 deletions
diff --git a/js/app/services/activefeed.coffee b/js/app/services/activefeed.coffee deleted file mode 100644 index ff469e138..000000000 --- a/js/app/services/activefeed.coffee +++ /dev/null @@ -1,48 +0,0 @@ -### - -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/>. - -### - -angular.module('News').factory 'ActiveFeed', -> - - class ActiveFeed - - constructor: -> - ### - Default value is all feeds - ### - @_id = 0 - @_type = 3 - - - handle: (data) -> - @_id = data.id - @_type = data.type - - - getType: -> - return @_type - - - getId: -> - return @_id - - - return new ActiveFeed() diff --git a/js/app/services/businesslayer/businesslayer.coffee b/js/app/services/businesslayer/businesslayer.coffee deleted file mode 100644 index 14d692084..000000000 --- a/js/app/services/businesslayer/businesslayer.coffee +++ /dev/null @@ -1,44 +0,0 @@ -### - -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/>. - -### - - -angular.module('News').factory '_BusinessLayer', -> - - class BusinessLayer - - constructor: (@_activeFeed, @_persistence, @_itemModel, @_type, - @_$rootScope) -> - - - load: (id) -> - @_$rootScope.$broadcast 'loadingNewItems' - @_itemModel.clear() - @_persistence.getItems @_type, id, 0, => - @_$rootScope.$broadcast 'loadedNewItems' - @_activeFeed.handle({id: id, type: @_type}) - - - isActive: (id) -> - return @_activeFeed.getType() == @_type && @_activeFeed.getId() == id - - - return BusinessLayer
\ No newline at end of file diff --git a/js/app/services/businesslayer/feedbusinesslayer.coffee b/js/app/services/businesslayer/feedbusinesslayer.coffee deleted file mode 100644 index c82b7de87..000000000 --- a/js/app/services/businesslayer/feedbusinesslayer.coffee +++ /dev/null @@ -1,194 +0,0 @@ -### - -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/>. - -### - - -angular.module('News').factory 'FeedBusinessLayer', -['_BusinessLayer', 'Settings', 'Persistence', 'ActiveFeed', 'FeedType', -'ItemModel', 'FeedModel', 'NewLoading', '_ExistsError', 'Utils', '$rootScope', -'NewestItem', -(_BusinessLayer, Settings, Persistence, ActiveFeed, FeedType, ItemModel, -FeedModel, NewLoading, _ExistsError, Utils, $rootScope, NewestItem)-> - - class FeedBusinessLayer extends _BusinessLayer - - constructor: (@_settings, @_feedModel, persistence, activeFeed, feedType, - itemModel, @_newLoading, @_utils, $rootScope, - @_newestItem) -> - super(activeFeed, persistence, itemModel, feedType.Feed, $rootScope) - @_feedType = feedType - - - getUnreadCount: (feedId) -> - @_feedModel.getFeedUnreadCount(feedId) - - - getFeedsOfFolder: (folderId) -> - return @_feedModel.getAllOfFolder(folderId) - - - getFolderUnreadCount: (folderId) -> - @_feedModel.getFolderUnreadCount(folderId) - - - getAllUnreadCount: -> - return @_feedModel.getUnreadCount() - - - delete: (feedId) -> - feed = @_feedModel.removeById(feedId) - - data = - undoCallback: => - @_persistence.restoreFeed feedId, => - @_persistence.getAllFeeds() - caption: feed.title - - @_$rootScope.$broadcast 'undoMessage', data - @_persistence.deleteFeed(feedId) - - - renameFeed: (feedId, feedTitle) -> - feed = @_feedModel.getById(feedId) - feed.editing = false - - if angular.isDefined(feed) and feedTitle != "" - @_persistence.renameFeed(feedId, feedTitle) - - - markRead: (feedId) -> - feed = @_feedModel.getById(feedId) - newestItemId = @_newestItem.getId() - - if angular.isDefined(feed) and newestItemId != 0 - feed.unreadCount = 0 - for item in @_itemModel.getAll() - if item.feedId == feed.id - item.setRead() - @_persistence.setFeedRead(feedId, newestItemId) - - - getNumberOfFeeds: -> - return @_feedModel.size() - - noFeeds: -> - return @getNumberOfFeeds() == 0 - - - isVisible: (feedId) -> - if @isActive(feedId) or @_settings.get('showAll') - return true - else - return @_feedModel.getFeedUnreadCount(feedId) > 0 - - - move: (feedId, folderId) -> - feed = @_feedModel.getById(feedId) - if angular.isDefined(feed) and feed.folderId != folderId - @_feedModel.update({ - id: feedId, - folderId: folderId, - url: feed.url}) - @_persistence.moveFeed(feedId, folderId) - - - setShowAll: (showAll) -> - @_settings.set('showAll', showAll) - - # TODO: this callback is not tested with a unittest - callback = => - @_itemModel.clear() - @_newLoading.increase() - @_persistence.getItems( - @_activeFeed.getType(), - @_activeFeed.getId(), - 0, - => - @_newLoading.decrease() - ) - - @_persistence.setSettings(@_settings.getSettings(), callback) - - - isShowAll: -> - return @_settings.get('showAll') - - - getAll: -> - return @_feedModel.getAll() - - - getFeedLink: (feedId) -> - feed = @_feedModel.getById(feedId) - if angular.isDefined(feed) - return feed.link - - - create: (url, parentId=0, onSuccess=null, onFailure=null) -> - onSuccess or= -> - onFailure or= -> - parentId = parseInt(parentId, 10) - - if angular.isUndefined(url) or url.trim() == '' - throw new Error('Url must not be empty') - - url = url.trim() - if url.indexOf('http') != 0 - url = 'http://' + url - - if @_feedModel.getByUrl(url) - throw new _ExistsError('Exists already') - - feed = - title: url - url: url - folderId: parentId - unreadCount: 0 - faviconLink: 'url('+@_utils.imagePath('core', 'loading.gif')+')' - - @_feedModel.add(feed) - - success = (response) -> - onSuccess(response) - - failure = (response) -> - feed.error = response.message - onFailure() - - @_persistence.createFeed(url, parentId, success, failure) - - - markErrorRead: (url) -> - @_feedModel.removeByUrl(url) - - - importArticles: (json, callback) -> - onSuccess = (response) -> - callback() - - @_persistence.importArticles(json, onSuccess) - - - return new FeedBusinessLayer(Settings, FeedModel, Persistence, ActiveFeed, - FeedType, ItemModel, NewLoading, Utils, - $rootScope, NewestItem) - -]
\ No newline at end of file diff --git a/js/app/services/businesslayer/folderbusinesslayer.coffee b/js/app/services/businesslayer/folderbusinesslayer.coffee deleted file mode 100644 index df2f80dd4..000000000 --- a/js/app/services/businesslayer/folderbusinesslayer.coffee +++ /dev/null @@ -1,208 +0,0 @@ -### - -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/>. - -### - - -angular.module('News').factory 'FolderBusinessLayer', -['_BusinessLayer', 'FolderModel', 'FeedBusinessLayer', 'Persistence', -'FeedType', 'ActiveFeed', 'ItemModel', 'Settings', '_ExistsError', 'OPMLParser', -'NewestItem', 'FeedModel', '$rootScope', -(_BusinessLayer, FolderModel, FeedBusinessLayer, Persistence, FeedType, -ActiveFeed, ItemModel, Settings, _ExistsError, OPMLParser, NewestItem, -FeedModel, $rootScope) -> - - class FolderBusinessLayer extends _BusinessLayer - - constructor: (@_folderModel, @_feedBusinessLayer, @_settings, activeFeed, - persistence, @_feedType, itemModel, @_opmlParser, - @_newestItem, @_feedModel, $rootScope) -> - super(activeFeed, persistence, itemModel, @_feedType.Folder, $rootScope) - - - getById: (folderId) -> - return @_folderModel.getById(folderId) - - - delete: (folderId) -> - feeds = [] - # also delete feeds - for feed in @_feedBusinessLayer.getFeedsOfFolder(folderId) - feeds.push(@_feedModel.removeById(feed.id)) - - folder = @_folderModel.removeById(folderId) - - data = - undoCallback: => - @_persistence.restoreFolder folderId, => - @_persistence.getAllFeeds() - @_persistence.getAllFolders() - caption: folder.name - - @_$rootScope.$broadcast 'undoMessage', data - @_persistence.deleteFolder(folderId) - - - - hasFeeds: (folderId) -> - return @_feedBusinessLayer.getFeedsOfFolder(folderId).length - - - open: (folderId) -> - folder = @_folderModel.getById(folderId) - if angular.isDefined(folder) - if not folder.opened - folder.opened = true - @_persistence.openFolder(folder.id) - - - toggleFolder: (folderId) -> - folder = @_folderModel.getById(folderId) - - if angular.isDefined(folder) - folder.opened = !folder.opened - if folder.opened - @_persistence.openFolder(folder.id) - else - @_persistence.collapseFolder(folder.id) - - - markRead: (folderId) -> - newestItemId = @_newestItem.getId() - folder = @_folderModel.getById(folderId) - - if newestItemId != 0 and angular.isDefined(folder) - for feed in @_feedBusinessLayer.getFeedsOfFolder(folderId) - feed.unreadCount = 0 - - # also set items in feeds as read - for item in @_itemModel.getAll() - if item.feedId == feed.id - item.setRead() - - @_persistence.setFolderRead(folderId, newestItemId) - - - getUnreadCount: (folderId) -> - return @_feedBusinessLayer.getFolderUnreadCount(folderId) - - - isVisible: (folderId) -> - if @_settings.get('showAll') || - @_feedBusinessLayer.getFeedsOfFolder(folderId).length == 0 - return true - else - if @isActive(folderId) or - @_feedBusinessLayer.getFolderUnreadCount(folderId) > 0 - return true - if @_activeFeed.getType() == @_feedType.Feed - for feed in @_feedBusinessLayer.getFeedsOfFolder(folderId) - if feed.id == @_activeFeed.getId() - return true - return false - - - getAll: -> - return @_folderModel.getAll() - - - create: (folderName, onSuccess=null, onFailure=null) -> - onSuccess or= -> - onFailure or= -> - - if angular.isUndefined(folderName) or folderName.trim() == '' - throw new Error('Folder name must not be empty') - - folderName = folderName.trim() - - if @_folderModel.getByName(folderName) - throw new _ExistsError('Exists already') - - folder = - name: folderName - opened: true - - @_folderModel.add(folder) - - success = (response) -> - onSuccess(response) - - failure = (response) -> - folder.error = response.message - onFailure() - - @_persistence.createFolder folderName, 0, success, failure - - - markErrorRead: (folderName) -> - @_folderModel.removeByName(folderName) - - - edit: (folderId) -> - folder = @_folderModel.getById(folderId) - folder.editing = true - folder.originalValue = folder.name - - - rename: (folderId, folderName) -> - folder = @_folderModel.getById(folderId) - folder.editing = false - @_persistence.renameFolder(folderId, folderName) - - - cancel: (folderId) -> - folder = @_folderModel.getById(folderId) - folder.editing = false - folder.name = folder.originalValue - - - import: (xml) -> - opml = @_opmlParser.parseXML(xml) - @_importElement(opml, 0) - - - _importElement: (opml, parentFolderId) -> - for item in opml.getItems() - do (item) => - if item.isFolder() - try - @create item.getName(), (data) => - @_importElement(item, data.folders[0].id) - catch error - if error instanceof _ExistsError - folder = @_folderModel.getByName(item.getName()) - @open(folder.id) - @_importElement(item, folder.id) - else - console.info error - else - try - @_feedBusinessLayer.create(item.getUrl(), - parentFolderId) - catch error - if not error instanceof _ExistsError - console.info error - - - return new FolderBusinessLayer(FolderModel, FeedBusinessLayer, Settings, - ActiveFeed, Persistence, FeedType, ItemModel, - OPMLParser, NewestItem, FeedModel, $rootScope) - -] diff --git a/js/app/services/businesslayer/itembusinesslayer.coffee b/js/app/services/businesslayer/itembusinesslayer.coffee deleted file mode 100644 index 1382df190..000000000 --- a/js/app/services/businesslayer/itembusinesslayer.coffee +++ /dev/null @@ -1,131 +0,0 @@ -### - -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/>. - -### - - -angular.module('News').factory 'ItemBusinessLayer', -['ItemModel', 'FeedModel', 'Persistence', 'ActiveFeed', 'FeedType', -'StarredBusinessLayer', 'NewestItem', -(ItemModel, FeedModel, Persistence, ActiveFeed, FeedType, -StarredBusinessLayer, NewestItem) -> - - class ItemBusinessLayer - - constructor: (@_itemModel, @_feedModel, @_persistence, @_activeFeed, - @_feedType, @_starredBusinessLayer, @_newestItem) -> - - getAll: -> - return @_itemModel.getAll() - - - noFeedActive: -> - return @_activeFeed.getType() != @_feedType.Feed - - - isKeptUnread: (itemId) -> - item = @_itemModel.getById(itemId) - if angular.isDefined(item) and angular.isDefined(item.keptUnread) - return item.keptUnread - return false - - - toggleKeepUnread: (itemId) -> - item = @_itemModel.getById(itemId) - if angular.isDefined(item) and not item.keptUnread - item.keptUnread = true - if item.isRead() - @setUnread(itemId) - else - item.keptUnread = false - - - toggleStarred: (itemId) -> - item = @_itemModel.getById(itemId) - if item.isStarred() - item.setUnstarred() - @_starredBusinessLayer.decreaseCount() - @_persistence.unstarItem(item.feedId, item.guidHash) - else - item.setStarred() - @_starredBusinessLayer.increaseCount() - @_persistence.starItem(item.feedId, item.guidHash) - - - setRead: (itemId) -> - item = @_itemModel.getById(itemId) - if angular.isDefined(item) - - keptUnread = angular.isDefined(item.keptUnread) and - item.keptUnread - - if not (item.isRead() or keptUnread) - item.setRead() - @_persistence.readItem(itemId) - - feed = @_feedModel.getById(item.feedId) - if angular.isDefined(feed) - feed.unreadCount -= 1 - - - setUnread: (itemId) -> - item = @_itemModel.getById(itemId) - if angular.isDefined(item) - if item.isRead() - item.setUnread() - @_persistence.unreadItem(itemId) - - feed = @_feedModel.getById(item.feedId) - if angular.isDefined(feed) - feed.unreadCount += 1 - - - getFeedTitle: (itemId) -> - item = @_itemModel.getById(itemId) - if angular.isDefined(item) - feed = @_feedModel.getById(item.feedId) - if angular.isDefined(feed) - return feed.title - - - loadNext: (callback) -> - lowestItemId = @_itemModel.getLowestId() - if lowestItemId != 0 - @_persistence.getItems @_activeFeed.getType(), - @_activeFeed.getId(), - lowestItemId, - callback - else - callback() - - - loadNew: (onSuccess) -> - lastModified = @_itemModel.getLastModified() - @_persistence.getNewItems(@_activeFeed.getType(), - @_activeFeed.getId(), - lastModified, - onSuccess) - - - - return new ItemBusinessLayer(ItemModel, FeedModel, Persistence, ActiveFeed, - FeedType, StarredBusinessLayer, NewestItem) - -]
\ No newline at end of file diff --git a/js/app/services/businesslayer/starredbusinesslayer.coffee b/js/app/services/businesslayer/starredbusinesslayer.coffee deleted file mode 100644 index 50ef0f37f..000000000 --- a/js/app/services/businesslayer/starredbusinesslayer.coffee +++ /dev/null @@ -1,56 +0,0 @@ -### - -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/>. - -### - - -angular.module('News').factory 'StarredBusinessLayer', -['_BusinessLayer', 'StarredCount', 'Persistence', 'ActiveFeed', 'FeedType', -'ItemModel', '$rootScope', -(_BusinessLayer, StarredCount, Persistence, ActiveFeed, FeedType, ItemModel, -$rootScope) -> - - class StarredBusinessLayer extends _BusinessLayer - - constructor: (@_starredCount, feedType, - persistence, activeFeed, itemModel, $rootScope) -> - super(activeFeed, persistence, itemModel, feedType.Starred, $rootScope) - - isVisible: -> - if @isActive(0) - return true - else - return @_starredCount.getStarredCount() > 0 - - - getUnreadCount: -> - return @_starredCount.getStarredCount() - - - increaseCount: -> - @_starredCount.setStarredCount(@_starredCount.getStarredCount() + 1) - - - decreaseCount: -> - @_starredCount.setStarredCount(@_starredCount.getStarredCount() - 1) - - return new StarredBusinessLayer(StarredCount, Fe |