diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-07 00:39:13 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-07 00:39:13 +0100 |
commit | 9325aafb84476c779b96eb9260c69a0144e55bc8 (patch) | |
tree | 01a822aa6afd4dc78b8e04dd6d514836bc6367d3 /coffee | |
parent | 2c7f779af5d902d1e323c0cec8e35a184e519de0 (diff) |
spaces to tabs
Diffstat (limited to 'coffee')
-rw-r--r-- | coffee/Makefile | 12 | ||||
-rw-r--r-- | coffee/grunt.coffee | 112 | ||||
-rw-r--r-- | coffee/lib/owncloud.coffee | 24 | ||||
-rw-r--r-- | coffee/lib/services/publisher.coffee | 74 | ||||
-rw-r--r-- | coffee/lib/services/request.coffee | 86 | ||||
-rw-r--r-- | coffee/lib/services/router.coffee | 2 |
6 files changed, 157 insertions, 153 deletions
diff --git a/coffee/Makefile b/coffee/Makefile index 8ca06f068..966a6ba76 100644 --- a/coffee/Makefile +++ b/coffee/Makefile @@ -2,15 +2,15 @@ all: watch deps: - cd $(CURDIR) - npm install --save-dev + cd $(CURDIR) + npm install --save-dev watch: compile - $(CURDIR)/node_modules/.bin/grunt --config $(CURDIR)/grunt.coffee run + $(CURDIR)/node_modules/.bin/grunt --config $(CURDIR)/grunt.coffee run compile: - mkdir -p $(CURDIR)/build - $(CURDIR)/node_modules/.bin/grunt --config $(CURDIR)/grunt.coffee compile + mkdir -p $(CURDIR)/build + $(CURDIR)/node_modules/.bin/grunt --config $(CURDIR)/grunt.coffee compile clean: - rm -rf $(CURDIR)/build + rm -rf $(CURDIR)/build diff --git a/coffee/grunt.coffee b/coffee/grunt.coffee index 28cd48462..538babc1f 100644 --- a/coffee/grunt.coffee +++ b/coffee/grunt.coffee @@ -1,60 +1,64 @@ module.exports = (grunt) -> + + grunt.loadNpmTasks('grunt-contrib-coffee') - grunt.loadNpmTasks('grunt-contrib-coffee') + grunt.initConfig + + meta: + pkg: '<json:package.json>' + version: '<%= meta.pkg.version %>' + banner: '/**\n' + + ' * <%= meta.pkg.description %> - v<%= meta.version %>\n' + + ' *\n' + + '<% _.forEach(meta.pkg.contributors, function(contributor){ %>' + + ' * Copyright (c) <%= grunt.template.today("yyyy") %> - ' + + '<%= contributor.name %> <<%= contributor.email %>>\n' + + '<% }) %>' + + ' *\n' + + ' * This file is licensed under the Affero General Public License version 3 or later.\n' + + ' * See the COPYING-README file\n' + + ' *\n' + + ' */' + prefix: '(function(angular, $, OC, oc_requesttoken){' + suffix: '})(window.angular, jQuery, OC, oc_requesttoken);' + build: 'build/' + production: '../js/' - grunt.initConfig + concat: + app: + src: [ + '<banner:meta.banner>' + '<banner:meta.prefix>' + '<%= meta.build %>main.js' + '<banner:meta.suffix>' + ] + dest: '<%= meta.production %>app.js' + owncloud: + src: ['lib/owncloud.coffee', 'lib/services/*.coffee'] + dest: '<%= meta.build %>owncloud.coffee' + news: + src: [ + 'app.coffee' + 'services/*.coffee' + 'controllers/*.coffee' + 'directives/*.coffee' + 'filters/*.coffee' + ] + dest: '<%= meta.build %>news.coffee' + + coffee: + compile: + files: + '<%= meta.build %>main.js': [ + '<%= meta.build %>owncloud.coffee' + '<%= meta.build %>news.coffee' + ] - meta: - pkg: '<json:package.json>' - version: '<config:meta.pkg.version>' - banner: '/*! <%= meta.pkg.description %> - v<%= meta.version %> - ' + - '<%= grunt.template.today("yyyy-mm-dd") %>\n' + - ' * https://github.com/owncloud/apps\n' + - '<% _.forEach(meta.pkg.contributors, function(contributor){ %>' + - ' * Copyright (c) <%= grunt.template.today("yyyy") %> ' + - '<%= contributor.name %> <<%= contributor.email %>>\n' + - '<% };) %>' + - ' * Licensed AGPL \n' + - ' */' - prefix: '(function(angular, $, OC, oc_requesttoken){' - suffix: '})(window.angular, jQuery, OC, oc_requesttoken);' - build: 'build/' - production: '../js/' + watch: + app: + files: './**/*.coffee', + tasks: 'compile' - concat: - app: - src: [ - '<banner:meta.prefix>' - '<%= meta.build %>main.js' - '<banner:meta.suffix>' - ] - dest: '<%= meta.production %>app.js' - owncloud: - src: ['lib/owncloud.coffee', 'lib/services/*.coffee'] - dest: '<%= meta.build %>owncloud.coffee' - news: - src: [ - 'app.coffee' - 'services/*.coffee' - 'controllers/*.coffee' - 'directives/*.coffee' - 'filters/*.coffee' - ] - dest: '<%= meta.build %>news.coffee' - coffee: - compile: - files: - '<%= meta.build %>main.js': [ - '<%= meta.build %>owncloud.coffee' - '<%= meta.build %>news.coffee' - ] - - watch: - app: - files: './**/*.coffee', - tasks: 'compile' - - - grunt.registerTask('run', 'watch') - grunt.registerTask('compile', 'concat:owncloud concat:news coffee concat:app') + grunt.registerTask('run', 'watch') + grunt.registerTask('compile', 'concat:owncloud concat:news coffee concat:app') diff --git a/coffee/lib/owncloud.coffee b/coffee/lib/owncloud.coffee index bd10650d5..c4cc2a336 100644 --- a/coffee/lib/owncloud.coffee +++ b/coffee/lib/owncloud.coffee @@ -14,16 +14,16 @@ ### angular.module('OC', []).config ['$httpProvider', ($httpProvider) -> - # Always send the CSRF token by default - $httpProvider.defaults.get['requesttoken'] = oc_requesttoken - $httpProvider.defaults.post['requesttoken'] = oc_requesttoken - - # needed because crap PHP does not understand JSON - $httpProvider.defaults.post['Content-Type'] = 'application/x-www-form-urlencoded' - $httpProvider.defaults.get['Content-Type'] = 'application/x-www-form-urlencoded' - $httpProvider.defaults.transformRequest = (data) -> - if angular.isDefined(data) - return data - else - return $.param(data) + # Always send the CSRF token by default + $httpProvider.defaults.get['requesttoken'] = oc_requesttoken + $httpProvider.defaults.post['requesttoken'] = oc_requesttoken + + # needed because crap PHP does not understand JSON + $httpProvider.defaults.post['Content-Type'] = 'application/x-www-form-urlencoded' + $httpProvider.defaults.get['Content-Type'] = 'application/x-www-form-urlencoded' + $httpProvider.defaults.transformRequest = (data) -> + if angular.isDefined(data) + return data + else + return $.param(data) ]
\ No newline at end of file diff --git a/coffee/lib/services/publisher.coffee b/coffee/lib/services/publisher.coffee index 39d4ddd43..4d8788726 100644 --- a/coffee/lib/services/publisher.coffee +++ b/coffee/lib/services/publisher.coffee @@ -15,40 +15,40 @@ angular.module('OC').factory '_Publisher', -> - class Publisher - - constructor: -> - @subscriptions = {} - - - # Use this to subscribe to a certain hashkey in the returned json data - # dictionary. - # If you send JSON from the server, you'll receive something like this - # - # { - # data: { - # modelName: { - # create: [{id: 1, name: 'john'}, {id: 2, name: 'ron'}], - # update: [], - # delete: [] - # } - # } - # } - # - # To get the array ['one', 'two'] passed to your model, just subscribe - # to the key: - # Publisher.subscribeModelTo('modelName', myModelInstance) - # - subscribeModelTo: (model, name) -> - @subscriptions[name] or= [] - @subscriptions[name].push(model) - - - # This will publish data from the server to all registered subscribers - # The parameter 'name' is the name under which subscribers have registered - publishDataTo: (data, name) -> - for subscriber in @subscriptions[name] || [] - subscriber.handle(data) - - - return Publisher
\ No newline at end of file + class Publisher + + constructor: -> + @subscriptions = {} + + + # Use this to subscribe to a certain hashkey in the returned json data + # dictionary. + # If you send JSON from the server, you'll receive something like this + # + # { + # data: { + # modelName: { + # create: [{id: 1, name: 'john'}, {id: 2, name: 'ron'}], + # update: [], + # delete: [] + # } + # } + # } + # + # To get the array ['one', 'two'] passed to your model, just subscribe + # to the key: + # Publisher.subscribeModelTo('modelName', myModelInstance) + # + subscribeModelTo: (model, name) -> + @subscriptions[name] or= [] + @subscriptions[name].push(model) + + + # This will publish data from the server to all registered subscribers + # The parameter 'name' is the name under which subscribers have registered + publishDataTo: (data, name) -> + for subscriber in @subscriptions[name] || [] + subscriber.handle(data) + + + return Publisher
\ No newline at end of file diff --git a/coffee/lib/services/request.coffee b/coffee/lib/services/request.coffee index 16f6db5cc..15b4b9013 100644 --- a/coffee/lib/services/request.coffee +++ b/coffee/lib/services/request.coffee @@ -11,64 +11,64 @@ angular.module('OC').factory '_Request', -> - class Request + class Request - constructor: (@_$http, @_$rootScope, @_publisher, @_token, @_router) -> - @_initialized = false - @_shelvedRequests = [] + constructor: (@_$http, @_$rootScope, @_publisher, @_token, @_router) -> + @_initialized = false + @_shelvedRequests = [] - @_$rootScope.$on 'routesLoaded', => - @_executeShelvedRequests() - @_initialized = true - @_shelvedRequests = [] + @_$rootScope.$on 'routesLoaded', => + @_executeShelvedRequests() + @_initialized = true + @_shelvedRequests = [] - request: (route, routeParams={}, data={}, onSuccess=null, onFailure=null, config={}) -> - # if routes are not ready yet, save the request - if not @_initialized - @_shelveRequest(route, routeParams, data, method, config) - return + request: (route, routeParams={}, data={}, onSuccess=null, onFailure=null, config={}) -> + # if routes are not ready yet, save the request + if not @_initialized + @_shelveRequest(route, routeParams, data, method, config) + return - url = @_router.generate(route, routeParams) + url = @_router.generate(route, routeParams) - defaultConfig = - method: 'GET' - url: url - data: data + defaultConfig = + method: 'GET' + url: url + data: data - # overwrite default values from passed in config - for key, value of config - defaultConfig[key] = value + # overwrite default values from passed in config + for key, value of config + defaultConfig[key] = value - @_$http(config) - .success (data, status, headers, config) => - if onSuccess - onSuccess(data, status, headers, config) + @_$http(config) + .success (data, status, headers, config) => + if onSuccess + onSuccess(data, status, headers, config) - # publish data to models - for name, value of data.data - @publisher.publishDataTo(name, value) + # publish data to models + for name, value of data.data + @publisher.publishDataTo(name, value) - .error (data, status, headers, config) -> - if onFailure - onFailure(data, status, headers, config) + .error (data, status, headers, config) -> + if onFailure + onFailure(data, status, headers, config) - _shelveRequest: (route, routeParams, data, method, config) -> - request = - route: route - routeParams: routeParams - data: data - config: config - method: method + _shelveRequest: (route, routeParams, data, method, config) -> + request = + route: route + routeParams: routeParams + data: data + config: config + method: method - @_shelvedRequests.push(request) + @_shelvedRequests.push(request) - _executeShelvedRequests: -> - for req in @_shelvedRequests - @post(req.route, req.routeParams, req.data, req.method, req.config) + _executeShelvedRequests: -> + for req in @_shelvedRequests + @post(req.route, req.routeParams, req.data, req.method, req.config) - return Request + return Request diff --git a/coffee/lib/services/router.coffee b/coffee/lib/services/router.coffee index ace9596cf..71ed24332 100644 --- a/coffee/lib/services/router.coffee +++ b/coffee/lib/services/router.coffee @@ -13,4 +13,4 @@ # Inject router into angular to make testing easier ### angular.module('OC').factory 'Router', -> - return OC.Router
\ No newline at end of file + return OC.Router
\ No newline at end of file |