This commit is contained in:
Bernhard Posselt 2013-04-08 17:56:53 +02:00
Родитель e6d926de62
Коммит ca0864dbcd
8 изменённых файлов: 344 добавлений и 94 удалений

Просмотреть файл

@ -23,9 +23,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').factory 'FolderBl',
['_Bl', 'FolderModel', 'FeedBl', 'Persistence', 'FeedType', 'ActiveFeed',
'ItemModel', 'ShowAll',
'ItemModel', 'ShowAll', '_ExistsError',
(_Bl, FolderModel, FeedBl, Persistence, FeedType, ActiveFeed,
ItemModel, ShowAll)->
ItemModel, ShowAll, _ExistsError)->
class FolderBl extends _Bl
@ -81,6 +81,12 @@ ItemModel, ShowAll)->
return @_folderModel.getAll()
create: (folderName) ->
if @_folderModel.nameExists(folderName)
throw new _ExistsError()
return new FolderBl(FolderModel, FeedBl, ShowAll, ActiveFeed, Persistence,
FeedType, ItemModel)

Просмотреть файл

@ -0,0 +1,32 @@
###
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 <http://www.gnu.org/licenses/>.
###
angular.module('News').factory '_ExistsError', ->
class ExistsError extends Error
constructor: (message='') ->
super(message)
return ExistsError

Просмотреть файл

