summaryrefslogtreecommitdiffstats
path: root/js/app
diff options
context:
space:
mode:
Diffstat (limited to 'js/app')
-rw-r--r--js/app/App.js10
-rw-r--r--js/app/Config.js105
-rw-r--r--js/app/Run.js109
-rw-r--r--js/app/app.coffee57
-rw-r--r--js/app/controllers/appcontroller.coffee42
-rw-r--r--js/app/controllers/feedcontroller.coffee147
-rw-r--r--js/app/controllers/itemcontroller.coffee84
-rw-r--r--js/app/controllers/settingscontroller.coffee63
-rw-r--r--js/app/directives/audio.coffee43
-rw-r--r--js/app/directives/autofocus.coffee6
-rw-r--r--js/app/directives/bindunsafehtml.coffee26
-rw-r--r--js/app/directives/clickfocus.coffee44
-rw-r--r--js/app/directives/clickslidetoggle.coffee82
-rw-r--r--js/app/directives/draggable.coffee32
-rw-r--r--js/app/directives/droppable.coffee44
-rw-r--r--js/app/directives/forwardclick.coffee35
-rw-r--r--js/app/directives/itemshortcuts.coffee148
-rw-r--r--js/app/directives/newsclickscroll.coffee39
-rw-r--r--js/app/directives/newsitemscroll.coffee81
-rw-r--r--js/app/directives/pulltorefresh.coffee39
-rw-r--r--js/app/directives/readfile.coffee44
-rw-r--r--js/app/directives/tooltip.coffee27
-rw-r--r--js/app/directives/translate.coffee31
-rw-r--r--js/app/directives/undonotification.coffee60
-rw-r--r--js/app/filters/trusturl.coffee25
-rw-r--r--js/app/services/activefeed.coffee48
-rw-r--r--js/app/services/businesslayer/businesslayer.coffee44
-rw-r--r--js/app/services/businesslayer/feedbusinesslayer.coffee196
-rw-r--r--js/app/services/businesslayer/folderbusinesslayer.coffee208
-rw-r--r--js/app/services/businesslayer/itembusinesslayer.coffee131
-rw-r--r--js/app/services/businesslayer/starredbusinesslayer.coffee56
-rw-r--r--js/app/services/businesslayer/subscriptionsbusinesslayer.coffee68
-rw-r--r--js/app/services/compact.coffee38
-rw-r--r--js/app/services/existserror.coffee32
-rw-r--r--js/app/services/feedtype.coffee31
-rw-r--r--js/app/services/language.coffee104
-rw-r--r--js/app/services/loading.coffee50
-rw-r--r--js/app/services/model.coffee128
-rw-r--r--js/app/services/models/feedmodel.coffee174
-rw-r--r--js/app/services/models/foldermodel.coffee142
-rw-r--r--js/app/services/models/itemmodel.coffee123
-rw-r--r--js/app/services/newestitem.coffee39
-rw-r--r--js/app/services/notification.coffee26
-rw-r--r--js/app/services/notimplementederror.coffee35
-rw-r--r--js/app/services/opmlparser.coffee79
-rw-r--r--js/app/services/persistence.coffee491
-rw-r--r--js/app/services/publisher.coffee64
-rw-r--r--js/app/services/queries/biggerthan.coffee46
-rw-r--r--js/app/services/queries/biggerthanequal.coffee45
-rw-r--r--js/app/services/queries/contains.coffee54
-rw-r--r--js/app/services/queries/doesnotcontain.coffee54
-rw-r--r--js/app/services/queries/equal.coffee54
-rw-r--r--js/app/services/queries/lessthan.coffee45
-rw-r--r--js/app/services/queries/lessthanequal.coffee45
-rw-r--r--js/app/services/queries/maximum.coffee46
-rw-r--r--js/app/services/queries/minimum.coffee46
-rw-r--r--js/app/services/queries/query.coffee49
-rw-r--r--js/app/services/queries/unequal.coffee54
-rw-r--r--js/app/services/request.coffee117
-rw-r--r--js/app/services/services.coffee66
-rw-r--r--js/app/services/showall.coffee44
-rw-r--r--js/app/services/starredcount.coffee44
-rw-r--r--js/app/services/statusflag.coffee31
-rw-r--r--js/app/services/unreadcountformatter.coffee28
-rw-r--r--js/app/services/utils.coffee26
65 files changed, 224 insertions, 4400 deletions
diff --git a/js/app/App.js b/js/app/App.js
new file mode 100644
index 000000000..4f6a47a96
--- /dev/null
+++ b/js/app/App.js
@@ -0,0 +1,10 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+var app = angular.module('News', ['ngRoute', 'ngSanitize']); \ No newline at end of file
diff --git a/js/app/Config.js b/js/app/Config.js
new file mode 100644
index 000000000..b922e0aa1
--- /dev/null
+++ b/js/app/Config.js
@@ -0,0 +1,105 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.config(function ($routeProvider, $provide, $httpProvider) {
+ 'use strict';
+
+ var feedType = {
+ FEED: 0,
+ FOLDER: 1,
+ STARRED: 2,
+ SUBSCRIPTIONS: 3,
+ SHARED: 4
+ };
+
+ // constants
+ $provide.constant('REFRESH_RATE', 60); // seconds
+ $provide.constant('ITEM_BATCH_SIZE', 50); // how many items to autopage by
+ $provide.constant('BASE_URL', OC.generateUrl('/apps/news'));
+ $provide.constant('FEED_TYPE', feedType);
+
+ // make sure that the CSRF header is only sent to the ownCloud domain
+ $provide.factory('CSRFInterceptor', function ($q, BASE_URL) {
+ return {
+ request: function (config) {
+ if (config.url.indexOf(BASE_URL) === 0) {
+ config.headers.requesttoken = csrfToken;
+ }
+
+ return config || $q.when(config);
+ }
+ };
+ });
+ $httpProvider.interceptors.push('CSRFInterceptor');
+
+ // routing
+ var getResolve = function (type) {
+ return {
+ // request to items also returns feeds
+ data: [
+ '$http',
+ '$route',
+ '$q',
+ 'BASE_URL',
+ 'ITEM_BATCH_SIZE',
+ function ($http, $route, $q, BASE_URL, ITEM_BATCH_SIZE) {
+
+ var parameters = {
+ type: type,
+ limit: ITEM_BATCH_SIZE
+ };
+
+ if ($route.current.params.id !== undefined) {
+ parameters.id = $route.current.params.id;
+ }
+
+ var deferred = $q.defer();
+
+ $http({
+ url: BASE_URL + '/items',
+ method: 'GET',
+ params: parameters
+ }).success(function (data) {
+ deferred.resolve(data);
+ });
+
+ return deferred.promise;
+ }
+ ]
+ };
+ };
+
+ $routeProvider
+ .when('/items', {
+ controller: 'ContentController as Content',
+ templateUrl: 'content.html',
+ resolve: getResolve(feedType.SUBSCRIPTIONS),
+ type: feedType.SUBSCRIPTIONS
+ })
+ .when('/items/starred', {
+ controller: 'ContentController as Content',
+ templateUrl: 'content.html',
+ resolve: getResolve(feedType.STARRED),
+ type: feedType.STARRED
+ })
+ .when('/items/feeds/:id', {
+ controller: 'ContentController as Content',
+ templateUrl: 'content.html',
+ resolve: getResolve(feedType.FEED),
+ type: feedType.FEED
+ })
+ .when('/items/folders/:id', {
+ controller: 'ContentController as Content',
+ templateUrl: 'content.html',
+ resolve: getResolve(feedType.FOLDER),
+ type: feedType.FOLDER
+ });
+
+});
+
diff --git a/js/app/Run.js b/js/app/Run.js
new file mode 100644
index 000000000..33c75c2b4
--- /dev/null
+++ b/js/app/Run.js
@@ -0,0 +1,109 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.run(function ($rootScope, $location, $http, $q, $interval, Loading,
+ ItemResource, FeedResource, FolderResource, SettingsResource,
+ Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) {
+ 'use strict';
+
+ // show Loading screen
+ Loading.setLoading('global', true);
+
+ // listen to keys in returned queries to automatically distribute the
+ // incoming values to models
+ Publisher.subscribe(ItemResource).toChannels(['items', 'newestItemId',
+ 'starred']);
+ Publisher.subscribe(FolderResource).toChannels(['folders']);
+ Publisher.subscribe(FeedResource).toChannels(['feeds']);
+ Publisher.subscribe(SettingsResource).toChannels(['settings']);
+
+ // load feeds, settings and last read feed
+ var settingsDeferred = $q.defer();
+ $http.get(BASE_URL + '/settings').success(function (data) {
+ Publisher.publishAll(data);
+ settingsDeferred.resolve();
+ });
+
+ var activeFeedDeferred = $q.defer();
+ var path = $location.path();
+ $http.get(BASE_URL + '/feeds/active').success(function (data) {
+ var url;
+
+ switch (data.activeFeed.type) {
+
+ case FEED_TYPE.FEED:
+ url = '/items/feeds/' + data.activeFeed.id;
+ break;
+
+ case FEED_TYPE.FOLDER:
+ url = '/items/folders/' + data.activeFeed.id;
+ break;
+
+ case FEED_TYPE.STARRED:
+ url = '/items/starred';
+ break;
+
+ default:
+ url = '/items';
+ }
+
+ // only redirect if url is empty or faulty
+ if (!/^\/items(\/(starred|feeds\/\d+|folders\/\d+))?\/?$/.test(path)) {
+ $location.path(url);
+ }
+
+ activeFeedDeferred.resolve();
+ });
+
+ var folderDeferred = $q.defer();
+ $http.get(BASE_URL + '/folders').success(function (data) {
+ Publisher.publishAll(data);
+ folderDeferred.resolve();
+ });
+
+ var feedDeferred = $q.defer();
+ $http.get(BASE_URL + '/feeds').success(function (data) {
+ Publisher.publishAll(data);
+ feedDeferred.resolve();
+ });
+
+ // disable loading if all initial requests finished
+ $q.all(
+ [
+ settingsDeferred.promise,
+ activeFeedDeferred.promise,
+ feedDeferred.promise,
+ folderDeferred.promise
+ ]
+ )
+ .then(function () {
+ Loading.setLoading('global', false);
+ });
+
+ // refresh feeds and folders
+ $interval(function () {
+ $http.get(BASE_URL + '/feeds');
+ $http.get(BASE_URL + '/folders');
+ }, REFRESH_RATE * 1000);
+
+
+ $rootScope.$on('$routeChangeStart', function () {
+ Loading.setLoading('content', true);
+ });
+
+ $rootScope.$on('$routeChangeSuccess', function () {
+ Loading.setLoading('content', false);
+ });
+
+ // in case of wrong id etc show all items
+ $rootScope.$on('$routeChangeError', function () {
+ $location.path('/items');
+ });
+
+}); \ No newline at end of file
diff --git a/js/app/app.coffee b/js/app/app.coffee
deleted file mode 100644
index 0c5763bd2..000000000
--- a/js/app/app.coffee
+++ /dev/null
@@ -1,57 +0,0 @@
-###
-
-ownCloud - News
-
-@author Bernhard Posselt
-@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-License as published by the Free Software Foundation; either
-version 3 of the License, or any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-
-You should have received a copy of the GNU Affero General Public
-License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-###
-
-
-# app main
-angular.module('News', ['ui']).config ['$provide', '$httpProvider',
-($provide, $httpProvider) ->
- $provide.value 'Config', config =
- markReadTimeout: 500
- scrollTimeout: 500
- feedUpdateInterval: 1000*60*3 # miliseconds
- itemBatchSize: 40
- undoTimeout: 1000*10 # miliseconds
- # the autoPageFactor defines how many articles must be left
- # before it starts autopaging
- autoPageFactor: 30
-
- # Always send the CSRF token by default
- $httpProvider.defaults.headers.common['requesttoken'] = oc_requesttoken
-]
-
-angular.module('News').run ['Persistence', 'Config',
-(Persistence, Config) ->
-
- setInterval ->
- Persistence.getAllFeeds(null, false)
- Persistence.getAllFolders(null, false)
- , Config.feedUpdateInterval
-]
-
-
-$(document).ready ->
- # this is used to forces browser to reload content after refreshing
- # and thus clearing the scroll cache
- $(this).keyup (e) ->
- if (e.which == 116) || (e.which == 82 && e.ctrlKey)
- document.location.reload(true)
- return false
diff --git a/js/app/controllers/appcontroller.coffee b/js/app/controllers/appcontroller.coffee
deleted file mode 100644
index bcb256077..000000000
--- a/js/app/controllers/appcontroller.coffee
+++ /dev/null
@@ -1,42 +0,0 @@
-###
-
-ownCloud - News
-
-@author Alessandro Cosentino
-@copyright 2013 Alessandro Cosentino cosenal@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').controller 'AppController',
-['$scope', 'Persistence', 'FeedBusinessLayer',
-($scope, Persistence, FeedBusinessLayer) ->
-
- class AppController
-
- constructor: (@_$scope, @_persistence, @_feedBusinessLayer) ->
-
- @_$scope.initialized = false
- @_$scope.feedBusinessLayer = @_feedBusinessLayer
-
- successCallback = =>
- @_$scope.initialized = true
-
- @_persistence.init().then(successCallback)
-
- return new AppController($scope, Persistence, FeedBusinessLayer)
-
-] \ No newline at end of file
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee
deleted file mode 100644
index 43186e689..000000000
--- a/js/app/controllers/feedcontroller.coffee
+++ /dev/null
@@ -1,147 +0,0 @@
-###
-
-ownCloud - News
-
-@author Bernhard Posselt
-@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-License as published by the Free Software Foundation; either
-version 3 of the License, or any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-
-You should have received a copy of the GNU Affero General Public
-License along with this library. If not, see <http://www.gnu.org/licenses/>.
-
-###
-
-
-angular.module('News').controller 'FeedController',
-['$scope', '_ExistsError', 'Persistence', 'FolderBusinessLayer',
-'FeedBusinessLayer', 'SubscriptionsBusinessLayer', 'StarredBusinessLayer',
-'unreadCountFormatter', 'ActiveFeed', 'FeedType', '$window',
-($scope, _ExistsError, Persistence, FolderBusinessLayer, FeedBusinessLayer,
-SubscriptionsBusinessLayer, StarredBusinessLayer, unreadCountFormatter,
-ActiveFeed, FeedType, $window) ->
-
-
- class FeedController
-
- constructor: (@_$scope, @_persistence, @_folderBusinessLayer,
- @_feedBusinessLayer, @_subscriptionsBusinessLayer,
- @_starredBusinessLayer, @_unreadCountFormatter,
- @_activeFeed, @_feedType, @_$window) ->
-
- @_isAddingFolder = false
- @_isAddingFeed = false
-
- # bind internal stuff to scope
- @_$scope.folderBusinessLayer = @_folderBusinessLayer
- @_$scope.feedBusinessLayer = @_feedBusinessLayer
- @_$scope.subscriptionsBusinessLayer = @_subscriptionsBusinessLayer
- @_$scope.starredBusinessLayer = @_starredBusinessLayer
- @_$scope.unreadCountFormatter = @_unreadCountFormatter
-
- @_$scope.edit = (feed) ->
- feed.editing = true
- feed.originalValue = feed.title
-
- @_$scope.cancel = (feed) ->
- feed.editing = false
- feed.title = feed.originalValue
-
- @_$scope.getTotalUnreadCount = =>
- # also update title based on unreadcount
- count = @_subscriptionsBusinessLayer.getUnreadCount(0)
-
- # dont do this for other dom elements
- # the title is some kind of exception since its always there
- # and it has nothing to do with the body structure
- if @_$scope.translations and @_$scope.translations.appName
- appName = @_$scope.translations.appName
- else
- appName = ''
-
- if count > 0
- titleCount = @_unreadCountFormatter(count)
- title = appName + ' (' + titleCount + ') | ownCloud'
- else
- title = appName + ' | ownCloud'
-
- # only update title when it changed to prevent highlighting the
- # tab
- if @_$window.document.title != title
- @_$window.document.title = title
-
- return count
-
- @_$scope.isAddingFolder = =>
- return @_isAddingFolder
-
- @_$scope.isAddingFeed = =>
- return @_isAddingFeed
-
- @_$scope.addFeed = (feedUrl, parentFolderId=0) =>
- @_$scope.feedExistsError = false
-
- try
- @_isAddingFeed = true
- # set folder to open
- if parentFolderId != 0
- @_folderBusinessLayer.open(parentFolderId)
- @_$scope.feedUrl = ''
- @_feedBusinessLayer.create feedUrl, parentFolderId
- # on success
- , (data) =>
- @_isAddingFeed = false
- @_feedBusinessLayer.load(data['feeds'][0].id)
- # on error
- , =>
- @_isAddingFeed = false
-
- catch error
- if error instanceof _ExistsError
- @_$scope.feedExistsError = true
- @_isAddingFeed = false
-
-
- @_$scope.addFolder = (folderName) =>
- @_$scope.folderExistsError = false
-
- try
- @_isAddingFolder = true
- @_folderBusinessLayer.create folderName
-
- # on success
- , (data) =>
- @_$scope.folderName = ''
- @_$scope.addNewFolder = false
- @_isAddingFolder = false
- activeId = data['folders'][0].id
- @_$scope.folderId = @_folderBusinessLayer.getById(activeId)
- # on error
- , =>
- @_isAddingFolder = false
-
- catch error
- if error instanceof _ExistsError
- @_$scope.folderExistsError = true
- @_isAddingFolder = false
-
-
- @_$scope.$on 'moveFeedToFolder', (scope, data) =>
- @_feedBusinessLayer.move(data.feedId, data.folderId)
-
-
-
- return new FeedController($scope, Persistence, FolderBusinessLayer,
- FeedBusinessLayer, SubscriptionsBusinessLayer,
- StarredBusinessLayer, unreadCountFormatter,
- ActiveFeed, FeedType, $window)
-
-] \ No newline at end of file
diff --git a/js/app/controllers/itemcontroller.coffee b/js/app/controllers/itemcontroller.coffee
deleted file mode 100644
index f381baede..000000000
--- a/js/app/controllers/itemcontroller.coffee
+++ /dev/null