(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 . */ (function() { angular.module('News').directive('clickFocus', function() { return function(scope, elm, attr) { var options; options = scope.$eval(attr.clickFocus); if (angular.isDefined(options) && angular.isDefined(options.selector)) { return elm.click(function() { return $(options.selector).focus(); }); } }; }); }).call(this); // Generated by CoffeeScript 1.4.0 /* ownCloud - App Framework @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('OC').directive('focusFirstInput', function() { return function(scope, elm, attr) { return elm.find('input:first').focus(); }; }); }).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', 'FolderBl', 'FeedBl', function($scope, _FeedController, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, FolderBl, FeedBl) { return new _FeedController($scope, FolderModel, FeedModel, ActiveFeed, ShowAll, FeedType, StarredCount, Persistence, FolderBl, FeedBl); } ]); angular.module('News').controller('ItemController', [ '$scope', '_ItemController', 'ItemModel', 'FeedModel', 'FeedLoading', function($scope, _ItemController, ItemModel, FeedModel, FeedLoading) { return new _ItemController($scope, ItemModel, FeedModel, 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, _folderBl, _feedBl) { 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._folderBl = _folderBl; this._feedBl = _feedBl; 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.folderBl = this._folderBl; this.$scope.feedBl = this._feedBl; this.$scope.isShown = function(type, id) { return true; }; this.$scope.getUnreadCount = function() { return _this._transFormCount(_this._feedBl.getUnreadCount()); }; this.$scope.getStarredCount = function() { return _this._transFormCount(_this._starredCount.getStarredCount()); }; this.$scope.getFeedUnreadCount = function(feedId) { return _this._transFormCount(_this._feedBl.getFeedUnreadCount(feedId)); }; this.$scope.getUnreadCount = function(folderId) { return _this._transFormCount(_this._feedBl.getFolderUnreadCount(folderId)); }; 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) { _this.$scope.folderEmptyError = false; _this.$scope.folderExistsError = false; if (angular.isUndefined(folderName) || folderName.trim() === '') { _this.$scope.folderEmptyError = true; } else { folderName = folderName.trim(); if (_this._folderModel.nameExists(folderName)) { _this.$scope.folderExistsError = true; } } if (!(_this.$scope.folderEmptyError || _this.$scope.folderExistsError)) { _this._isAddingFolder = true; return _this._persistence.createFolder(folderName, 0, function() { _this.$scope.folderName = ''; _this.$scope.addNewFolder = false; return _this._isAddingFolder = false; }); } }; } FeedController.prototype.isFeedActive = function(type, id) { return type === this._active.getType() && id === this._active.getId(); }; FeedController.prototype.isShowAll = function() { return this._showAll.getShowAll(); }; FeedController.prototype._transFormCount = function(count) { 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.getHighestId(); return this._persistence.getItems(type, id, 0, null, lastModified); } }; 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, _feedModel, _feedLoading) { var _this = this; this._$scope = _$scope; this._itemModel = _itemModel; this._feedModel = _feedModel; this._feedLoading = _feedLoading; this._$scope.items = this._itemModel.getAll(); this._$scope.isLoading = function() { return _this._feedLoading.isLoading(); }; this._$scope.getFeedTitle = function(feedId) { var feed; feed = _this._feedModel.getById(feedId); if (angular.isDefined(feed)) { return feed.title; } else { return ''; } }; } 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) { var _this = this; this.$scope = $scope; this.$scope["import"] = function(fileContent) { console.log('hi'); return console.log(fileContent); }; } 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('_FeedBl', function() { var FeedBl; FeedBl = (function() { function FeedBl(_feedModel, _itemBl, _persistence) { this._feedModel = _feedModel; this._itemBl = _itemBl; this._persistence = _persistence; } FeedBl.prototype.getFeedUnreadCount = function(feedId) { return this._feedModel.getFeedUnreadCount(feedId); }; FeedBl.prototype.getFeedsOfFolder = function(folderId) { return this._feedModel.getAllOfFolder(folderId); }; FeedBl.prototype.getFolderUnreadCount = function(folderId) { return this._feedModel.getFolderUnreadCount(folderId); }; FeedBl.prototype.getUnreadCount = function() { return this._feedModel.getUnreadCount(); }; FeedBl.prototype["delete"] = function(feedId) { this._feedModel.removeById(feedId); return this._persistence.deleteFeed(feedId); }; FeedBl.prototype.markFeedRead = function(feedId) { var feed; feed = this._feedModel.getById(feedId); if (angular.isDefined(feed)) { feed.unreadCount = 0; return this._itemBl.markAllRead(feedId); } }; FeedBl.prototype.markAllRead = function() { var feed, _i, _len, _ref, _results; _ref = this._feedModel.getAll(); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { feed = _ref[_i]; _results.push(this.markFeedRead(feed.id)); } return _results; }; return FeedBl; })(); return FeedBl; }); }).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('_FolderBl', function() { var FolderBl; FolderBl = (function() { function FolderBl(_folderModel, _feedBl, _persistence) { this._folderModel = _folderModel; this._feedBl = _feedBl; this._persistence = _persistence; } FolderBl.prototype["delete"] = function(folderId) { this._folderModel.removeById(folderId); return this._persistence.deleteFolder(folderId); }; FolderBl.prototype.hasFeeds = function(folderId) { return this._feedBl.getFeedsOfFolder(folderId).length; }; FolderBl.prototype.markFolderRead = function(folderId) { var feed, _i, _len, _ref, _results; _ref = this._feedBl.getFeedsOfFolder(folderId); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { feed = _ref[_i]; _results.push(this._feedBl.markFeedRead(feed.id)); } return _results; }; FolderBl.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); } } }; return FolderBl; })(); return FolderBl; }); }).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('_ItemBl', function() { var ItemBl; ItemBl = (function() { function ItemBl(_itemModel, _persistence) { this._itemModel = _itemModel; this._persistence = _persistence; } ItemBl.prototype.markAllRead = function(feedId) { var highestItemId, item, _i, _len, _ref, _results; highestItemId = this._itemModel.getHighestId(); this._persistence.setFeedRead(feedId, highestItemId); _ref = this._itemModel.getAll(); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { item = _ref[_i]; _results.push(item.setRead()); } return _results; }; return ItemBl; })(); return ItemBl; }); }).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; this._urlHash = {}; FeedModel.__super__.constructor.call(this); } FeedModel.prototype.clear = function() { this._urlHash = {}; return FeedModel.__super__.clear.call(this); }; FeedModel.prototype.add = function(item, clearCache) { var entry; if (clearCache == null) { clearCache = true; } if (item.faviconLink === null) { item.faviconLink = 'url(' + this._utils.imagePath('news', 'rss.svg') + ')'; } entry = this._urlHash[item.urlHash]; if (angular.isDefined(entry)) { return this.update(item, clearCache); } else { this._urlHash[item.urlHash] = item; return FeedModel.__super__.add.call(this, item, clearCache); } }; FeedModel.prototype.update = function(item, clearCache) { var entry, key, value, _results; if (clearCache == null) { clearCache = true; } entry = this._urlHash[item.urlHash]; delete this._dataMap[entry.id]; this._dataMap[item.id] = entry; _results = []; for (key in item) { value = item[key]; if (key === 'urlHash') { continue; } else { _results.push(entry[key] = value); } } return _results; }; FeedModel.prototype.removeById = function(id) { var item; item = this.getById(id); delete this._urlHash[item.urlHash]; return FeedModel.__super__.removeById.call(this, id); }; FeedModel.prototype.getByUrlHash = function(urlHash) { return this._urlHash[urlHash]; }; 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', '_EqualQuery', function(_Model, _EqualQuery) { var FolderModel; FolderModel = (function(_super) { __extends(FolderModel, _super); function FolderModel() { return FolderModel.__super__.constructor.apply(this, arguments); } FolderModel.prototype.nameExists = function(folderName) { var query; query = new _EqualQuery('name', folderName.trim(), true); return this.get(query).length > 0; }; 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', 'StatusFlag', function(_Model, _MaximumQuery, _MinimumQuery, StatusFlag) { var ItemModel; ItemModel = (function(_super) { __extends(ItemModel, _super); function ItemModel() { this._guidFeedIdHash = {}; ItemModel.__super__.constructor.call(this); } ItemModel.prototype.clear = function() { this._guidFeedIdHash = {}; return ItemModel.__super__.clear.call(this); }; ItemModel.prototype.add = function(data, clearCache) { var entry, hash; if (clearCache == null) { clearCache = true; } this._bindMethods(data); hash = data.feedId + '_' + data.guidHash; entry = this._guidFeedIdHash[hash]; if (angular.isDefined(entry)) { return this.update(data, clearCache); } else { this._guidFeedIdHash[hash] = data; return ItemModel.__super__.add.call(this, data, clearCache); } }; ItemModel.prototype._bindMethods = function(data) { data.isRead = function() { return !((this.status & StatusFlag.UNREAD) === StatusFlag.UNREAD); }; data.setRead = function() { return this.status &= ~StatusFlag.UNREAD; }; data.setUnread = function() { return this.status |= StatusFlag.UNREAD; }; data.isStarred = function() { return (this.status & StatusFlag.STARRED) === StatusFlag.STARRED; }; data.setStarred = function() { return this.status |= StatusFlag.STARRED; }; return data.setUnstarred = function() { return this.status &= ~StatusFlag.STARRED; }; }; ItemModel.prototype.update = function(data, clearCache) { var entry, hash, key, value; if (clearCache == null) { clearCache = true; } hash = data.feedId + '_' + data.guidHash; entry = this._guidFeedIdHash[hash]; delete this._dataMap[entry.id]; this._dataMap[data.id] = entry; for (key in data) { value = data[key]; if (key === 'feedId' || key === 'guidHash') { continue; } else { entry[key] = value; } } return ItemModel.__super__.update.call(this, entry, clearCache); }; ItemModel.prototype.getByGuidHashAndFeedId = function(guidHash, feedId) { var hash; hash = feedId + '_' + guidHash; return this._guidFeedIdHash[hash]; }; ItemModel.prototype.removeById = function(id) { var hash, item; item = this.getById(id); hash = item.feedId + '_' + item.guidHash; delete this._guidFeedIdHash[hash]; return ItemModel.__super__.removeById.call(this, id); }; 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(feedId, guidHash) { /* Stars an item */ var params; params = { routeParams: { feedId: feedId, guidHash: guidHash } }; return this._request.post('news_items_star', params); }; Persistence.prototype.unstarItem = function(feedId, guidHash) { /* Unstars an item */ var params; params = { routeParams: { feedId: feedId, guidHash: guidHash } }; return this._request.post('news_items_unstar', params); }; Persistence.prototype.readItem = function(itemId) { /* Sets an item as read */ var params; params = { routeParams: { itemId: itemId } }; return this._request.post('news_items_read', params); }; Persistence.prototype.unreadItem = function(itemId) { /* Sets an item as unread */ var params; params = { routeParams: { 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 = { routeParams: { 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 = { routeParams: { 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 = { routeParams: { 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 = { routeParams: { 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 = { routeParams: { folderId: folderId } }; return this._request.post('news_folders_open', params); }; Persistence.prototype.collapseFolder = function(folderId) { /* Save if a folder was collapsed */ var params; params = { routeParams: { 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 = { routeParams: { 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 = { routeParams: { 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('AutoPageLoading', [ '_Loading', function(_Loading) { return new _Loading(); } ]); angular.module('News').factory('NewLoading', [ '_Loading', function(_Loading) { return new _Loading(); } ]); angular.module('News').factory('ItemBl', [ '_ItemBl', 'ItemModel', 'Persistence', function(_ItemBl, ItemModel, Persistence) { return new _ItemBl(ItemModel, Persistence); } ]); angular.module('News').factory('FeedBl', [ '_FeedBl', 'FeedModel', 'ItemBl', 'Persistence', function(_FeedBl, FeedModel, ItemBl, Persistence) { return new _FeedBl(FeedModel, ItemBl, Persistence); } ]); angular.module('News').factory('FolderBl', [ '_FolderBl', 'FolderModel', 'FeedBl', 'Persistence', function(_FolderBl, FolderModel, FeedBl, Persistence) { return new _FolderBl(FolderModel, FeedBl, Persistence); } ]); 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); // 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('StatusFlag', function() { return { UNREAD: 0x02, STARRED: 0x04, DELETED: 0x08, UPDATED: 0x16 }; }); }).call(this); })(window.angular, jQuery);