@ -18,7 +18,7 @@
"devDependencies": {
"grunt": "~0.4.0",
"grunt-cli": "~0.1.6",
"coffee-script": "~1.4.0",
"coffee-script": "~1.6",
"grunt-contrib-concat": "~0.1.2",
"grunt-contrib-watch": "~0.2.0",
"grunt-coffeelint": "0.0.6",

Просмотреть файл

@ -11,8 +11,7 @@
*/
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -36,9 +35,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News', ['OC', 'ui']).config(function($provide) {
var config;
return $provide.value('Config', config = {
markReadTimeout: 500,
scrollTimeout: 500,
@ -138,8 +137,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -163,7 +161,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').controller('SettingsController', [
'$scope', '_SettingsController', function($scope, _SettingsController) {
return new _SettingsController($scope);
@ -184,8 +181,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -209,13 +205,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_FeedController', function() {
var FeedController;
FeedController = (function() {
FeedController = (function() {
function FeedController($scope, _persistence, _folderBl, _feedBl, _subscriptionsBl, _starredBl, _unreadCountFormatter) {
var _this = this;
this.$scope = $scope;
this._persistence = _persistence;
this._folderBl = _folderBl;
@ -238,6 +234,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
};
this.$scope.addFeed = function(feedUrl, parentFolderId) {
var onError, onSuccess;
if (parentFolderId == null) {
parentFolderId = 0;
}
@ -293,8 +290,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -318,13 +314,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_ItemController', function() {
var ItemController;
ItemController = (function() {
ItemController = (function() {
function ItemController(_$scope, _itemBl, _feedModel, _feedLoading, _feedBl) {
var _this = this;
this._$scope = _$scope;
this._itemBl = _itemBl;
this._feedModel = _feedModel;
@ -337,6 +333,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
};
this._$scope.getFeedTitle = function(feedId) {
var feed;
feed = _this._feedModel.getById(feedId);
if (angular.isDefined(feed)) {
return feed.title;
@ -354,8 +351,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -379,13 +375,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_SettingsController', function() {
var SettingsController;
SettingsController = (function() {
SettingsController = (function() {
function SettingsController($scope) {
var _this = this;
this.$scope = $scope;
this.$scope["import"] = function(fileContent) {
console.log('hi');
@ -401,8 +397,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -426,11 +421,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_ActiveFeed', function() {
var ActiveFeed;
ActiveFeed = (function() {
ActiveFeed = (function() {
function ActiveFeed() {
/*
Default value is all feeds
@ -460,8 +454,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -485,11 +478,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_Bl', function() {
var Bl;
Bl = (function() {
Bl = (function() {
function Bl(_activeFeed, _persistence, _itemModel, _type) {
this._activeFeed = _activeFeed;
this._persistence = _persistence;
@ -499,6 +491,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Bl.prototype.load = function(id) {
var lastModified;
if (this._type !== this._activeFeed.getType() || id !== this._activeFeed.getId()) {
this._itemModel.clear();
this._persistence.getItems(this._type, id, 0);
@ -524,8 +517,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -555,8 +547,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').factory('FeedBl', [
'_Bl', 'ShowAll', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', 'FeedModel', 'NewLoading', function(_Bl, ShowAll, Persistence, ActiveFeed, FeedType, ItemModel, FeedModel, NewLoading) {
var FeedBl;
FeedBl = (function(_super) {
FeedBl = (function(_super) {
__extends(FeedBl, _super);
function FeedBl(_showAll, _feedModel, persistence, activeFeed, feedType, itemModel, _newLoading) {
@ -589,6 +581,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedBl.prototype.markFeedRead = function(feedId) {
var feed, highestItemId, item, _i, _len, _ref, _results;
feed = this._feedModel.getById(feedId);
if (angular.isDefined(feed)) {
feed.unreadCount = 0;
@ -606,6 +599,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedBl.prototype.markAllRead = function() {
var feed, _i, _len, _ref, _results;
_ref = this._feedModel.getAll();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -629,6 +623,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedBl.prototype.move = function(feedId, folderId) {
var feed;
feed = this._feedModel.getById(feedId);
if (angular.isDefined(feed) && feed.folderId !== folderId) {
this._feedModel.update({
@ -643,6 +638,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedBl.prototype.setShowAll = function(showAll) {
var callback,
_this = this;
this._showAll.setShowAll(showAll);
callback = function() {
_this._itemModel.clear();
@ -668,6 +664,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedBl.prototype.getFeedLink = function(feedId) {
var feed;
feed = this._feedModel.getById(feedId);
if (angular.isDefined(feed)) {
return feed.link;
@ -683,8 +680,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -712,10 +708,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
__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('FolderBl', [
'_Bl', 'FolderModel', 'FeedBl', 'Persistence', 'FeedType', 'ActiveFeed', 'ItemModel', 'ShowAll', function(_Bl, FolderModel, FeedBl, Persistence, FeedType, ActiveFeed, ItemModel, ShowAll) {
'_Bl', 'FolderModel', 'FeedBl', 'Persistence', 'FeedType', 'ActiveFeed', 'ItemModel', 'ShowAll', '_ExistsError', function(_Bl, FolderModel, FeedBl, Persistence, FeedType, ActiveFeed, ItemModel, ShowAll, _ExistsError) {
var FolderBl;
FolderBl = (function(_super) {
FolderBl = (function(_super) {
__extends(FolderBl, _super);
function FolderBl(_folderModel, _feedBl, _showAll, activeFeed, persistence, _feedType, itemModel) {
@ -737,6 +733,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FolderBl.prototype.toggleFolder = function(folderId) {
var folder;
folder = this._folderModel.getById(folderId);
if (angular.isDefined(folder)) {
folder.opened = !folder.opened;
@ -750,6 +747,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
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++) {
@ -765,6 +763,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FolderBl.prototype.isVisible = function(folderId) {
var feed, _i, _len, _ref;
if (this._showAll.getShowAll()) {
return true;
} else {
@ -788,6 +787,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return this._folderModel.getAll();
};
FolderBl.prototype.create = function(folderName) {
if (this._folderModel.nameExists(folderName)) {
throw new _ExistsError();
}
};
return FolderBl;
})(_Bl);
@ -797,8 +802,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -822,12 +826,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('ItemBl', [
'ItemModel', 'FeedModel', 'Persistence', 'ActiveFeed', 'FeedType', 'StarredBl', function(ItemModel, FeedModel, Persistence, ActiveFeed, FeedType, StarredBl) {
var ItemBl;
ItemBl = (function() {
ItemBl = (function() {
function ItemBl(_itemModel, _feedModel, _persistence, _activeFeed, _feedType, _starredBl) {
this._itemModel = _itemModel;
this._feedModel = _feedModel;
@ -847,6 +850,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemBl.prototype.isKeptUnread = function(itemId) {
var item;
item = this._itemModel.getById(itemId);
if (angular.isDefined(item) && angular.isDefined(item.keptUnread)) {
return item.keptUnread;
@ -856,6 +860,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemBl.prototype.toggleKeepUnread = function(itemId) {
var item;
item = this._itemModel.getById(itemId);
if (angular.isDefined(item) && !item.keptUnread) {
item.keptUnread = true;
@ -869,6 +874,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemBl.prototype.toggleStarred = function(itemId) {
var item;
item = this._itemModel.getById(itemId);
if (item.isStarred()) {
item.setUnstarred();
@ -883,6 +889,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemBl.prototype.setRead = function(itemId) {
var feed, item;
item = this._itemModel.getById(itemId);
if (angular.isDefined(item)) {
if (!item.isRead()) {
@ -898,6 +905,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemBl.prototype.setUnread = function(itemId) {
var feed, item;
item = this._itemModel.getById(itemId);
if (angular.isDefined(item)) {
if (item.isRead()) {
@ -913,6 +921,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemBl.prototype.getFeedTitle = function(itemId) {
var feed, item;
item = this._itemModel.getById(itemId);
if (angular.isDefined(item)) {
feed = this._feedModel.getById(item.feedId);
@ -935,8 +944,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -966,8 +974,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').factory('StarredBl', [
'_Bl', 'StarredCount', 'Persistence', 'ActiveFeed', 'FeedType', 'ItemModel', function(_Bl, StarredCount, Persistence, ActiveFeed, FeedType, ItemModel) {
var StarredBl;
StarredBl = (function(_super) {
StarredBl = (function(_super) {
__extends(StarredBl, _super);
function StarredBl(_starredCount, feedType, persistence, activeFeed, itemModel) {
@ -1004,8 +1012,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -1035,8 +1042,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').factory('SubscriptionsBl', [
'_Bl', 'FeedBl', 'Persistence', 'ShowAll', 'ActiveFeed', 'FeedType', 'ItemModel', function(_Bl, FeedBl, Persistence, ShowAll, ActiveFeed, FeedType, ItemModel) {
var SubscriptionsBl;
SubscriptionsBl = (function(_super) {
SubscriptionsBl = (function(_super) {
__extends(SubscriptionsBl, _super);
function SubscriptionsBl(_feedBl, _showAll, feedType, persistence, activeFeed, itemModel) {
@ -1047,6 +1054,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
SubscriptionsBl.prototype.isVisible = function() {
var visible;
if (this.isActive(0)) {
return true;
}
@ -1075,8 +1083,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -1100,9 +1107,57 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
angular.module('News').factory('_ExistsError', function() {
var ExistsError;
ExistsError = (function(_super) {
__extends(ExistsError, _super);
function ExistsError(message) {
if (message == null) {
message = '';
}
ExistsError.__super__.constructor.call(this, message);
}
return ExistsError;
})(Error);
return ExistsError;
});
}).call(this);
// Generated by CoffeeScript 1.6.2
/*
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 <http://www.gnu.org/licenses/>.
*/
(function() {
angular.module('News').factory('FeedType', function() {
var feedType;
return feedType = {
Feed: 0,
Folder: 1,
@ -1114,8 +1169,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -1145,8 +1199,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').factory('_FeedModel', [
'_Model', '_EqualQuery', function(_Model, _EqualQuery) {
var FeedModel;
FeedModel = (function(_super) {
FeedModel = (function(_super) {
__extends(FeedModel, _super);
function FeedModel(_utils) {
@ -1162,6 +1216,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedModel.prototype.add = function(item, clearCache) {
var entry;
if (clearCache == null) {
clearCache = true;
}
@ -1179,6 +1234,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedModel.prototype.update = function(item, clearCache) {
var entry, key, value, _results;
if (clearCache == null) {
clearCache = true;
}
@ -1199,6 +1255,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedModel.prototype.removeById = function(id) {
var item;
item = this.getById(id);
delete this._urlHash[item.urlHash];
return FeedModel.__super__.removeById.call(this, id);
@ -1210,6 +1267,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedModel.prototype.getUnreadCount = function() {
var count, feed, _i, _len, _ref;
count = 0;
_ref = this.getAll();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -1221,6 +1279,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedModel.prototype.getFeedUnreadCount = function(feedId) {
var count, feed;
feed = this.getById(feedId);
count = 0;
if (angular.isDefined(feed)) {
@ -1232,6 +1291,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedModel.prototype.getFolderUnreadCount = function(folderId) {
var count, feed, query, _i, _len, _ref;
query = new _EqualQuery('folderId', folderId);
count = 0;
_ref = this.get(query);
@ -1244,6 +1304,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
FeedModel.prototype.getAllOfFolder = function(folderId) {
var query;
query = new _EqualQuery('folderId', folderId);
return this.get(query);
};
@ -1257,8 +1318,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -1287,17 +1347,19 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').factory('_FolderModel', [
'_Model', '_EqualQuery', function(_Model, _EqualQuery) {
var FolderModel;
FolderModel = (function(_super) {
var FolderModel, _ref;
FolderModel = (function(_super) {
__extends(FolderModel, _super);
function FolderModel() {
return FolderModel.__super__.constructor.apply(this, arguments);
_ref = FolderModel.__super__.constructor.apply(this, arguments);
return _ref;
}
FolderModel.prototype.nameExists = function(folderName) {
var query;
query = new _EqualQuery('name', folderName.trim(), true);
return this.get(query).length > 0;
};
@ -1311,8 +1373,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -1342,8 +1403,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('News').factory('_ItemModel', [
'_Model', '_MaximumQuery', '_MinimumQuery', 'StatusFlag', function(_Model, _MaximumQuery, _MinimumQuery, StatusFlag) {
var ItemModel;
ItemModel = (function(_super) {
ItemModel = (function(_super) {
__extends(ItemModel, _super);
function ItemModel() {
@ -1358,6 +1419,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemModel.prototype.add = function(data, clearCache) {
var entry, hash;
if (clearCache == null) {
clearCache = true;
}
@ -1395,6 +1457,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemModel.prototype.update = function(data, clearCache) {
var entry, hash, key, value;
if (clearCache == null) {
clearCache = true;
}
@ -1415,12 +1478,14 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
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];
@ -1429,6 +1494,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
ItemModel.prototype.getHighestId = function() {
var highestId, query;
query = new _MaximumQuery('id');
highestId = this.get(query);
if (angular.isDefined(highestId)) {
@ -1447,8 +1513,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -1472,11 +1537,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_OPMLParser', function() {
var Feed, Folder, OPMLParser;
Feed = (function() {
Feed = (function() {
function Feed(_name, _url) {
this._name = _name;
this._url = _url;
@ -1498,7 +1562,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
})();
Folder = (function() {
function Folder(_name) {
this._name = _name;
this._items = [];
@ -1524,11 +1587,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
})();
OPMLParser = (function() {
function OPMLParser() {}
OPMLParser.prototype.parseXML = function(xml) {
var $root, $xml, structure;
$xml = $($.parseXML(xml));
$root = $xml.find('body');
structure = new Folder('root');
@ -1538,6 +1601,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
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++) {
@ -1563,8 +1627,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -1588,11 +1651,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_Persistence', function() {
var Persistence;
Persistence = (function() {
Persistence = (function() {
function Persistence(_request, _loading, _config, _activeFeed, _$rootScope) {
this._request = _request;
this._loading = _loading;
@ -1608,6 +1670,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
var triggerHideRead,
_this = this;
this._loading.increase();
this.getActiveFeed(function() {
return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId(), 0, function() {
@ -1630,6 +1693,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.getItems = function(type, id, offset, onSuccess, updatedSince) {
var data, params;
if (onSuccess == null) {
onSuccess = null;
}
@ -1660,6 +1724,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.getStarredItems = function(onSuccess) {
var params;
params = {
onSuccess: onSuccess
};
@ -1672,6 +1737,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
feedId: feedId,
@ -1687,6 +1753,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
feedId: feedId,
@ -1702,6 +1769,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
itemId: itemId
@ -1716,6 +1784,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
itemId: itemId
@ -1731,6 +1800,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.getAllFeeds = function(callback) {
var params;
callback || (callback = function() {});
params = {
onSuccess: callback
@ -1740,6 +1810,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.getActiveFeed = function(onSuccess) {
var params;
params = {
onSuccess: onSuccess
};
@ -1748,6 +1819,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.createFeed = function(url, parentFolderId, onSuccess, onFailure) {
var params;
if (onSuccess == null) {
onSuccess = null;
}
@ -1769,6 +1841,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.deleteFeed = function(feedId) {
var params;
params = {
routeParams: {
feedId: feedId
@ -1783,6 +1856,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
feedId: feedId
@ -1800,6 +1874,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
feedId: feedId
@ -1817,6 +1892,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
feedId: feedId
@ -1832,6 +1908,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.getAllFolders = function(callback) {
var params;
callback || (callback = function() {});
params = {
onSuccess: callback
@ -1845,6 +1922,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
folderId: folderId
@ -1859,6 +1937,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
folderId: folderId
@ -1869,6 +1948,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.createFolder = function(folderName, parentFolderId, onSuccess, onFailure) {
var params;
if (parentFolderId == null) {
parentFolderId = 0;
}
@ -1897,6 +1977,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
folderId: folderId
@ -1911,6 +1992,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var params;
params = {
routeParams: {
folderId: folderId
@ -1941,6 +2023,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.userSettingsRead = function(callback) {
var params;
if (callback == null) {
callback = null;
}
@ -1961,6 +2044,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var data;
data = {
onSuccess: callback
};
@ -1973,6 +2057,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
var data;
data = {
onSuccess: callback
};
@ -1991,8 +2076,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -2016,7 +2100,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(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);
@ -2086,6 +2169,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
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');
@ -2105,8 +2189,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -2130,11 +2213,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_ShowAll', function() {
var ShowAll;
ShowAll = (function() {
ShowAll = (function() {
function ShowAll() {
this._showAll = false;
}
@ -2159,8 +2241,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -2184,11 +2265,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('_StarredCount', function() {
var StarredCount;
StarredCount = (function() {
StarredCount = (function() {
function StarredCount() {
this._count = 0;
}
@ -2213,8 +2293,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -2238,7 +2317,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('StatusFlag', function() {
return {
UNREAD: 0x02,
@ -2250,8 +2328,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.2
/*
ownCloud - News
@ -2275,7 +2352,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').factory('unreadCountFormatter', function() {
return function(unreadCount) {
if (unreadCount > 999) {

Просмотреть файл

@ -30,11 +30,12 @@ describe 'FolderBl', ->
@persistence = {}
beforeEach inject (@FolderBl, @FolderModel, @FeedModel, @ShowAll,
@ActiveFeed, @FeedType) =>
@ActiveFeed, @FeedType, @_ExistsError) =>
@ShowAll.setShowAll(false)
@ActiveFeed.handle({type: @FeedType.Feed, id:0})
it 'should delete folders', =>
@FolderModel.removeById = jasmine.createSpy('remove')
@persistence.deleteFolder = jasmine.createSpy('deletequery')
@ -130,3 +131,8 @@ describe 'FolderBl', ->
expect(@FolderBl.getAll()).toContain(item2)
it 'should not create a folder if it already exists', =>
item1 = {id: 4, open: true, name: 'john'}
@FolderModel.add(item1)
expect(@FolderBl.create('johns')).toThrow(new @_ExistsError())

Просмотреть файл

@ -17,6 +17,7 @@ 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/>.
###
@ -26,11 +27,139 @@ describe 'OPMLParser', ->
beforeEach module 'News'
beforeEach inject (@OPMLParser) =>
@opml = '<?xml version="1.0" ?>
<opml version="1.1">
<!--Generated by NewsBlur - www.newsblur.com-->
<head>
<title>
NewsBlur Feeds
</title>
<dateCreated>
2013-03-14 16:44:01.356965
</dateCreated>
<dateModified>
2013-03-14 16:44:01.356965
</dateModified>
</head>
<body>
<outline htmlUrl="http://www.reddit.com/r/tldr/"
text="test_text" type="rss" version="RSS"
xmlUrl="http://www.reddit.com/r/tldr.rss"/>
<outline htmlUrl="http://news.ycombinator.com"
text="Hacker News 200" title="Hacker News 200" type="rss"
version="RSS"
xmlUrl=
"http://feeds.feedburner.com/hacker-news-feed-200?format=xml"/>
<outline text="Design" title="Design">
<outline htmlUrl="http://worrydream.com/" text=
"&lt;div&gt;Bret Victor\'s website&lt;/div&gt;"
title="&lt;div&gt;Bret Victor\'s website&lt;/div&gt;"
type="rss"
version="RSS" xmlUrl="http://worrydream.com/feed.xml"/>
<outline htmlUrl="http://www.hylkebons.nl/journal/rss/" text=
"Journal - Hylke Bons"
title="Journal - Hylke Bons"
type="rss"
version="RSS" xmlUrl="http://feeds.feedburner.com/HbonsHome"/>
<outline htmlUrl="http://afaikblog.wordpress.com" text=
"As far as I know"
title="As far as I know"
type="rss"
version="RSS" xmlUrl="https://afaikblog.wordpress.com/feed/"/>
<outline htmlUrl="http://informationarchitects.net" text=
"Information Architects"
title="Information Architects"
type="rss"
version="RSS" xmlUrl="http://informationarchitects.net/feed/"/>
<outline htmlUrl="http://ignorethecode.net" text=
"ignorethecode.net"
title="ignorethecode.net"
type="rss"
version="RSS"
xmlUrl="http://feeds.feedburner.com/IgnoreTheCode"/>
<outline htmlUrl="http://blogs.gnome.org/mccann" text=
"Push the Button"
title="Push the Button"
type="rss"
version="RSS" xmlUrl="https://blogs.gnome.org/mccann/feed/"/>
<outline htmlUrl="http://littlebigdetails.com/" text=
"Little Big Details"
title="Little Big Details"
type="rss"
version="RSS"
xmlUrl="http://feeds.feedburner.com/littlebigdetails"/>
<outline htmlUrl="http://theixdlibrary.com" text=
"The IxD Library"
title="The IxD Library" type="rss"
version="RSS" xmlUrl="http://theixdlibrary.com/feed/"/>
</outline>
<outline text="Nomadism" title="Nomadism">
<outline htmlUrl="http://a-flat.posterous.com"
text="a-flat" title="a-flat" type="rss"
version="RSS" xmlUrl="http://a-flat.posterous.com/rss.xml"/>
<outline htmlUrl="http://egor.im"
text="egor.im" title="egor.im" type="rss"
version="RSS" xmlUrl="http://feeds.feedburner.com/egorim"/>
<outline htmlUrl="http://nomadbase.org/"
text="nomadbase - find the others..."
title="nomadbase - find the others..." type="rss"
version="RSS" xmlUrl="http://nomadbase.org/rss.xml"/>
<outline htmlUrl="http://casarobino.org/frontpage"
text="Casa Robino - Shared Hospitality"
title="Casa Robino - Shared Hospitality" type="rss"
version="RSS" xmlUrl="http://casarobino.org/rss.xml"/>
<outline htmlUrl="http://casabhavani.org"
text="Casa Bhavani" title="Casa Bhavani" type="rss"
version="RSS" xmlUrl="http://casabhavani.org/feed/"/>
</outline>
<outline htmlUrl="http://www.elezea.com"
text="Elezea" title="Elezea" type="rss"
version="RSS" xmlUrl="http://feeds.feedburner.com/elezea"/>
</body>
</opml>'
@data = @OPMLParser.parseXML(@opml)
it 'should return only the root folder when parsing empty OPML', =>
@data = @OPMLParser.parseXML('')
expect(@data.getName()).toBe('root')
data = @OPMLParser.parseXML('')
expect(data.getName()).toBe('root')
# TODO: write rest
it 'should parse folders', =>
firstLevel = @data.getItems()
expect(firstLevel[2].isFolder()).toBe(true)
expect(firstLevel[2].getName()).toBe('Design')
it 'should parse feeds', =>
firstLevel = @data.getItems()[0]
expect(firstLevel.isFolder()).toBe(false)
expect(firstLevel.getUrl()).toBe('http://www.reddit.com/r/tldr.rss')
expect(firstLevel.getName()).toBe('test_text')
it 'should nest feeds', =>
secondLevel = @data.getItems()[2].getItems()[1]
expect(secondLevel.isFolder()).toBe(false)
expect(secondLevel.getUrl()).
toBe('http://feeds.feedburner.com/HbonsHome')
expect(secondLevel.getName()).toBe('Journal - Hylke Bons')

Просмотреть файл

@ -15,9 +15,6 @@
</a>
<span class="utils">
<button ng-click="feedBl.delete(feed.id)"
class="svg action delete-icon"
title="<?php p($l->t('Delete feed')); ?>"></button>
<span class="unread-counter">
{{ feedBl.getUnreadCount(feed.id) }}
@ -27,6 +24,10 @@
ng-show="feedBl.getUnreadCount(feed.id) > 0"
ng-click="feedBl.markFeedRead(feed.id)"
title="<?php p($l->t('Mark all read')); ?>"></button>
<button ng-click="feedBl.delete(feed.id)"
class="svg action delete-icon"
title="<?php p($l->t('Delete feed')); ?>"></button>
</span>
</li>

Просмотреть файл

@ -1,6 +1,6 @@
<li ng-class="{
active: folderBl.isActive(folder.id),
open: folder.opened,
open: folder.opened && folderBl.hasFeeds(folder.id),
collapsible: folderBl.hasFeeds(folder.id),
unread: folderBl.getUnreadCount(folder.id) != 0
}"