summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appinfo/routes.php5
-rw-r--r--controller/usersettingscontroller.php16
-rw-r--r--js/Gruntfile.coffee4
-rw-r--r--js/app/controllers/feedcontroller.coffee13
-rw-r--r--js/app/controllers/itemcontroller.coffee10
-rw-r--r--js/app/services/language.coffee (renamed from js/app/controllers/controllers.coffee)31
-rw-r--r--js/app/services/persistence.coffee10
-rw-r--r--js/app/services/services.coffee5
-rw-r--r--js/public/app.js178
-rw-r--r--js/tests/controllers/feedcontrollerSpec.coffee9
-rw-r--r--js/tests/controllers/itemcontrollerSpec.coffee16
-rw-r--r--js/tests/services/languageSpec.coffee40
-rw-r--r--js/tests/services/persistenceSpec.coffee11
-rw-r--r--tests/unit/controller/UserSettingsControllerTest.php21
14 files changed, 255 insertions, 114 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 40cf23149..9acce6661 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -193,6 +193,11 @@ $this->create('news_usersettings_read_hide', '/usersettings/read/hide')->post()-
}
);
+$this->create('news_usersettings_language', '/usersettings/language')->get()->action(
+ function($params){
+ App::main('UserSettingsController', 'getLanguage', $params, new DIContainer());
+ }
+);
diff --git a/controller/usersettingscontroller.php b/controller/usersettingscontroller.php
index 88f3d07f4..4cb088255 100644
--- a/controller/usersettingscontroller.php
+++ b/controller/usersettingscontroller.php
@@ -77,4 +77,20 @@ class UserSettingsController extends Controller {
}
+ /**
+ * @IsAdminExemption
+ * @IsSubAdminExemption
+ * @Ajax
+ */
+ public function getLanguage(){
+ $language = $this->api->getTrans()->findLanguage();
+
+ $params = array(
+ 'language' => $language
+ );
+ return $this->renderJSON($params);
+ }
+
+
+
} \ No newline at end of file
diff --git a/js/Gruntfile.coffee b/js/Gruntfile.coffee
index 285ee47f0..503e16738 100644
--- a/js/Gruntfile.coffee
+++ b/js/Gruntfile.coffee
@@ -66,8 +66,8 @@ module.exports = (grunt) ->
src: '<%= meta.production %>app.js'
dest: ''
wrapper: [
- '(function(angular, $, hex_md5, undefined){\n\n'
- '\n})(window.angular, jQuery, hex_md5);'
+ '(function(angular, $, hex_md5, moment, undefined){\n\n'
+ '\n})(window.angular, jQuery, hex_md5, moment);'
]
coffeelint:
diff --git a/js/app/controllers/feedcontroller.coffee b/js/app/controllers/feedcontroller.coffee
index 8f9f4e7b6..e9171a455 100644
--- a/js/app/controllers/feedcontroller.coffee
+++ b/js/app/controllers/feedcontroller.coffee
@@ -21,9 +21,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').factory '_FeedController',
-['_ExistsError',
-(_ExistsError)->
+angular.module('News').controller 'FeedController',
+['$scope', '_ExistsError', 'Persistence', 'FolderBl', 'FeedBl',
+'SubscriptionsBl', 'StarredBl', 'unreadCountFormatter',
+($scope, _ExistsError, Persistence, FolderBl, FeedBl, SubscriptionsBl,
+StarredBl, unreadCountFormatter) ->
+
class FeedController
@@ -105,6 +108,8 @@ angular.module('News').factory '_FeedController',
@_$scope.$on 'moveFeedToFolder', (scope, data) =>
@_feedBl.move(data.feedId, data.folderId)
- return FeedController
+
+ return new FeedController($scope, Persistence, FolderBl, FeedBl,
+ SubscriptionsBl, StarredBl, unreadCountFormatter)
] \ No newline at end of file
diff --git a/js/app/controllers/itemcontroller.coffee b/js/app/controllers/itemcontroller.coffee
index 514186393..71bbb13be 100644
--- a/js/app/controllers/itemcontroller.coffee
+++ b/js/app/controllers/itemcontroller.coffee
@@ -21,12 +21,14 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').factory '_ItemController', ->
+angular.module('News').controller 'ItemController',
+['$scope', 'ItemBl', 'FeedModel', 'FeedLoading', 'FeedBl', 'Language',
+($scope, ItemBl, FeedModel, FeedLoading, FeedBl, Language) ->
class ItemController
constructor: (@_$scope, @_itemBl, @_feedModel, @_feedLoading,
- @_feedBl) ->
+ @_feedBl, @_language) ->
@_$scope.itemBl = @_itemBl
@_$scope.feedBl = @_feedBl
@@ -42,4 +44,6 @@ angular.module('News').factory '_ItemController', ->
return ''
- return ItemController \ No newline at end of file
+ return new ItemController($scope, ItemBl, FeedModel, FeedLoading, FeedBl,
+ Language)
+] \ No newline at end of file
diff --git a/js/app/controllers/controllers.coffee b/js/app/services/language.coffee
index 8a73549cf..85a405fc7 100644
--- a/js/app/controllers/controllers.coffee
+++ b/js/app/services/language.coffee
@@ -20,19 +20,18 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-angular.module('News').controller 'FeedController',
-['$scope', '_FeedController', 'Persistence', 'FolderBl', 'FeedBl',
-'SubscriptionsBl', 'StarredBl', 'unreadCountFormatter',
-($scope, _FeedController, Persistence, FolderBl, FeedBl, SubscriptionsBl,
-StarredBl, unreadCountFormatter)->
-
- return new _FeedController($scope, Persistence, FolderBl, FeedBl,
- SubscriptionsBl, StarredBl, unreadCountFormatter)
-]
-
-angular.module('News').controller 'ItemController',
-['$scope', '_ItemController', 'ItemBl', 'FeedModel', 'FeedLoading', 'FeedBl',
-($scope, _ItemController, ItemBl, FeedModel, FeedLoading, FeedBl)->
-
- return new _ItemController($scope, ItemBl, FeedModel, FeedLoading, FeedBl)
-] \ No newline at end of file
+angular.module('News').factory 'Language', ->
+
+ class Language
+
+ constructor: ->
+ @_language = 'en'
+
+ handle: (data) ->
+ @_language = data.language
+
+ getLanguage: ->
+ return @_language
+
+
+ return new Language()
diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee
index b6a9cd2c6..2b627301a 100644
--- a/js/app/services/persistence.coffee
+++ b/js/app/services/persistence.coffee
@@ -47,7 +47,8 @@ angular.module('News').factory '_Persistence', ->
@getAllFeeds(triggerHideRead)
@userSettingsRead(triggerHideRead)
@getStarredItems(triggerHideRead)
-
+ @userSettingsLanguage()
+
###
ITEM CONTROLLER
@@ -320,6 +321,13 @@ angular.module('News').factory '_Persistence', ->
@_request.post 'news_usersettings_read_hide', data
+ userSettingsLanguage: (callback=null) ->
+ callback or= ->
+ data =
+ onSuccess: callback
+ @_request.get 'news_usersettings_language', data
+
+
_triggerHideRead: ->
@_$rootScope.$broadcast('triggerHideRead')
diff --git a/js/app/services/services.coffee b/js/app/services/services.coffee
index 83e76e20e..19e4b990d 100644
--- a/js/app/services/services.coffee
+++ b/js/app/services/services.coffee
@@ -82,14 +82,15 @@ angular.module('News').factory 'ItemModel', ['_ItemModel', (_ItemModel) ->
angular.module('News').factory 'Publisher',
['_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel',
-'FolderModel', 'FeedModel',
+'FolderModel', 'FeedModel', 'Language',
(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel,
-FolderModel, FeedModel) ->
+FolderModel, FeedModel, Language) ->
# register items at publisher to automatically add incoming items
publisher = new _Publisher()
publisher.subscribeObjectTo(ActiveFeed, 'activeFeed')
publisher.subscribeObjectTo(ShowAll, 'showAll')
+ publisher.subscribeObjectTo(Language, 'language')
publisher.subscribeObjectTo(StarredCount, 'starred')
publisher.subscribeObjectTo(FolderModel, 'folders')
publisher.subscribeObjectTo(FeedModel, 'feeds')
diff --git a/js/public/app.js b/js/public/app.js
index ea1974247..0f4912af6 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -1,4 +1,4 @@
-(function(angular, $, hex_md5, undefined){
+(function(angular, $, hex_md5, moment, undefined){
/**
* ownCloud News App - v0.0.1
@@ -218,45 +218,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
angular.module('News').controller('FeedController', [
- '$scope', '_FeedController', 'Persistence', 'FolderBl', 'FeedBl', 'SubscriptionsBl', 'StarredBl', 'unreadCountFormatter', function($scope, _FeedController, Persistence, FolderBl, FeedBl, SubscriptionsBl, StarredBl, unreadCountFormatter) {
- return new _FeedController($scope, Persistence, FolderBl, FeedBl, SubscriptionsBl, StarredBl, unreadCountFormatter);
- }
- ]);
-
- angular.module('News').controller('ItemController', [
- '$scope', '_ItemController', 'ItemBl', 'FeedModel', 'FeedLoading', 'FeedBl', function($scope, _ItemController, ItemBl, FeedModel, FeedLoading, FeedBl) {
- return new _ItemController($scope, ItemBl, FeedModel, FeedLoading, FeedBl);
- }
- ]);
-
-}).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('_FeedController', [
- '_ExistsError', function(_ExistsError) {
+ '$scope', '_ExistsError', 'Persistence', 'FolderBl', 'FeedBl', 'SubscriptionsBl', 'StarredBl', 'unreadCountFormatter', function($scope, _ExistsError, Persistence, FolderBl, FeedBl, SubscriptionsBl, StarredBl, unreadCountFormatter) {
var FeedController;
FeedController = (function() {
@@ -350,7 +312,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return FeedController;
})();
- return FeedController;
+ return new FeedController($scope, Persistence, FolderBl, FeedBl, SubscriptionsBl, StarredBl, unreadCountFormatter);
}
]);
@@ -380,40 +342,43 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
- angular.module('News').factory('_ItemController', function() {
- var ItemController;
-
- ItemController = (function() {
- function ItemController(_$scope, _itemBl, _feedModel, _feedLoading, _feedBl) {
- var _this = this;
-
- this._$scope = _$scope;
- this._itemBl = _itemBl;
- this._feedModel = _feedModel;
- this._feedLoading = _feedLoading;
- this._feedBl = _feedBl;
- this._$scope.itemBl = this._itemBl;
- this._$scope.feedBl = this._feedBl;
- this._$scope.isLoading = function() {
- return _this._feedLoading.isLoading();
- };
- this._$scope.getFeedTitle = function(feedId) {
- var feed;
+ angular.module('News').controller('ItemController', [
+ '$scope', 'ItemBl', 'FeedModel', 'FeedLoading', 'FeedBl', 'Language', function($scope, ItemBl, FeedModel, FeedLoading, FeedBl, Language) {
+ var ItemController;
- feed = _this._feedModel.getById(feedId);
- if (angular.isDefined(feed)) {
- return feed.title;
- } else {
- return '';
- }
- };
- }
+ ItemController = (function() {
+ function ItemController(_$scope, _itemBl, _feedModel, _feedLoading, _feedBl, _language) {
+ var _this = this;
- return ItemController;
+ this._$scope = _$scope;
+ this._itemBl = _itemBl;
+ this._feedModel = _feedModel;
+ this._feedLoading = _feedLoading;
+ this._feedBl = _feedBl;
+ this._language = _language;
+ this._$scope.itemBl = this._itemBl;
+ this._$scope.feedBl = this._feedBl;
+ this._$scope.isLoading = function() {
+ return _this._feedLoading.isLoading();
+ };
+ this._$scope.getFeedTitle = function(feedId) {
+ var feed;
- })();
- return ItemController;
- });
+ feed = _this._feedModel.getById(feedId);
+ if (angular.isDefined(feed)) {
+ return feed.title;
+ } else {
+ return '';
+ }
+ };
+ }
+
+ return ItemController;
+
+ })();
+ return new ItemController($scope, ItemBl, FeedModel, FeedLoading, FeedBl, Language);
+ }
+ ]);
}).call(this);
@@ -1427,6 +1392,54 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
(function() {
+ angular.module('News').factory('Language', function() {
+ var Language;
+
+ Language = (function() {
+ function Language() {
+ this._language = 'en';
+ }
+
+ Language.prototype.handle = function(data) {
+ return this._language = data.language;
+ };
+
+ Language.prototype.getLanguage = function() {
+ return this._language;
+ };
+
+ return Language;
+
+ })();
+ return new Language();
+ });
+
+}).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() {
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; };
@@ -2082,7 +2095,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this.getAllFolders(triggerHideRead);
this.getAllFeeds(triggerHideRead);
this.userSettingsRead(triggerHideRead);
- return this.getStarredItems(triggerHideRead);
+ this.getStarredItems(triggerHideRead);
+ return this.userSettingsLanguage();
};
/*
@@ -2463,6 +2477,19 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
return this._request.post('news_usersettings_read_hide', data);
};
+ Persistence.prototype.userSettingsLanguage = function(callback) {
+ var data;
+
+ if (callback == null) {
+ callback = null;
+ }
+ callback || (callback = function() {});
+ data = {
+ onSuccess: callback
+ };
+ return this._request.get('news_usersettings_language', data);
+ };
+
Persistence.prototype._triggerHideRead = function() {
return this._$rootScope.$broadcast('triggerHideRead');
};
@@ -2566,12 +2593,13 @@ 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) {
+ '_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel', 'FolderModel', 'FeedModel', 'Language', function(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel, FolderModel, FeedModel, Language) {
var publisher;
publisher = new _Publisher();
publisher.subscribeObjectTo(ActiveFeed, 'activeFeed');
publisher.subscribeObjectTo(ShowAll, 'showAll');
+ publisher.subscribeObjectTo(Language, 'language');
publisher.subscribeObjectTo(StarredCount, 'starred');
publisher.subscribeObjectTo(FolderModel, 'folders');
publisher.subscribeObjectTo(FeedModel, 'feeds');
@@ -2756,4 +2784,4 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
}).call(this);
-})(window.angular, jQuery, hex_md5); \ No newline at end of file
+})(window.angular, jQuery, hex_md5, moment); \ No newline at end of file
diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee
index b5216db60..e3ecb357b 100644
--- a/js/tests/controllers/feedcontrollerSpec.coffee
+++ b/js/tests/controllers/feedcontrollerSpec.coffee
@@ -30,13 +30,14 @@ describe '_FeedController', ->
@persistence = {}
- beforeEach inject (@_FeedController, @FolderBl, @FeedBl, $rootScope,
+ beforeEach inject ($controller, @FolderBl, @FeedBl, $rootScope,
@unreadCountFormatter, @SubscriptionsBl, @StarredBl) =>
@scope = $rootScope.$new()
+ replace =
+ $scope: @scope
+ Persistence: @persistence
- @controller = new @_FeedController(@scope, @persistence, @FolderBl,
- @FeedBl, @SubscriptionsBl, @StarredBl,
- @unreadCountFormatter)
+ @controller = $controller('FeedController', replace)
diff --git a/js/tests/controllers/itemcontrollerSpec.coffee b/js/tests/controllers/itemcontrollerSpec.coffee
index f95f4a459..d6a33b68e 100644
--- a/js/tests/controllers/itemcontrollerSpec.coffee
+++ b/js/tests/controllers/itemcontrollerSpec.coffee
@@ -21,20 +21,21 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
###
-describe '_ItemController', ->
+describe 'ItemController', ->
beforeEach module 'News'
- beforeEach inject (@_ItemController, @ActiveFeed, @ShowAll, @FeedType,
- @StarredCount, @FeedModel, @FolderModel, @ItemModel,
- @ItemBl, @FeedBl, @FeedLoading) =>
+ beforeEach inject ($controller, @ItemBl, @FeedBl) =>
@scope = {}
@persistence = {
getItems: ->
}
- @controller = new @_ItemController(@scope, @ItemBl, @FeedModel,
- @FeedLoading, @FeedBl)
+
+ replace =
+ $scope: @scope
+ Persistence: @persistence
+ @controller = $controller('ItemController', replace)
it 'should make ItemBl availabe', =>
@@ -43,3 +44,6 @@ describe '_ItemController', ->
it 'should make FeedBl availabe', =>
expect(@scope.feedBl).toBe(@FeedBl)
+
+
+ it 'should '
diff --git a/js/tests/services/languageSpec.coffee b/js/tests/services/languageSpec.coffee
new file mode 100644
index 000000000..526d4ecbc
--- /dev/null
+++ b/js/tests/services/languageSpec.coffee
@@ -0,0 +1,40 @@
+###
+
+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/>.
+
+###
+
+
+describe 'Language', ->
+
+ beforeEach module 'News'
+
+ beforeEach inject (@Language, @FeedType) =>
+ @data =
+ language: 'de'
+
+
+ it 'should be en by default', =>
+ expect(@Language.getLanguage()).toBe('en')
+
+
+ it 'should set the correct feed id', =>
+ @Language.handle(@data)
+ expect(@Language.getLanguage()).toBe('de')
+
diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee
index 28c13b06d..80a95c758 100644
--- a/js/tests/services/persistenceSpec.coffee
+++ b/js/tests/services/persistenceSpec.coffee
@@ -354,7 +354,6 @@ describe '_Persistence', ->
params)
-
it 'should do a proper user settings read hide request', =>
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
params =
@@ -362,4 +361,14 @@ describe '_Persistence', ->
pers.userSettingsReadHide(params.onSuccess)
expect(@req.post).toHaveBeenCalledWith('news_usersettings_read_hide',
+ params)
+
+
+ it 'should do a proper user settings language request', =>
+ pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
+ params =
+ onSuccess: ->
+ pers.userSettingsLanguage(params.onSuccess)
+
+ expect(@req.get).toHaveBeenCalledWith('news_usersettings_language',
params) \ No newline at end of file
diff --git a/tests/unit/controller/UserSettingsControllerTest.php b/tests/unit/controller/UserSettingsControllerTest.php
index a0aa0dff4..99b959db5 100644
--- a/tests/unit/controller/UserSettingsControllerTest.php
+++ b/tests/unit/controller/UserSettingsControllerTest.php
@@ -59,6 +59,11 @@ class UserSettingsControllerTest extends ControllerTestUtility {
}
+ public function testGetLanguageAnnotations(){
+ $this->assertUserSettingsControllerAnnotations('getLanguage');
+ }
+
+
public function testFoldersAnnotations(){
$this->assertUserSettingsControllerAnnotations('read');
}
@@ -109,6 +114,22 @@ class UserSettingsControllerTest extends ControllerTestUtility {
}
+ public function testGetLanguage(){
+ $language = 'de';
+ $lang = $this->getMock('Lang', array('findLanguage'));
+ $lang->expects($this->once())
+ ->method('findLanguage')
+ ->will($this->returnValue($language));
+ $this->api->expects($this->once())
+ ->method('getTrans')
+ ->will($this->returnValue($lang));
+
+ $response = $this->controller->getLanguage();
+ $params = $response->getParams();
+
+ $this->assertEquals($language, $params['language']);
+ $this->assertTrue($response instanceof JSONResponse);
+ }
} \ No newline at end of file