diff options
-rw-r--r-- | README.rst | 2 | ||||
-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/model.coffee | 176 | ||||
-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 | ||||
-rw-r--r-- | js/app.js | 11 | ||||
-rw-r--r-- | l10n/es.php | 11 | ||||
-rw-r--r-- | l10n/sr.php | 41 |
11 files changed, 292 insertions, 259 deletions
diff --git a/README.rst b/README.rst index 487ca6104..015979834 100644 --- a/README.rst +++ b/README.rst @@ -6,7 +6,7 @@ CoffeeScript ------------ To install the nodejs dependencies run :: - make deps + make deps inside the **coffee/** directory. diff --git a/coffee/Makefile b/coffee/Makefile index 966a6ba76..8ca06f068 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 538babc1f..28cd48462 100644 --- a/coffee/grunt.coffee +++ b/coffee/grunt.coffee @@ -1,64 +1,60 @@ module.exports = (grunt) -> - - 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.loadNpmTasks('grunt-contrib-coffee') - 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' - ] + grunt.initConfig - watch: - app: - files: './**/*.coffee', - tasks: 'compile' + 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/' + 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' - grunt.registerTask('run', 'watch') - grunt.registerTask('compile', 'concat:owncloud concat:news coffee concat:app') + 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') diff --git a/coffee/lib/owncloud.coffee b/coffee/lib/owncloud.coffee index c4cc2a336..bd10650d5 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/model.coffee b/coffee/lib/services/model.coffee index a1316e3bb..7466505a7 100644 --- a/coffee/lib/services/model.coffee +++ b/coffee/lib/services/model.coffee @@ -11,121 +11,121 @@ angular.module('OC').factory '_Model', -> - # Parent model: inherit your model from this object - class Model + # Parent model: inherit your model from this object + class Model - constructor: -> - @foreignKeys = {} - @data = [] - @ids = {} + constructor: -> + @foreignKeys = {} + @data = [] + @ids = {} - handle: (data) -> - if data['create'] != undefined - for item in data['create'] - @create(item) + handle: (data) -> + if data['create'] != undefined + for item in data['create'] + @create(item) - if data['update'] != undefined - for item in data['update'] - @update(item) + if data['update'] != undefined + for item in data['update'] + @update(item) - if data['delete'] != undefined - for item in data['delete'] - @delete(item) + if data['delete'] != undefined + for item in data['delete'] + @delete(item) - # @brief add a new foreign key name which caches data by foreign key - # @param string name: the name of the foreign key property on the object - # Foreign keys are caching items in a structure like - # name -> id -> [item1, item2] - hasForeignKey: (name) -> - @foreignKeys[name] = {} + # @brief add a new foreign key name which caches data by foreign key + # @param string name: the name of the foreign key property on the object + # Foreign keys are caching items in a structure like + # name -> id -> [item1, item2] + hasForeignKey: (name) -> + @foreignKeys[name] = {} - # @brief adds a new object to the dataset - # @param object data: the data that we want to store - create: (data) -> - if @ids[data.id] != undefined - @update(data) - else - @data.push(data) - @ids[data.id] = data + # @brief adds a new object to the dataset + # @param object data: the data that we want to store + create: (data) -> + if @ids[data.id] != undefined + @update(data) + else + @data.push(data) + @ids[data.id] = data - # fill indizes of foreign keys - for name, ids of @foreignKeys - id = data[name] - @foreignKeys[name][id] or= [] - @foreignKeys[name][id].push(data) + # fill indizes of foreign keys + for name, ids of @foreignKeys + id = data[name] + @foreignKeys[name][id] or= [] + @foreignKeys[name][id].push(data) - # @brief updates an existing item, the id must not change - # @param object item: the item which should be updated - update: (item) -> - currentItem = @ids[item.id] - for key, value of item - # if the foreignkey changed, we need to update the cache - if @foreignKeys[key] != undefined - if value != currentItem[key] - @_updateForeignKeyCache(key, currentItem, item) - if key != 'id' - currentItem[key] = value + # @brief updates an existing item, the id must not change + # @param object item: the item which should be updated + update: (item) -> + currentItem = @ids[item.id] + for key, value of item + # if the foreignkey changed, we need to update the cache + if @foreignKeys[key] != undefined + if value != currentItem[key] + @_updateForeignKeyCache(key, currentItem, item) + if key != 'id' + currentItem[key] = value - delete: (item) -> - if @getById(item.id) != undefined - @removeById(item.id) + delete: (item) -> + if @getById(item.id) != undefined + @removeById(item.id) - _updateForeignKeyCache: (name, currentItem, toItem) -> - fromValue = currentItem[name] - toValue = toItem[name] - foreignKeyItems = @foreignKeys[name][fromValue] - @_removeForeignKeyCacheItem(foreignKeyItems, currentItem) - @foreignKeys[name][toValue].push(item) + _updateForeignKeyCache: (name, currentItem, toItem) -> + fromValue = currentItem[name] + toValue = toItem[name] + foreignKeyItems = @foreignKeys[name][fromValue] + @_removeForeignKeyCacheItem(foreignKeyItems, currentItem) + @foreignKeys[name][toValue].push(item) - _removeForeignKeyCacheItem: (foreignKeyItems, item) -> - for fkItem, index in foreignKeyItems - if fkItem.id == id - @foreignKeys[key][item[key]].splice(index, 1) + _removeForeignKeyCacheItem: (foreignKeyItems, item) -> + for fkItem, index in foreignKeyItems + if fkItem.id == id + @foreignKeys[key][item[key]].splice(index, 1) - # @brief removes an object - # @param int id: the id of the object - removeById: (id) -> - item = @getById(id) - - # remove from foreign key cache - for key, ids of @foreignKeys - foreignKeyItems = ids[item[key]] - @_removeForeignKeyCacheItem(foreignKeyItems, item) + # @brief removes an object + # @param int id: the id of the object + removeById: (id) -> + item = @getById(id) - # remove from array - for item, index in @data - if item.id == id - @data.splice(index, 1) + # remove from foreign key cache + for key, ids of @foreignKeys + foreignKeyItems = ids[item[key]] + @_removeForeignKeyCacheItem(foreignKeyItems, item) - delete @ids[id] + # remove from array + for item, index in @data + if item.id == id + @data.splice(index, 1) + delete @ids[id] - # @brief returns a data object by its id - # @param int id: the id of the object that we want to fetch - getById: (id) -> - return @ids[id] + # @brief returns a data object by its id + # @param int id: the id of the object that we want to fetch + getById: (id) -> + return @ids[id] - # @brief returns all stored data objects - getAll: -> - return @data + # @brief returns all stored data objects + getAll: -> + return @data - # @brief access the foreign key cache - # @param string foreignKeyName: the name of the foreign key that we want to - # look up - # @param string foreignKeyId: the id from that foreign key that we want to - # get - getAllOfForeignKeyWithId: (foreignKeyName, foreignKeyId) -> - return @foreignKeys[foreignKeyName][foreignKeyId] + # @brief access the foreign key cache + # @param string foreignKeyName: the name of the foreign key that we want to + # look up + # @param string foreignKeyId: the id from that foreign key that we want to + # get + getAllOfForeignKeyWithId: (foreignKeyName, foreignKeyId) -> + return @foreignKeys[foreignKeyName][foreignKeyId] - return Model
\ No newline at end of file + + return Model
\ No newline at end of file diff --git a/coffee/lib/services/publisher.coffee b/coffee/lib/services/publisher.coffee index 4d8788726..39d4ddd43 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 15b4b9013..16f6db5cc 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 71ed24332..ace9596cf 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 @@ -1,14 +1,3 @@ -/** - * ownCloud RSS reader app - v0.0.1 - * - * Copyright (c) 2013 - Alessandro Cosentino <cosenal@gmail.com> - * Copyright (c) 2013 - Bernhard Posselt <nukeawhale@gmail.com> - * - * This file is licensed under the Affero General Public License version 3 or later. - * See the COPYING-README file - * - */ - (function(angular, $, OC, oc_requesttoken){ diff --git a/l10n/es.php b/l10n/es.php index c52d5a7fe..750e1b380 100644 --- a/l10n/es.php +++ b/l10n/es.php @@ -1,4 +1,5 @@ <?php $TRANSLATIONS = array( +"year" => "año", "News" => "Noticias", "no title" => "sin título", "no name" => "sin nombre", @@ -17,15 +18,25 @@ "Delete folder" => "Eliminar carpeta", "Rename folder" => "Renombrar carpeta", "Add Subscription" => "Añadir subcripción", +"Folder under which the feed is being saved" => "Carpeta en la cual se guardaran los feed", +"-- choose folder --" => "-- seleccionar carpeta --", +"Address must not be empty!" => "La direccion no debe estar vacia!", +"Feed exists already!" => "Los feed ya existen!", +"Could not add feed!" => "No se puede agregar feed!", "Address" => "Dirección", "Add" => "Añadir", "Add Folder" => "Añadir carpeta", +"Folder name must not be empty!" => "El nombre de la carpeta no debe estar vacio!", +"Folder exists already!" => "La carpeta ya existe!", +"Folder Name" => "Nombre de carpeta", "Show everything" => "Mostrar todo", "Show only unread" => "Mostrar solo no leídos", "Settings" => "Configuración", "Add feed or folder" => "Añadir fuente o carpeta", "Add Feed/Folder" => "Añadir Fuente/Carpeta", +"Import / Export" => "Importar / Exportar", "Import OPML" => "Importar OPML", +"Export OPML" => "Exportar OPML", "Subscribelet" => "Suscribirse", "Drag this to your browser bookmarks and click on it whenever you want to subscribe to a webpage quickly:" => "Arrastra hacia los favoritos de tu navegador y haz clic en él siempre que quiera suscribirse a una página web con rapidez:", "Subscribe" => "Subscribirse" diff --git a/l10n/sr.php b/l10n/sr.php index 589b78653..8555512a4 100644 --- a/l10n/sr.php +++ b/l10n/sr.php @@ -1,6 +1,43 @@ <?php $TRANSLATIONS = array( -"Share" => "Дељење", +"year" => "година", +"News" => "Вести", +"no title" => "нема наслова", +"no name" => "нема имена", +"no body" => "нема текста", +"subscriptions in ownCloud - News" => "пријаве на ownCloud-у – вести", +"An error occurred" => "Дошло је до грешке", +"Nice! You have subscribed to " => "Лепо! Пријавили сте се на ", +"You had already subscribed to this feed!" => "Већ сте пријављени на овај довод.", +"New articles" => "Нови чланци", +"Mark all read" => "Означи све као прочитано", +"Starred" => "Означено звездицом", +"Share" => "Дели", +"Keep unread" => "Задржи непрочитано", +"Delete feed" => "Обриши довод", +"Collapse" => "Скупи", +"Delete folder" => "Обриши фасциклу", +"Rename folder" => "Преименуј фасциклу", +"Add Subscription" => "Додај пријаву", +"Folder under which the feed is being saved" => "Фасцикла под којом се чува довод", +"-- choose folder --" => "– изаберите фасциклу –", +"Address must not be empty!" => "Адреса не може бити празна.", +"Feed exists already!" => "Довод већ постоји.", +"Could not add feed!" => "Не могу да додам довод.", "Address" => "Адреса", "Add" => "Додај", -"Settings" => "Подешавања" +"Add Folder" => "Додај фасциклу", +"Folder name must not be empty!" => "Име фасцикле не може бити празно.", +"Folder exists already!" => "Фасцикла већ постоји.", +"Folder Name" => "Име фасцикле", +"Show everything" => "Прикажи све", +"Show only unread" => "Прикажи само непрочитане", +"Settings" => "Поставке", +"Add feed or folder" => "Додај довод или фасциклу", +"Add Feed/Folder" => "Додај довод/фасциклу", +"Import / Export" => "Увези/извези", +"Import OPML" => "Увези OPML", +"Export OPML" => "Извези OPML", +"Subscribelet" => "Пријава", +"Drag this to your browser bookmarks and click on it whenever you want to subscribe to a webpage quickly:" => "Превуците ово на траку са обележивачима и кликните кад год желите да бисте се пријавили на веб страницу:", +"Subscribe" => "Пријави ме" ); |