summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-01-27 04:15:53 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-01-27 04:15:53 +0100
commitae7393db3d99a7ac223ae917129cccd9f49888e3 (patch)
tree7f54b72b0d01c38afd1378365a67e4f192922423 /js
parent483784caa38bd6131405ac474347a215584e30a5 (diff)
merged the angularjs branch
Diffstat (limited to 'js')
-rw-r--r--js/app.js2142
-rw-r--r--js/cache.js32
-rw-r--r--js/firstrun.js7
-rw-r--r--js/items.js705
-rw-r--r--js/main.js149
-rw-r--r--js/menu.js920
-rw-r--r--js/news.js134
-rw-r--r--js/settings.js101
8 files changed, 2142 insertions, 2048 deletions
diff --git a/js/app.js b/js/app.js
new file mode 100644
index 000000000..31e92e152
--- /dev/null
+++ b/js/app.js
@@ -0,0 +1,2142 @@
+// Generated by CoffeeScript 1.3.3
+
+/*
+# ownCloud - News app
+#
+# @author Bernhard Posselt
+# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+#
+# This file is licensed under the Affero General Public License version 3 or later.
+# See the COPYING-README file
+#
+*/
+
+
+(function() {
+ var app, markingRead, scrolling,
+ __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; };
+
+ app = angular.module('News', []).config(function($provide) {
+ var config;
+ config = {
+ MarkReadTimeout: 500,
+ ScrollTimeout: 500,
+ initialLoadedItemsNr: 20,
+ FeedUpdateInterval: 6000000
+ };
+ return $provide.value('Config', config);
+ });
+
+ app.run([
+ 'PersistenceNews', function(PersistenceNews) {
+ return PersistenceNews.loadInitial();
+ }
+ ]);
+
+ $(document).ready(function() {
+ $(this).keyup(function(e) {
+ if ((e.which === 116) || (e.which === 82 && e.ctrlKey)) {
+ document.location.reload(true);
+ return false;
+ }
+ });
+ return $('#browselink').click(function() {
+ return $('#file_upload_start').trigger('click');
+ });
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ scrolling = true;
+
+ markingRead = true;
+
+ angular.module('News').directive('whenScrolled', [
+ '$rootScope', 'Config', function($rootScope, Config) {
+ return function(scope, elm, attr) {
+ return elm.bind('scroll', function() {
+ if (scrolling) {
+ scrolling = false;
+ setTimeout(function() {
+ return scrolling = true;
+ }, Config.ScrollTimeout);
+ if (markingRead) {
+ markingRead = false;
+ setTimeout(function() {
+ var $elems, feed, feedItem, id, offset, _i, _len, _results;
+ markingRead = true;
+ $elems = $(elm).find('.feed_item:not(.read)');
+ _results = [];
+ for (_i = 0, _len = $elems.length; _i < _len; _i++) {
+ feedItem = $elems[_i];
+ offset = $(feedItem).position().top;
+ if (offset <= -50) {
+ id = parseInt($(feedItem).data('id'), 10);
+ feed = parseInt($(feedItem).data('feed'), 10);
+ _results.push($rootScope.$broadcast('read', {
+ id: id,
+ feed: feed
+ }));
+ } else {
+ break;
+ }
+ }
+ return _results;
+ }, Config.MarkReadTimeout);
+ }
+ return scope.$apply(attr.whenScrolled);
+ }
+ });
+ };
+ }
+ ]);
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').directive('onEnter', function() {
+ return function(scope, elm, attr) {
+ return elm.bind('keyup', function(e) {
+ if (e.keyCode === 13) {
+ e.preventDefault();
+ return scope.$apply(attr.onEnter);
+ }
+ });
+ };
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').directive('feedNavigation', function() {
+ return function(scope, elm, attr) {
+ var jumpTo, jumpToNextItem, jumpToPreviousItem;
+ jumpTo = function($scrollArea, $item) {
+ var position;
+ position = $item.offset().top - $scrollArea.offset().top + $scrollArea.scrollTop();
+ return $scrollArea.scrollTop(position);
+ };
+ jumpToPreviousItem = function(scrollArea) {
+ var $item, $items, $previous, $scrollArea, item, notJumped, _i, _len;
+ $scrollArea = $(scrollArea);
+ $items = $scrollArea.find('.feed_item');
+ notJumped = true;
+ for (_i = 0, _len = $items.length; _i < _len; _i++) {
+ item = $items[_i];
+ $item = $(item);
+ if ($item.position().top >= 0) {
+ $previous = $item.prev();
+ if ($previous.length > 0) {
+ jumpTo($scrollArea, $previous);
+ }
+ notJumped = false;
+ break;
+ }
+ }
+ if ($items.length > 0 && notJumped) {
+ return jumpTo($scrollArea, $items.last());
+ }
+ };
+ jumpToNextItem = function(scrollArea) {
+ var $item, $items, $scrollArea, item, _i, _len, _results;
+ $scrollArea = $(scrollArea);
+ $items = $scrollArea.find('.feed_item');
+ _results = [];
+ for (_i = 0, _len = $items.length; _i < _len; _i++) {
+ item = $items[_i];
+ $item = $(item);
+ if ($item.position().top > 1) {
+ jumpTo($scrollArea, $item);
+ break;
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+ return $(document).keydown(function(e) {
+ var focused, scrollArea;
+ focused = $(':focus');
+ if (!(focused.is('input') || focused.is('select') || focused.is('textarea') || focused.is('checkbox') || focused.is('button'))) {
+ scrollArea = elm;
+ if (e.keyCode === 74 || e.keyCode === 39) {
+ return jumpToNextItem(scrollArea);
+ } else if (e.keyCode === 75 || e.keyCode === 37) {
+ return jumpToPreviousItem(scrollArea);
+ }
+ }
+ });
+ };
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ /*
+ # This is used to signal the settings bar that the app has been focused and that
+ # it should hide
+ */
+
+
+ angular.module('News').directive('hideSettingsWhenFocusLost', [
+ '$rootScope', function($rootScope) {
+ return function(scope, elm, attr) {
+ $(document.body).click(function() {
+ $rootScope.$broadcast('hidesettings');
+ return scope.$apply(attr.hideSettingsWhenFocusLost);
+ });
+ return $(elm).click(function(e) {
+ return e.stopPropagation();
+ });
+ };
+ }
+ ]);
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').directive('draggable', function() {
+ return function(scope, elm, attr) {
+ var details;
+ details = {
+ revert: true,
+ stack: '> li',
+ zIndex: 1000,
+ axis: 'y'
+ };
+ return $(elm).draggable(details);
+ };
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ /*
+ Thise directive can be bound on an input element with type file and name files []
+ When a file is input, the content will be broadcasted as a readFile event
+ */
+
+
+ angular.module('News').directive('readFile', [
+ '$rootScope', function($rootScope) {
+ return function(scope, elm, attr) {
+ return $(elm).change(function() {
+ var file, reader;
+ if (window.File && window.FileReader && window.FileList) {
+ file = elm[0].files[0];
+ reader = new FileReader();
+ reader.onload = function(e) {
+ var content;
+ content = e.target.result;
+ return $rootScope.$broadcast('readFile', content);
+ };
+ return reader.readAsText(file);
+ } else {
+ return alert('Your browser does not support the FileReader API!');
+ }
+ });
+ };
+ }
+ ]);
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').directive('droppable', [
+ '$rootScope', function($rootScope) {
+ return function(scope, elm, attr) {
+ var $elem, details;
+ $elem = $(elm);
+ details = {
+ accept: '.feed',
+ hoverClass: 'dnd_over',
+ greedy: true,
+ drop: function(event, ui) {
+ var data;
+ $('.dnd_over').removeClass('dnd_over');
+ data = {
+ folderId: parseInt($elem.data('id'), 10),
+ feedId: parseInt($(ui.draggable).data('id'), 10)
+ };
+ $rootScope.$broadcast('moveFeedToFolder', data);
+ return scope.$apply(attr.droppable);
+ }
+ };
+ return $elem.droppable(details);
+ };
+ }
+ ]);
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').filter('feedInFolder', function() {
+ return function(feeds, folderId) {
+ var feed, result, _i, _len;
+ result = [];
+ for (_i = 0, _len = feeds.length; _i < _len; _i++) {
+ feed = feeds[_i];
+ if (feed.folderId === folderId) {
+ result.push(feed);
+ }
+ }
+ return result;
+ };
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_FeedModel', [
+ 'Model', function(Model) {
+ var FeedModel;
+ FeedModel = (function(_super) {
+
+ __extends(FeedModel, _super);
+
+ function FeedModel() {
+ FeedModel.__super__.constructor.call(this);
+ }
+
+ FeedModel.prototype.add = function(item) {
+ return FeedModel.__super__.add.call(this, this.bindAdditional(item));
+ };
+
+ FeedModel.prototype.bindAdditional = function(item) {
+ if (item.icon === "url()") {
+ item.icon = 'url(' + OC.imagePath('news', 'rss.svg') + ')';
+ }
+ return item;
+ };
+
+ return FeedModel;
+
+ })(Model);
+ return FeedModel;
+ }
+ ]);
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_GarbageRegistry', function() {
+ var GarbageRegistry;
+ GarbageRegistry = (function() {
+
+ function GarbageRegistry(itemModel) {
+ this.itemModel = itemModel;
+ this.registeredItemIds = {};
+ }
+
+ GarbageRegistry.prototype.register = function(item) {
+ var itemId;
+ itemId = item.id;
+ return this.registeredItemIds[itemId] = item;
+ };
+
+ GarbageRegistry.prototype.unregister = function(item) {
+ var itemId;
+ itemId = item.id;
+ return delete this.registeredItemIds[itemId];
+ };
+
+ GarbageRegistry.prototype.clear = function() {
+ var id, item, _ref;
+ _ref = this.registeredItemIds;
+ for (id in _ref) {
+ item = _ref[id];
+ if (!item.keptUnread) {
+ this.itemModel.removeById(parseInt(id, 10));
+ }
+ item.keptUnread = false;
+ }
+ return this.registeredItemIds = {};
+ };
+
+ return GarbageRegistry;
+
+ })();
+ return GarbageRegistry;
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_ShowAll', function() {
+ var ShowAll;
+ ShowAll = (function() {
+
+ function ShowAll() {
+ this.showAll = false;
+ }
+
+ ShowAll.prototype.handle = function(data) {
+ return this.showAll = data;
+ };
+
+ return ShowAll;
+
+ })();
+ return ShowAll;
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_PersistenceNews', [
+ 'Persistence', function(Persistence) {
+ var PersistenceNews;
+ PersistenceNews = (function(_super) {
+
+ __extends(PersistenceNews, _super);
+
+ function PersistenceNews($http, $rootScope, loading, publisher) {
+ this.$rootScope = $rootScope;
+ this.loading = loading;
+ this.publisher = publisher;
+ PersistenceNews.__super__.constructor.call(this, 'news', $http);
+ }
+
+ PersistenceNews.prototype.updateModels = function(data) {
+ var type, value, _results;
+ _results = [];
+ for (type in data) {
+ value = data[type];
+ _results.push(this.publisher.publish(type, value));
+ }
+ return _results;
+ };
+
+ PersistenceNews.prototype.loadInitial = function() {
+ var _this = this;
+ this.loading.loading += 1;
+ return OC.Router.registerLoadedCallback(function() {
+ return _this.post('init', {}, function(json) {
+ _this.loading.loading -= 1;
+ _this.updateModels(json.data);
+ _this.$rootScope.$broadcast('triggerHideRead');
+ return _this.setInitialized(true);
+ }, null, true);
+ });
+ };
+
+ PersistenceNews.prototype.loadFeed = function(type, id, latestFeedId, latestTimestamp, limit) {
+ var data,
+ _this = this;
+ if (limit == null) {
+ limit = 20;
+ }
+ data = {
+ type: type,
+ id: id,
+ latestFeedId: latestFeedId,
+ latestTimestamp: latestTimestamp,
+ limit: limit
+ };
+ this.loading.loading += 1;
+ return this.post('loadfeed', data, function(json) {
+ _this.loading.loading -= 1;
+ return _this.updateModels(json.data);
+ });
+ };
+
+ PersistenceNews.prototype.createFeed = function(feedUrl, folderId, onSuccess, onError) {
+ var data,
+ _this = this;
+ data = {
+ feedUrl: feedUrl,
+ folderId: folderId
+ };
+ return this.post('createfeed', data, function(json) {
+ onSuccess(json.data);
+ return _this.updateModels(json.data);
+ }, onError);
+ };
+
+ PersistenceNews.prototype.deleteFeed = function(feedId, onSuccess) {
+ var data;
+ data = {
+ feedId: feedId
+ };
+ return this.post('deletefeed', data, onSuccess);
+ };
+
+ PersistenceNews.prototype.moveFeedToFolder = function(feedId, folderId) {
+ var data;
+ data = {
+ feedId: feedId,
+ folderId: folderId
+ };
+ return this.post('movefeedtofolder', data);
+ };
+
+ PersistenceNews.prototype.createFolder = function(folderName, onSuccess) {
+ var data,
+ _this = this;
+ data = {
+ folderName: folderName
+ };
+ return this.post('createfolder', data, function(json) {
+ onSuccess(json.data);
+ return _this.updateModels(json.data);
+ });
+ };
+
+ PersistenceNews.prototype.deleteFolder = function(folderId) {
+ var data;
+ data = {
+ folderId: folderId
+ };
+ return this.post('deletefolder', data);
+ };
+
+ PersistenceNews.prototype.changeFolderName = function(folderId, newFolderName) {
+ var data;
+ data = {
+ folderId: folderId,
+ newFolderName: newFolderName
+ };
+ return this.post('folderName', data);
+ };
+
+ PersistenceNews.prototype.showAll = function(isShowAll) {
+ var data;
+ data = {
+ showAll: isShowAll
+ };
+ return this.post('setshowall', data);
+ };
+
+ PersistenceNews.prototype.markRead = function(itemId, isRead) {
+ var data, status;
+ if (isRead) {
+ status = 'read';
+ } else {
+ status = 'unread';
+ }
+ data = {
+ itemId: itemId,
+ status: status
+ };
+ return this.post('setitemstatus', data);
+ };
+
+ PersistenceNews.prototype.setImportant = function(itemId, isImportant) {
+ var data, status;
+ if (isImportant) {
+ status = 'important';
+ } else {
+ status = 'unimportant';
+ }
+ data = {
+ itemId: itemId,
+ status: status
+ };
+ return this.post('setitemstatus', data);
+ };
+
+ PersistenceNews.prototype.collapseFolder = function(folderId, value) {
+ var data;
+ data = {
+ folderId: folderId,
+ opened: value
+ };
+ return this.post('collapsefolder', data);
+ };
+
+ PersistenceNews.prototype.updateFeed = function(feedId) {
+ var data,
+ _this = this;
+ data = {
+ feedId: feedId
+ };
+ return this.post('updatefeed', data, function(json) {
+ return _this.updateModels(json.data);
+ });
+ };
+
+ PersistenceNews.prototype.setAllItemsRead = function(feedId, mostRecentItemId) {
+ var data;
+ data = {
+ feedId: feedId,
+ mostRecentItemId: mostRecentItemId
+ };
+ return this.post('setallitemsread', data);
+ };
+
+ return PersistenceNews;
+
+ })(Persistence);
+ return PersistenceNews;
+ }
+ ]);
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_Loading', function() {
+ var Loading;
+ return Loading = (function() {
+
+ function Loading() {
+ this.loading = 0;
+ }
+
+ return Loading;
+
+ })();
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('Loading', [
+ '_Loading', function(_Loading) {
+ return new _Loading();
+ }
+ ]);
+
+ angular.module('News').factory('ActiveFeed', [
+ '_ActiveFeed', 'Publisher', function(_ActiveFeed, Publisher) {
+ var model;
+ model = new _ActiveFeed();
+ Publisher.subscribeTo('activeFeed', model);
+ return model;
+ }
+ ]);
+
+ angular.module('News').factory('ShowAll', [
+ '_ShowAll', 'Publisher', function(_ShowAll, Publisher) {
+ var model;
+ model = new _ShowAll();
+ Publisher.subscribeTo('showAll', model);
+ return model;
+ }
+ ]);
+
+ angular.module('News').factory('StarredCount', [
+ '_StarredCount', 'Publisher', function(_StarredCount, Publisher) {
+ var model;
+ model = new _StarredCount();
+ Publisher.subscribeTo('starredCount', model);
+ return model;
+ }
+ ]);
+
+ angular.module('News').factory('FeedModel', [
+ '_FeedModel', 'Publisher', function(_FeedModel, Publisher) {
+ var model;
+ model = new _FeedModel();
+ Publisher.subscribeTo('feeds', model);
+ return model;
+ }
+ ]);
+
+ angular.module('News').factory('FolderModel', [
+ '_FolderModel', 'Publisher', function(_FolderModel, Publisher) {
+ var model;
+ model = new _FolderModel();
+ Publisher.subscribeTo('folders', model);
+ return model;
+ }
+ ]);
+
+ angular.module('News').factory('ItemModel', [
+ '_ItemModel', 'Publisher', 'Cache', 'FeedType', function(_ItemModel, Publisher, Cache, FeedType) {
+ var model;
+ model = new _ItemModel(Cache, FeedType);
+ Publisher.subscribeTo('items', model);
+ return model;
+ }
+ ]);
+
+ angular.module('News').factory('Cache', [
+ '_Cache', 'FeedType', 'FeedModel', 'FolderModel', function(_Cache, FeedType, FeedModel, FolderModel) {
+ return new _Cache(FeedType, FeedModel, FolderModel);
+ }
+ ]);
+
+ angular.module('News').factory('PersistenceNews', [
+ '_PersistenceNews', '$http', '$rootScope', 'Loading', 'Publisher', function(_PersistenceNews, $http, $rootScope, Loading, Publisher) {
+ return new _PersistenceNews($http, $rootScope, Loading, Publisher);
+ }
+ ]);
+
+ angular.module('News').factory('GarbageRegistry', [
+ '_GarbageRegistry', 'ItemModel', function(_GarbageRegistry, ItemModel) {
+ return new _GarbageRegistry(ItemModel);
+ }
+ ]);
+
+ angular.module('News').factory('Publisher', [
+ '_Publisher', function(_Publisher) {
+ return new _Publisher();
+ }
+ ]);
+
+ angular.module('News').factory('OPMLParser', [
+ '_OPMLParser', function(_OPMLParser) {
+ return new _OPMLParser();
+ }
+ ]);
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('FeedType', function() {
+ var feedType;
+ return feedType = {
+ Feed: 0,
+ Folder: 1,
+ Starred: 2,
+ Subscriptions: 3,
+ Shared: 4
+ };
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ 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 ($outline.attr('type') !== void 0) {
+ 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;
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_FolderModel', [
+ 'Model', function(Model, $rootScope) {
+ var FolderModel;
+ FolderModel = (function(_super) {
+
+ __extends(FolderModel, _super);
+
+ function FolderModel() {
+ FolderModel.__super__.constructor.call(this);
+ }
+
+ return FolderModel;
+
+ })(Model);
+ return FolderModel;
+ }
+ ]);
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_ActiveFeed', function() {
+ var ActiveFeed;
+ ActiveFeed = (function() {
+
+ function ActiveFeed() {
+ this.id = 0;
+ this.type = 3;
+ }
+
+ ActiveFeed.prototype.handle = function(data) {
+ this.id = data.id;
+ return this.type = data.type;
+ };
+
+ return ActiveFeed;
+
+ })();
+ return ActiveFeed;
+ });
+
+ /*
+ # ownCloud - News app
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or later.
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_Publisher', function() {
+ var Publisher;
+ Publisher = (function() {
+
+ function Publisher() {
+ this.subscriptions = {};
+ }
+
+ Publisher.prototype.subscribeTo = function(type, object) {
+ var _base;
+ (_base = this.subscriptions)[type] || (_base[type] = []);
+ return this.subscriptions[type].push(object);
+ };
+
+ Publisher.prototype.publish = function(type, message) {
+ var subscriber, _i, _len, _ref, _results;