allow to change the explore service url

This commit is contained in:
Bernhard Posselt 2014-11-19 18:13:43 +01:00
Родитель 53443fd177
Коммит b6a4a8a29b
7 изменённых файлов: 74 добавлений и 15 удалений

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

@ -27,6 +27,8 @@
$('#news input[name="news-feed-fetcher-timeout"]');
var maxSizeInput =
$('#news input[name="news-max-size"]');
var exploreUrlInput =
$('#news input[name="news-explore-url"]');
var savedMessage = $('#news-saved-message');
var saved = function () {
@ -47,6 +49,7 @@
var maxRedirects = maxRedirectsInput.val();
var feedFetcherTimeout = feedFetcherTimeoutInput.val();
var maxSize = maxSizeInput.val();
var exploreUrl = exploreUrlInput.val();
var useCronUpdates = useCronUpdatesInput.is(':checked');
var data = {
@ -56,7 +59,8 @@
maxRedirects: parseInt(maxRedirects, 10),
feedFetcherTimeout: parseInt(feedFetcherTimeout, 10),
maxSize: parseInt(maxSize, 10),
useCronUpdates: useCronUpdates
useCronUpdates: useCronUpdates,
exploreUrl: exploreUrl
};
var url = OC.generateUrl('/apps/news/admin');
@ -76,6 +80,7 @@
maxSizeInput.val(data.maxSize);
feedFetcherTimeoutInput.val(data.feedFetcherTimeout);
useCronUpdatesInput.prop('checked', data.useCronUpdates);
exploreUrlInput.val(data.exploreUrl);
});
};

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

@ -30,10 +30,13 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
$provide.constant('SCROLL_TIMEOUT', 0.1);
// make sure that the CSRF header is only sent to the ownCloud domain
$provide.factory('CSRFInterceptor', function ($q, BASE_URL) {
$provide.factory('CSRFInterceptor', function ($q, BASE_URL, $window) {
return {
request: function (config) {
if (config.url.indexOf(BASE_URL) === 0) {
var domain =
$window.location.href.split($window.location.pathname)[0];
if (config.url.indexOf(BASE_URL) === 0 ||
config.url.indexOf(domain) === 0) {
config.headers.requesttoken = csrfToken;
}
@ -102,8 +105,31 @@ app.config(function ($routeProvider, $provide, $httpProvider) {
controller: 'ExploreController as Explore',
templateUrl: 'explore.html',
resolve: {
sites: /* @ngInject */ function ($http, BASE_URL) {
return $http.get(BASE_URL + '/explore');
sites: /* @ngInject */ function (
$http, $q, BASE_URL, Publisher, SettingsResource) {
var deferred = $q.defer();
$http.get(BASE_URL + '/settings').then(function (data) {
Publisher.publishAll(data);
var url = SettingsResource.get('exploreUrl');
var language = SettingsResource.get('language');
return $http({
url: url,
method: 'GET',
params: {
lang: language
}
});
}).then(function (data) {
console.log(data);
deferred.resolve(data.data);
}, function () {
deferred.reject();
});
return deferred.promise;
}
},
type: feedType.EXPLORE

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

@ -28,10 +28,13 @@ app.config(["$routeProvider", "$provide", "$httpProvider", function ($routeProvi
$provide.constant('SCROLL_TIMEOUT', 0.1);
// make sure that the CSRF header is only sent to the ownCloud domain
$provide.factory('CSRFInterceptor', ["$q", "BASE_URL", function ($q, BASE_URL) {
$provide.factory('CSRFInterceptor', ["$q", "BASE_URL", "$window", function ($q, BASE_URL, $window) {
return {
request: function (config) {
if (config.url.indexOf(BASE_URL) === 0) {
var domain =
$window.location.href.split($window.location.pathname)[0];
if (config.url.indexOf(BASE_URL) === 0 ||
config.url.indexOf(domain) === 0) {
config.headers.requesttoken = csrfToken;
}
@ -100,8 +103,31 @@ app.config(["$routeProvider", "$provide", "$httpProvider", function ($routeProvi
controller: 'ExploreController as Explore',
templateUrl: 'explore.html',
resolve: {
sites: /* @ngInject */ ["$http", "BASE_URL", function ($http, BASE_URL) {
return $http.get(BASE_URL + '/explore');
sites: /* @ngInject */ ["$http", "$q", "BASE_URL", "Publisher", "SettingsResource", function (
$http, $q, BASE_URL, Publisher, SettingsResource) {
var deferred = $q.defer();
$http.get(BASE_URL + '/settings').then(function (data) {
Publisher.publishAll(data);
var url = SettingsResource.get('exploreUrl');
var language = SettingsResource.get('language');
return $http({
url: url,
method: 'GET',
params: {
lang: language
}
});
}).then(function (data) {
console.log(data);
deferred.resolve(data.data);
}, function () {
deferred.reject();
});
return deferred.promise;
}]
},
type: feedType.EXPLORE
@ -395,7 +421,7 @@ app.controller('ContentController',
app.controller('ExploreController', ["sites", "$rootScope", function (sites, $rootScope) {
'use strict';
this.sites = sites.data;
this.sites = sites;
this.subscribeTo = function (url) {
@ -1737,7 +1763,8 @@ app.service('SettingsResource', ["$http", "BASE_URL", function ($http, BASE_URL)
showAll: false,
compact: false,
oldestFirst: false,
preventReadOnScroll: false
preventReadOnScroll: false,
exploreUrl: ''
};
this.defaultLanguageCode = 'en';
this.supportedLanguageCodes = [

2
js/build/app.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -10,7 +10,7 @@
app.controller('ExploreController', function (sites, $rootScope) {
'use strict';
this.sites = sites.data;
this.sites = sites;
this.subscribeTo = function (url) {

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

@ -17,7 +17,8 @@ app.service('SettingsResource', function ($http, BASE_URL) {
showAll: false,
compact: false,
oldestFirst: false,
preventReadOnScroll: false
preventReadOnScroll: false,
exploreUrl: ''
};
this.defaultLanguageCode = 'en';
this.supportedLanguageCodes = [

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

@ -30,7 +30,7 @@ describe('ExploreController', function () {
it('should expose sites', inject(function () {
expect(controller.sites).toBe(sites.data);
expect(controller.sites).toBe(sites);
}));