(function(angular, $, undefined){ /** * ownCloud News App - v0.0.1 * * Copyright (c) 2013 - Bernhard Posselt * * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file * */ // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News', ['OC', 'ui']).config(function($provide) { var config; return $provide.value('Config', config = { markReadTimeout: 500, scrollTimeout: 500, feedUpdateInterval: 6000000, itemBatchSize: 20 }); }); angular.module('News').run([ 'Persistence', function(Persistence) { return Persistence.init(); } ]); $(document).ready(function() { return $(this).keyup(function(e) { if ((e.which === 116) || (e.which === 82 && e.ctrlKey)) { document.location.reload(true); return false; } }); }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ /* Turns a normal select into a folder select with the ability to create new folders */ (function() { angular.module('News').directive('addFolderSelect', [ '$rootScope', function() { return function(scope, elm, attr) { var options; options = { singleSelect: true, selectedFirst: true, createText: $(elm).data('create'), createdCallback: function(selected, value) { console.log(selected); return console.log(value); } }; return $(elm).multiSelect(options); }; } ]); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').controller('SettingsController', [ '$scope', '_SettingsController', function($scope, _SettingsController) { return new _SettingsController($scope); } ]); angular.module('News').controller('FeedController', [ '$scope', '_FeedController', 'FolderModel', 'FeedModel', 'ActiveFeed', 'ShowAll', 'FeedType', 'StarredCount', 'Persistence', 'ItemModel', function($scope, _FeedController, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, ItemModel) { return new _FeedController($scope, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, ItemModel); } ]); angular.module('News').controller('ItemController', [ '$scope', '_ItemController', 'ItemModel', 'FeedLoading', function($scope, _ItemController, ItemModel, FeedLoading) { return new _ItemController($scope, ItemModel, FeedLoading); } ]); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('_FeedController', function() { var FeedController; FeedController = (function() { function FeedController($scope, _folderModel, _feedModel, _active, _showAll, _feedType, _starredCount, _persistence, _itemModel) { var _this = this; this.$scope = $scope; this._folderModel = _folderModel; this._feedModel = _feedModel; this._active = _active; this._showAll = _showAll; this._feedType = _feedType; this._starredCount = _starredCount; this._persistence = _persistence; this._itemModel = _itemModel; this._isAddingFolder = false; this._isAddingFeed = false; this.$scope.feeds = this._feedModel.getAll(); this.$scope.folders = this._folderModel.getAll(); this.$scope.feedType = this._feedType; this.$scope.isFeedActive = function(type, id) { return _this.isFeedActive(type, id); }; this.$scope.isShown = function(type, id) { return _this.isShown(type, id); }; this.$scope.getUnreadCount = function(type, id) { return _this.getUnreadCount(type, id); }; this.$scope.isShowAll = function() { return _this.isShowAll(); }; this.$scope.loadFeed = function(type, id) { return _this.loadFeed(type, id); }; this.$scope.hasFeeds = function(folderId) { return _this.hasFeeds(folderId); }; this.$scope["delete"] = function(type, id) { return _this["delete"](type, id); }; this.$scope.markAllRead = function(type, id) { return _this.markAllRead(type, id); }; this.$scope.getFeedsOfFolder = function(folderId) { return _this.getFeedsOfFolder(folderId); }; this.$scope.setShowAll = function(showAll) { return _this.setShowAll(showAll); }; this.$scope.isAddingFolder = function() { return _this._isAddingFolder; }; this.$scope.isAddingFeed = function() { return _this._isAddingFeed; }; this.$scope.toggleFolder = function(folderId) { return _this.toggleFolder(folderId); }; this.$scope.addFeed = function(feedUrl, parentFolderId) { var onError, onSuccess; if (parentFolderId == null) { parentFolderId = 0; } _this.$scope.feedEmptyError = false; _this.$scope.feedError = false; if (angular.isUndefined(feedUrl) || feedUrl.trim() === '') { _this.$scope.feedEmptyError = true; } if (!_this.$scope.feedEmptyError) { _this._isAddingFeed = true; onError = function() { _this.$scope.feedError = true; return _this._isAddingFeed = false; }; onSuccess = function(data) { if (data.status === 'error') { return onError(); } else { _this.$scope.feedUrl = ''; return _this._isAddingFeed = false; } }; return _this._persistence.createFeed(feedUrl.trim(), parentFolderId, onSuccess, onError); } }; this.$scope.addFolder = function(folderName) { var folder, _i, _len, _ref; _this.$scope.folderEmptyError = false; _this.$scope.folderExistsError = false; if (angular.isUndefined(folderName) || folderName.trim() === '') { _this.$scope.folderEmptyError = true; } else { folderName = folderName.trim(); _ref = _this._folderModel.getAll(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { folder = _ref[_i]; if (folderName.toLowerCase() === folder.name.toLowerCase()) { _this.$scope.folderExistsError = true; } } } if (!(_this.$scope.folderEmptyError || _this.$scope.folderExistsError)) { _this._isAddingFolder = true; return _this._persistence.createFolder(folderName, 0, function() { _this.$scope.folderName = ''; return _this._isAddingFolder = false; }); } }; } FeedController.prototype.toggleFolder = function(folderId) { var folder; folder = this._folderModel.getById(folderId); if (angular.isDefined(folder)) { folder.open = !folder.open; if (folder.open) { return this._persistence.openFolder(folder.id); } else { return this._persistence.collapseFolder(folder.id); } } }; FeedController.prototype.isFeedActive = function(type, id) { return type === this._active.getType() && (id = this._active.getId()); }; FeedController.prototype.isShown = function(type, id) { var hasUnread; hasUnread = this.getUnreadCount(type, id) > 0; if (hasUnread) { return true; } else { if (this.isShowAll()) { switch (type) { case this._feedType.Subscriptions: return this._feedModel.size() > 0; case this._feedType.Folder: return this._folderModel.size() > 0; case this._feedType.Feed: return this._feedModel.size() > 0; } } } return false; }; FeedController.prototype.isShowAll = function() { return this._showAll.getShowAll(); }; FeedController.prototype.getUnreadCount = function(type, id) { var count; switch (type) { case this._feedType.Subscriptions: count = this._feedModel.getUnreadCount(); break; case this._feedType.Starred: count = this._starredCount.getStarredCount(); break; case this._feedType.Feed: count = this._feedModel.getFeedUnreadCount(id); break; case this._feedType.Folder: count = this._feedModel.getFolderUnreadCount(id); } if (count > 999) { count = '999+'; } return count; }; FeedController.prototype.loadFeed = function(type, id) { var lastModified; if (type !== this._active.getType() || id !== this._active.getId()) { this._itemModel.clear(); this._persistence.getItems(type, id, 0); return this._active.handle({ id: id, type: type }); } else { lastModified = this._itemModel.getLastModified(); return this._persistence.getItems(type, id, 0, null, lastModified); } }; FeedController.prototype.hasFeeds = function(folderId) { return this._feedModel.getAllOfFolder(folderId).length; }; FeedController.prototype["delete"] = function(type, id) { var count; switch (type) { case this._feedType.Feed: count = this._feedModel.removeById(id); return this._persistence.deleteFeed(id); case this._feedType.Folder: count = this._folderModel.removeById(id); return this._persistence.deleteFolder(id); } }; FeedController.prototype.markAllRead = function(type, id) { var feed, highestItemId, _i, _j, _len, _len1, _ref, _ref1, _results, _results1; switch (type) { case this._feedType.Subscriptions: _ref = this._feedModel.getAll(); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { feed = _ref[_i]; _results.push(this.markAllRead(this._feedType.Feed, feed.id)); } return _results; break; case this._feedType.Feed: feed = this._feedModel.getById(id); if (angular.isDefined(feed)) { feed.unreadCount = 0; highestItemId = this._itemModel.getHighestId(); return this._persistence.setFeedRead(id, highestItemId); } break; case this._feedType.Folder: _ref1 = this._feedModel.getAllOfFolder(id); _results1 = []; for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { feed = _ref1[_j]; _results1.push(this.markAllRead(this._feedType.Feed, feed.id)); } return _results1; } }; FeedController.prototype.getFeedsOfFolder = function(folderId) { return this._feedModel.getAllOfFolder(folderId); }; FeedController.prototype.setShowAll = function(showAll) { this._showAll.setShowAll(showAll); if (showAll) { return this._persistence.userSettingsReadShow(); } else { return this._persistence.userSettingsReadHide(); } }; return FeedController; })(); return FeedController; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('_ItemController', function() { var ItemController; ItemController = (function() { function ItemController($scope, itemModel, feedLoading) { var _this = this; this.$scope = $scope; this.itemModel = itemModel; this.feedLoading = feedLoading; this.$scope.isLoading = function() { return _this.feedLoading.isLoading(); }; } return ItemController; })(); return ItemController; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('_SettingsController', function() { var SettingsController; SettingsController = (function() { function SettingsController($scope) { this.$scope = $scope; } return SettingsController; })(); return SettingsController; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('_ActiveFeed', function() { var ActiveFeed; ActiveFeed = (function() { function ActiveFeed() { /* Default value is all feeds */ this._id = 0; this._type = 3; } ActiveFeed.prototype.handle = function(data) { this._id = data.id; return this._type = data.type; }; ActiveFeed.prototype.getType = function() { return this._type; }; ActiveFeed.prototype.getId = function() { return this._id; }; return ActiveFeed; })(); return ActiveFeed; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('FeedType', function() { var feedType; return feedType = { Feed: 0, Folder: 1, Starred: 2, Subscriptions: 3, Shared: 4 }; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (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('_FeedModel', [ '_Model', '_EqualQuery', function(_Model, _EqualQuery) { var FeedModel; FeedModel = (function(_super) { __extends(FeedModel, _super); function FeedModel(_utils) { this._utils = _utils; FeedModel.__super__.constructor.call(this); } FeedModel.prototype.add = function(item) { if (item.faviconLink === null) { item.faviconLink = 'url(' + this._utils.imagePath('news', 'rss.svg') + ')'; } return FeedModel.__super__.add.call(this, item); }; FeedModel.prototype.getUnreadCount = function() { var count, feed, _i, _len, _ref; count = 0; _ref = this.getAll(); for (_i = 0, _len = _ref.length; _i < _len; _i++) { feed = _ref[_i]; count += feed.unreadCount; } return count; }; FeedModel.prototype.getFeedUnreadCount = function(feedId) { var count, feed; feed = this.getById(feedId); count = 0; if (angular.isDefined(feed)) { return count += feed.unreadCount; } else { return 0; } }; FeedModel.prototype.getFolderUnreadCount = function(folderId) { var count, feed, query, _i, _len, _ref; query = new _EqualQuery('folderId', folderId); count = 0; _ref = this.get(query); for (_i = 0, _len = _ref.length; _i < _len; _i++) { feed = _ref[_i]; count += feed.unreadCount; } return count; }; FeedModel.prototype.getAllOfFolder = function(folderId) { var query; query = new _EqualQuery('folderId', folderId); return this.get(query); }; return FeedModel; })(_Model); return FeedModel; } ]); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (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('_FolderModel', [ '_Model', function(_Model) { var FolderModel; FolderModel = (function(_super) { __extends(FolderModel, _super); function FolderModel() { return FolderModel.__super__.constructor.apply(this, arguments); } return FolderModel; })(_Model); return FolderModel; } ]); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (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('_ItemModel', [ '_Model', '_MaximumQuery', '_MinimumQuery', function(_Model, _MaximumQuery, _MinimumQuery) { var ItemModel; ItemModel = (function(_super) { __extends(ItemModel, _super); function ItemModel() { return ItemModel.__super__.constructor.apply(this, arguments); } ItemModel.prototype.getLastModified = function() { var lastModified, query; query = new _MaximumQuery('lastModified'); lastModified = this.get(query); if (angular.isDefined(lastModified)) { return lastModified.lastModified; } else { return null; } }; ItemModel.prototype.getHighestId = function() { var highestId, query; query = new _MaximumQuery('id'); highestId = this.get(query); if (angular.isDefined(highestId)) { return highestId.id; } else { return 0; } }; return ItemModel; })(_Model); return ItemModel; } ]); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('_OPMLParser', function() { var Feed, Folder, OPMLParser; Feed = (function() { function Feed(_name, _url) { this._name = _name; this._url = _url; } Feed.prototype.getName = function() { return this._name; }; Feed.prototype.getUrl = function() { return this._url; }; Feed.prototype.isFolder = function() { return false; }; return Feed; })(); Folder = (function() { function Folder(_name) { this._name = _name; this._items = []; } Folder.prototype.add = function(feed) { return this._items.push(feed); }; Folder.prototype.getItems = function() { return this._items; }; Folder.prototype.getName = function() { return this._name; }; Folder.prototype.isFolder = function() { return true; }; return Folder; })(); OPMLParser = (function() { function OPMLParser() {} OPMLParser.prototype.parseXML = function(xml) { var $root, $xml, structure; $xml = $($.parseXML(xml)); $root = $xml.find('body'); structure = new Folder('root'); this._recursivelyParse($root, structure); return structure; }; OPMLParser.prototype._recursivelyParse = function($xml, structure) { var $outline, feed, folder, outline, _i, _len, _ref, _results; _ref = $xml.children('outline'); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { outline = _ref[_i]; $outline = $(outline); if (angular.isDefined($outline.attr('type'))) { feed = new Feed($outline.attr('text'), $outline.attr('xmlUrl')); _results.push(structure.add(feed)); } else { folder = new Folder($outline.attr('text')); structure.add(folder); _results.push(this._recursivelyParse($outline, folder)); } } return _results; }; return OPMLParser; })(); return OPMLParser; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('_Persistence', function() { var Persistence; Persistence = (function() { function Persistence(_request, _loading, _config, _activeFeed, _$rootScope) { this._request = _request; this._loading = _loading; this._config = _config; this._activeFeed = _activeFeed; this._$rootScope = _$rootScope; } Persistence.prototype.init = function() { /* Loads the initial data from the server */ var triggerHideRead, _this = this; this._loading.increase(); this.getActiveFeed(function() { return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId(), 0, function() { return _this._loading.decrease(); }); }); triggerHideRead = function() { return _this._triggerHideRead; }; this.getAllFolders(triggerHideRead); this.getAllFeeds(triggerHideRead); this.userSettingsRead(triggerHideRead); return this.getStarredItems(triggerHideRead); }; /* ITEM CONTROLLER */ Persistence.prototype.getItems = function(type, id, offset, onSuccess, updatedSince) { var data, params; if (onSuccess == null) { onSuccess = null; } if (updatedSince == null) { updatedSince = null; } onSuccess || (onSuccess = function() {}); if (updatedSince !== null) { data = { updatedSince: updatedSince, type: type, id: id }; } else { data = { limit: this._config.itemBatchSize, offset: offset, id: id, type: type }; } params = { data: data, onSuccess: onSuccess }; return this._request.get('news_items', params); }; Persistence.prototype.getStarredItems = function(onSuccess) { var params; params = { onSuccess: onSuccess }; return this._request.get('news_items_starred', params); }; Persistence.prototype.starItem = function(itemId) { /* Stars an item */ var params; params = { urlParams: { itemId: itemId } }; return this._request.post('news_items_star', params); }; Persistence.prototype.unstarItem = function(itemId) { /* Unstars an item */ var params; params = { urlParams: { itemId: itemId } }; return this._request.post('news_items_unstar', params); }; Persistence.prototype.readItem = function(itemId) { /* Sets an item as read */ var params; params = { urlParams: { itemId: itemId } }; return this._request.post('news_items_read', params); }; Persistence.prototype.unreadItem = function(itemId) { /* Sets an item as unread */ var params; params = { urlParams: { itemId: itemId } }; return this._request.post('news_items_unread', params); }; /* FEED CONTROLLER */ Persistence.prototype.getAllFeeds = function(callback) { var params; callback || (callback = function() {}); params = { onSuccess: callback }; return this._request.get('news_feeds', params); }; Persistence.prototype.getActiveFeed = function(onSuccess) { var params; params = { onSuccess: onSuccess }; return this._request.get('news_feeds_active', params); }; Persistence.prototype.createFeed = function(url, parentFolderId, onSuccess, onFailure) { var params; if (onSuccess == null) { onSuccess = null; } if (onFailure == null) { onFailure = null; } onSuccess || (onSuccess = function() {}); onFailure || (onFailure = function() {}); params = { data: { parentFolderId: parentFolderId, url: url }, onSuccess: onSuccess, onFailure: onFailure }; return this._request.post('news_feeds_create', params); }; Persistence.prototype.deleteFeed = function(feedId) { var params; params = { urlParams: { feedId: feedId } }; return this._request.post('news_feeds_delete', params); }; Persistence.prototype.moveFeed = function(feedId, folderId) { /* moves a feed to a new folder */ var params; params = { urlParams: { feedId: feedId }, data: { folderId: folderId } }; return this._request.post('news_feeds_move', params); }; Persistence.prototype.setFeedRead = function(feedId, highestItemId) { /* sets all items of a feed as read */ var params; params = { urlParams: { feedId: feedId }, data: { highestItemId: highestItemId } }; return this._request.post('news_feeds_read', params); }; Persistence.prototype.updateFeed = function(feedId) { /* moves a feed to a new folder */ var params; params = { urlParams: { feedId: feedId } }; return this._request.post('news_feeds_update', params); }; /* FOLDER CONTROLLER */ Persistence.prototype.getAllFolders = function(callback) { var params; callback || (callback = function() {}); params = { onSuccess: callback }; return this._request.get('news_folders', params); }; Persistence.prototype.openFolder = function(folderId) { /* Save if a folder was opened */ var params; params = { urlParams: { folderId: folderId } }; return this._request.post('news_folders_open', params); }; Persistence.prototype.collapseFolder = function(folderId) { /* Save if a folder was collapsed */ var params; params = { urlParams: { folderId: folderId } }; return this._request.post('news_folders_collapse', params); }; Persistence.prototype.createFolder = function(folderName, parentFolderId, onSuccess, onFailure) { var params; if (parentFolderId == null) { parentFolderId = 0; } if (onSuccess == null) { onSuccess = null; } if (onFailure == null) { onFailure = null; } onSuccess || (onSuccess = function() {}); onFailure || (onFailure = function() {}); params = { data: { folderName: folderName, parentFolderId: parentFolderId }, onSuccess: onSuccess, onFailure: onFailure }; return this._request.post('news_folders_create', params); }; Persistence.prototype.deleteFolder = function(folderId) { /* Save if a folder was collapsed */ var params; params = { urlParams: { folderId: folderId } }; return this._request.post('news_folders_delete', params); }; Persistence.prototype.renameFolder = function(folderId, folderName) { /* Save if a folder was collapsed */ var params; params = { urlParams: { folderId: folderId }, data: { folderName: folderName } }; return this._request.post('news_folders_rename', params); }; /* EXPORT CONTROLLER */ Persistence.prototype.exportOPML = function() { /* Prompts for an OPML download */ return this._request.get('news_export_opml'); }; /* USERSETTINGS CONTROLLER */ Persistence.prototype.userSettingsRead = function(callback) { var params; if (callback == null) { callback = null; } /* Gets the configs for read settings */ callback || (callback = function() {}); params = { onSuccess: callback }; return this._request.get('news_usersettings_read', params); }; Persistence.prototype.userSettingsReadShow = function() { /* Sets the reader mode to show all */ return this._request.post('news_usersettings_read_show'); }; Persistence.prototype.userSettingsReadHide = function() { /* Sets the reader mode to show only unread */ return this._request.post('news_usersettings_read_hide'); }; Persistence.prototype._triggerHideRead = function() { return this._$rootScope.$broadcast('triggerHideRead'); }; return Persistence; })(); return Persistence; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('Persistence', [ '_Persistence', 'Request', 'FeedLoading', 'Config', 'ActiveFeed', '$rootScope', function(_Persistence, Request, FeedLoading, Config, ActiveFeed, $rootScope) { return new _Persistence(Request, FeedLoading, Config, ActiveFeed, $rootScope); } ]); angular.module('News').factory('Request', [ '_Request', '$http', 'Publisher', 'Router', function(_Request, $http, Publisher, Router) { return new _Request($http, Publisher, Router); } ]); angular.module('News').factory('FeedLoading', [ '_Loading', function(_Loading) { return new _Loading(); } ]); angular.module('News').factory('ActiveFeed', [ '_ActiveFeed', function(_ActiveFeed) { return new _ActiveFeed(); } ]); angular.module('News').factory('ShowAll', [ '_ShowAll', function(_ShowAll) { return new _ShowAll(); } ]); angular.module('News').factory('StarredCount', [ '_StarredCount', function(_StarredCount) { return new _StarredCount(); } ]); angular.module('News').factory('FeedModel', [ '_FeedModel', 'Utils', function(_FeedModel, Utils) { return new _FeedModel(Utils); } ]); angular.module('News').factory('FolderModel', [ '_FolderModel', function(_FolderModel) { return new _FolderModel(); } ]); angular.module('News').factory('ItemModel', [ '_ItemModel', function(_ItemModel) { return new _ItemModel(); } ]); angular.module('News').factory('Publisher', [ '_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel', 'FolderModel', 'FeedModel', function(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel, FolderModel, FeedModel) { var publisher; publisher = new _Publisher(); publisher.subscribeObjectTo(ActiveFeed, 'activeFeed'); publisher.subscribeObjectTo(ShowAll, 'showAll'); publisher.subscribeObjectTo(StarredCount, 'starred'); publisher.subscribeObjectTo(FolderModel, 'folders'); publisher.subscribeObjectTo(FeedModel, 'feeds'); publisher.subscribeObjectTo(ItemModel, 'items'); return publisher; } ]); angular.module('News').factory('OPMLParser', [ '_OPMLParser', function(_OPMLParser) { return new _OPMLParser(); } ]); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('_ShowAll', function() { var ShowAll; ShowAll = (function() { function ShowAll() { this._showAll = false; } ShowAll.prototype.handle = function(data) { return this._showAll = data; }; ShowAll.prototype.getShowAll = function() { return this._showAll; }; ShowAll.prototype.setShowAll = function(showAll) { return this._showAll = showAll; }; return ShowAll; })(); return ShowAll; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt nukeawhale@gmail.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 . */ (function() { angular.module('News').factory('_StarredCount', function() { var StarredCount; StarredCount = (function() { function StarredCount() { this._count = 0; } StarredCount.prototype.handle = function(data) { return this._count = data; }; StarredCount.prototype.setStarredCount = function(count) { return this._count = count; }; StarredCount.prototype.getStarredCount = function() { return this._count; }; return StarredCount; })(); return StarredCount; }); }).call(this); })(window.angular, jQuery);