var $__build_47_app__ = function () {
'use strict';
var __moduleName = 'build/app';
(function (window, document, angular, $, OC, csrfToken, undefined) {
'use strict';
var app = angular.module('News', [
'ngRoute',
'ngSanitize',
'ngAnimate'
]);
app.config([
'$routeProvider',
'$provide',
'$httpProvider',
function ($routeProvider, $provide, $httpProvider) {
'use strict';
var feedType = {
FEED: 0,
FOLDER: 1,
STARRED: 2,
SUBSCRIPTIONS: 3,
SHARED: 4
};
$provide.constant('REFRESH_RATE', 60);
$provide.constant('ITEM_BATCH_SIZE', 50);
$provide.constant('BASE_URL', OC.generateUrl('/apps/news'));
$provide.constant('FEED_TYPE', feedType);
$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');
var getResolve = function (type) {
return {
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',
templateUrl: 'content.html',
resolve: getResolve(feedType.SUBSCRIPTIONS)
}).when('/items/starred', {
controller: 'ContentController',
templateUrl: 'content.html',
resolve: getResolve(feedType.STARRED)
}).when('/items/feeds/:id', {
controller: 'ContentController',
templateUrl: 'content.html',
resolve: getResolve(feedType.FEED)
}).when('/items/folders/:id', {
controller: 'ContentController',
templateUrl: 'content.html',
resolve: getResolve(feedType.FOLDER)
}).otherwise({ redirectTo: '/items' });
}
]);
app.run([
'$rootScope',
'$location',
'$http',
'$q',
'$interval',
'Loading',
'ItemResource',
'FeedResource',
'FolderResource',
'Settings',
'Publisher',
'BASE_URL',
'FEED_TYPE',
'REFRESH_RATE',
function ($rootScope, $location, $http, $q, $interval, Loading, ItemResource, FeedResource, FolderResource, Settings, Publisher, BASE_URL, FEED_TYPE, REFRESH_RATE) {
'use strict';
Loading.setLoading('global', true);
Publisher.subscribe(ItemResource).toChannels('items', 'newestItemId', 'starred');
Publisher.subscribe(FolderResource).toChannels('folders');
Publisher.subscribe(FeedResource).toChannels('feeds');
Publisher.subscribe(Settings).toChannels('settings');