summaryrefslogtreecommitdiffstats
path: root/coffee
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-02-07 11:49:30 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-02-07 11:49:55 +0100
commita31a6b8467ed89f9128b06bc470648c1de0215da (patch)
treededab8582a2ec0eba4a5891b9c5a8622d74e8a29 /coffee
parent810fa35a1cc6af84d78cac74b21c78df27f77280 (diff)
migrated to grunt 4.0
Diffstat (limited to 'coffee')
-rw-r--r--coffee/Gruntfile.coffee49
-rw-r--r--coffee/app.coffee12
-rw-r--r--coffee/grunt.coffee64
-rw-r--r--coffee/lib/owncloud.coffee10
-rw-r--r--coffee/lib/services/model.coffee131
-rw-r--r--coffee/lib/services/publisher.coffee4
-rw-r--r--coffee/lib/services/request.coffee4
-rw-r--r--coffee/lib/services/router.coffee4
-rw-r--r--coffee/package.json47
-rw-r--r--coffee/services/activefeed.coffee8
-rw-r--r--coffee/services/cache.coffee13
-rw-r--r--coffee/services/feedmodel.coffee6
-rw-r--r--coffee/services/feedtype.coffee6
-rw-r--r--coffee/services/foldermodel.coffee6
14 files changed, 122 insertions, 242 deletions
diff --git a/coffee/Gruntfile.coffee b/coffee/Gruntfile.coffee
index a01f34e84..ca90ffc5f 100644
--- a/coffee/Gruntfile.coffee
+++ b/coffee/Gruntfile.coffee
@@ -1,6 +1,22 @@
+###
+# ownCloud news app
+#
+# @author Alessandro Cosentino
+# @author Bernhard Posselt
+# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+#
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
+# See the COPYING-README file
+#
+###
+
module.exports = (grunt) ->
grunt.loadNpmTasks('grunt-contrib-coffee')
+ grunt.loadNpmTasks('grunt-coffeelint')
grunt.initConfig
@@ -25,13 +41,10 @@ module.exports = (grunt) ->
production: '../js/'
concat:
+ options:
+ banner: '<%= meta.banner %>\n'
app:
- src: [
- '<banner:meta.banner>'
- '<banner:meta.prefix>'
- '<%= meta.build %>main.js'
- '<banner:meta.suffix>'
- ]
+ src: '<%= meta.build %>main.js'
dest: '<%= meta.production %>app.js'
owncloud:
src: ['lib/owncloud.coffee', 'lib/services/*.coffee']
@@ -53,6 +66,21 @@ module.exports = (grunt) ->
'<%= meta.build %>owncloud.coffee'
'<%= meta.build %>news.coffee'
]
+ coffeelintOptions:
+ 'no_tabs':
+ 'level': 'ignore'
+ 'indentation':
+ 'level': 'ignore'
+
+ coffeelint:
+ app: [
+ 'app.coffee'
+ 'services/*.coffee'
+ 'controllers/*.coffee'
+ 'directives/*.coffee'
+ 'filters/*.coffee'
+ 'lib/**/*.coffee'
+ ]
watch:
app:
@@ -61,4 +89,11 @@ module.exports = (grunt) ->
grunt.registerTask('run', 'watch')
- grunt.registerTask('compile', 'concat:owncloud concat:news coffee concat:app')
+ grunt.registerTask('compile', [
+ 'coffeelint'
+ 'concat:owncloud'
+ 'concat:news'
+ 'coffee'
+ 'concat:app'
+ ]
+ )
diff --git a/coffee/app.coffee b/coffee/app.coffee
index fb3589dbd..59f921577 100644
--- a/coffee/app.coffee
+++ b/coffee/app.coffee
@@ -1,10 +1,14 @@
###
-# ownCloud - News app
+# ownCloud news app
#
+# @author Alessandro Cosentino
# @author Bernhard Posselt
+# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###
@@ -30,9 +34,9 @@ $(document).ready ->
# and thus clearing the scroll cache
$(this).keyup (e) ->
if (e.which == 116) || (e.which == 82 && e.ctrlKey)
- document.location.reload(true);
+ document.location.reload(true)
return false
# click on upload button should trigger the file input
$('#browselink').click ->
- $('#file_upload_start').trigger('click');
+ $('#file_upload_start').trigger('click')
diff --git a/coffee/grunt.coffee b/coffee/grunt.coffee
deleted file mode 100644
index a01f34e84..000000000
--- a/coffee/grunt.coffee
+++ /dev/null
@@ -1,64 +0,0 @@
-module.exports = (grunt) ->
-
- grunt.loadNpmTasks('grunt-contrib-coffee')
-
- grunt.initConfig
-
- meta:
- pkg: grunt.file.readJSON('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/'
-
- 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'
- ]
-
- 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..30d593536 100644
--- a/coffee/lib/owncloud.coffee
+++ b/coffee/lib/owncloud.coffee
@@ -4,7 +4,9 @@
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###
@@ -19,8 +21,10 @@ angular.module('OC', []).config ['$httpProvider', ($httpProvider) ->
$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.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
diff --git a/coffee/lib/services/model.coffee b/coffee/lib/services/model.coffee
deleted file mode 100644
index 7466505a7..000000000
--- a/coffee/lib/services/model.coffee
+++ /dev/null
@@ -1,131 +0,0 @@
-###
-# ownCloud
-#
-# @author Bernhard Posselt
-# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
-#
-# This file is licensed under the Affero General Public License version 3 or later.
-# See the COPYING-README file
-#
-###
-
-angular.module('OC').factory '_Model', ->
-
- # Parent model: inherit your model from this object
- class Model
-
- constructor: ->
- @foreignKeys = {}
- @data = []
- @ids = {}
-
-
- 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['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 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)
-
-
- # @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)
-
-
- _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)
-
-
- # @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)
-
- # 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 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]
-
-
- return Model \ No newline at end of file
diff --git a/coffee/lib/services/publisher.coffee b/coffee/lib/services/publisher.coffee
index 4d8788726..03559e37e 100644
--- a/coffee/lib/services/publisher.coffee
+++ b/coffee/lib/services/publisher.coffee
@@ -4,7 +4,9 @@
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###
diff --git a/coffee/lib/services/request.coffee b/coffee/lib/services/request.coffee
index 15b4b9013..b3a0cf7a5 100644
--- a/coffee/lib/services/request.coffee
+++ b/coffee/lib/services/request.coffee
@@ -4,7 +4,9 @@
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###
diff --git a/coffee/lib/services/router.coffee b/coffee/lib/services/router.coffee
index 71ed24332..a04763585 100644
--- a/coffee/lib/services/router.coffee
+++ b/coffee/lib/services/router.coffee
@@ -4,7 +4,9 @@
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###
diff --git a/coffee/package.json b/coffee/package.json
index 0c528493f..adb6417aa 100644
--- a/coffee/package.json
+++ b/coffee/package.json
@@ -1,24 +1,27 @@
{
- "name": "owncloud-news-app",
- "description": "ownCloud RSS reader app",
- "version": "0.0.1",
- "author": "ownCloud <owncloud@kde.org>",
- "private": true,
- "contributors": [
- {
- "name": "Alessandro Cosentino",
- "email": "cosenal@gmail.com"
- },
- {
- "name": "Bernhard Posselt",
- "email": "nukeawhale@gmail.com"
- }
- ],
- "devDependencies": {
- "grunt": "~0.3.17",
- "coffee-script": "~1.4.0",
- "grunt-contrib-coffee": "~0.3.2",
- "grunt-testacular": "~0.2.2"
- },
- "engine": "node >= 0.8"
+ "name": "owncloud-news-app",
+ "description": "ownCloud RSS reader app",
+ "version": "0.0.1",
+ "author": "ownCloud <owncloud@kde.org>",
+ "private": true,
+ "contributors": [
+ {
+ "name": "Alessandro Cosentino",
+ "email": "cosenal@gmail.com"
+ },
+ {
+ "name": "Bernhard Posselt",
+ "email": "nukeawhale@gmail.com"
+ }
+ ],
+ "devDependencies": {
+ "grunt": "~0.4.0rc7",
+ "coffee-script": "~1.4.0",
+ "grunt-contrib-coffee": "~0.4.0rc7",
+ "grunt-testacular": "~0.2.2",
+ "grunt-contrib-concat": "~0.1.2rc6",
+ "grunt-contrib-watch": "~0.2.0rc7",
+ "grunt-coffeelint": "0.0.4"
+ },
+ "engine": "node >= 0.8"
}
diff --git a/coffee/services/activefeed.coffee b/coffee/services/activefeed.coffee
index 3ebb34634..8ba160e4f 100644
--- a/coffee/services/activefeed.coffee
+++ b/coffee/services/activefeed.coffee
@@ -1,10 +1,14 @@
###
-# ownCloud - News app
+# ownCloud news app
#
+# @author Alessandro Cosentino
# @author Bernhard Posselt
+# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###
diff --git a/coffee/services/cache.coffee b/coffee/services/cache.coffee
index 194fca3f1..06e6ab5f3 100644
--- a/coffee/services/cache.coffee
+++ b/coffee/services/cache.coffee
@@ -1,3 +1,16 @@
+###
+# ownCloud
+#
+# @author Bernhard Posselt
+# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+#
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
+# See the COPYING-README file
+#
+###
+
angular.module('News').factory '_Cache', ->
class Cache
diff --git a/coffee/services/feedmodel.coffee b/coffee/services/feedmodel.coffee
index 94af1727f..ff7f9c148 100644
--- a/coffee/services/feedmodel.coffee
+++ b/coffee/services/feedmodel.coffee
@@ -1,10 +1,12 @@
###
-# ownCloud - News app
+# ownCloud
#
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###
diff --git a/coffee/services/feedtype.coffee b/coffee/services/feedtype.coffee
index a14970649..55ca0419e 100644
--- a/coffee/services/feedtype.coffee
+++ b/coffee/services/feedtype.coffee
@@ -1,10 +1,12 @@
###
-# ownCloud - News app
+# ownCloud
#
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###
diff --git a/coffee/services/foldermodel.coffee b/coffee/services/foldermodel.coffee
index 279caffd9..46f3b5cfa 100644
--- a/coffee/services/foldermodel.coffee
+++ b/coffee/services/foldermodel.coffee
@@ -1,10 +1,12 @@
###
-# ownCloud - News app
+# ownCloud
#
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
###