summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/Gruntfile.coffee118
-rw-r--r--js/Makefile58
-rw-r--r--js/README.md38
-rw-r--r--js/app/app.coffee44
-rw-r--r--js/app/services/activefeed.coffee48
-rw-r--r--js/app/services/feedtype.coffee31
-rw-r--r--js/app/services/models/feedmodel.coffee40
-rw-r--r--js/app/services/models/foldermodel.coffee28
-rw-r--r--js/app/services/models/itemmodel.coffee28
-rw-r--r--js/app/services/opmlparser.coffee78
-rw-r--r--js/app/services/persistence.coffee298
-rw-r--r--js/app/services/services.coffee89
-rw-r--r--js/app/services/showall.coffee41
-rw-r--r--js/app/services/starredcount.coffee41
-rw-r--r--js/config/testacular_conf.js98
-rw-r--r--js/package.json33
-rw-r--r--js/public/app.js997
-rw-r--r--js/tests/services/activefeedSpec.coffee52
-rw-r--r--js/tests/services/feedtypeSpec.coffee49
-rw-r--r--js/tests/services/models/feedmodelSpec.coffee46
-rw-r--r--js/tests/services/models/foldermodelSpec.coffee32
-rw-r--r--js/tests/services/models/itemmodelSpec.coffee32
-rw-r--r--js/tests/services/opmlparserSpec.coffee36
-rw-r--r--js/tests/services/persistenceSpec.coffee359
-rw-r--r--js/tests/services/showallSpec.coffee42
-rw-r--r--js/tests/services/starredcountSpec.coffee42
-rw-r--r--js/tests/stubs/modules.js23
-rw-r--r--js/vendor/angular-ui/.gitignore3
-rw-r--r--js/vendor/angular-ui/angular-ui.js1316
-rw-r--r--js/vendor/angular/angular-mocks.js1764
-rw-r--r--js/vendor/angular/angular.js14604
-rw-r--r--js/vendor/jquery-ui/jquery-ui.js14850
-rw-r--r--js/vendor/jquery/jquery.js9597
-rw-r--r--js/vendor/momentjs/moment.js1400
34 files changed, 46355 insertions, 0 deletions
diff --git a/js/Gruntfile.coffee b/js/Gruntfile.coffee
new file mode 100644
index 000000000..3280d94e8
--- /dev/null
+++ b/js/Gruntfile.coffee
@@ -0,0 +1,118 @@
+###
+
+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/>.
+
+###
+
+
+module.exports = (grunt) ->
+
+ grunt.loadNpmTasks('grunt-contrib-concat')
+ grunt.loadNpmTasks('grunt-contrib-watch')
+ grunt.loadNpmTasks('grunt-coffeelint')
+ grunt.loadNpmTasks('grunt-wrap');
+ grunt.loadNpmTasks('grunt-phpunit');
+ grunt.loadNpmTasks('gruntacular');
+
+ grunt.initConfig
+
+ meta:
+ pkg: grunt.file.readJSON('package.json')
+ version: '<%= meta.pkg.version %>'
+ banner: '/**\n' +
+ ' * <%= meta.pkg.description %> - v<%= meta.version %>\n' +
+ ' *\n' +
+ ' * Copyright (c) <%= grunt.template.today("yyyy") %> - ' +
+ '<%= meta.pkg.author.name %> <<%= meta.pkg.author.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' +
+ ' */\n\n'
+ build: 'build/'
+ production: 'public/'
+
+ concat:
+ app:
+ options:
+ banner: '<%= meta.banner %>\n'
+ stripBanners:
+ options: 'block'
+ src: [
+ '<%= meta.build %>app/app.js'
+ '<%= meta.build %>app/directives/*.js'
+ '<%= meta.build %>app/controllers/*.js'
+ '<%= meta.build %>app/services/**/*.js'
+ ]
+ dest: '<%= meta.production %>app.js'
+ wrap:
+ app:
+ src: '<%= meta.production %>app.js'
+ dest: ''
+ wrapper: [
+ '(function(angular, $, undefined){\n\n'
+ '\n})(window.angular, jQuery);'
+ ]
+
+ coffeelint:
+ app: [
+ 'app/**/*.coffee'
+ 'tests/**/*.coffee'
+ ]
+ options:
+ 'no_tabs':
+ 'level': 'ignore'
+ 'indentation':
+ 'level': 'ignore'
+ 'no_trailing_whitespace':
+ 'level': 'warn'
+
+ watch:
+ concat:
+ files: [
+ '<%= meta.build %>app/**/*.js'
+ '<%= meta.build %>tests/**/*.js'
+ ]
+ tasks: 'compile'
+ phpunit:
+ files: '../**/*.php'
+ tasks: 'phpunit'
+
+ testacular:
+ unit:
+ configFile: 'config/testacular_conf.js'
+ continuous:
+ configFile: 'config/testacular_conf.js'
+ singleRun: true
+ browsers: ['PhantomJS']
+ reporters: ['progress', 'junit']
+ junitReporter:
+ outputFile: 'test-results.xml'
+
+ phpunit:
+ classes:
+ dir: '../tests'
+ options:
+ colors: true
+
+
+ grunt.registerTask('run', ['watch:concat'])
+ grunt.registerTask('compile', ['concat', 'wrap', 'coffeelint'])
+ grunt.registerTask('ci', ['testacular:continuous'])
+ grunt.registerTask('testphp', ['watch:phpunit']) \ No newline at end of file
diff --git a/js/Makefile b/js/Makefile
new file mode 100644
index 000000000..2a0b8577d
--- /dev/null
+++ b/js/Makefile
@@ -0,0 +1,58 @@
+# 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/>.
+
+firefox_bin=/usr/bin/firefox
+chrome_bin=/usr/bin/chromium
+coffee=$(CURDIR)/node_modules/coffee-script/bin/coffee
+grunt=$(CURDIR)/node_modules/grunt-cli/bin/grunt
+phantomjs=$(CURDIR)/node_modules/phantomjs/bin/phantomjs
+
+all: compile
+
+deps:
+ cd $(CURDIR)/
+ npm install --deps
+ cd ..
+
+watch: compile
+ $(coffee) --compile --watch --output $(CURDIR)/build/app $(CURDIR)/app/ & \
+ $(coffee) --compile --watch --output $(CURDIR)/build/tests $(CURDIR)/tests/ & \
+ $(grunt) --config $(CURDIR)/Gruntfile.coffee run
+
+testacular: deps
+ export CHROME_BIN=$(chrome_bin) && export FIREFOX_BIN=$(firefox_bin) && \
+ $(grunt) --config $(CURDIR)/Gruntfile.coffee testacular
+
+phpunit:
+ $(grunt) --config $(CURDIR)/Gruntfile.coffee testphp
+
+compile: deps
+ mkdir -p $(CURDIR)/build/app
+ mkdir -p $(CURDIR)/build/tests
+ mkdir -p $(CURDIR)/public
+ $(coffee) --compile --output $(CURDIR)/build/app $(CURDIR)/app/
+ $(coffee) --compile --output $(CURDIR)/build/tests $(CURDIR)/tests/
+ $(grunt) --config $(CURDIR)/Gruntfile.coffee compile
+
+test: deps compile
+ export PHANTOMJS_BIN=$(phantomjs) && \
+ $(grunt) --config $(CURDIR)/Gruntfile.coffee ci
+
+clean:
+ rm -rf $(CURDIR)/build
+ rm -rf $(CURDIR)/test-results.xml
diff --git a/js/README.md b/js/README.md
new file mode 100644
index 000000000..fb497f368
--- /dev/null
+++ b/js/README.md
@@ -0,0 +1,38 @@
+# News
+
+You'll need node.js version > 0.8
+
+## Compile coffeescript
+To compile the coffeescript run:
+
+ make
+
+If you want to autocompile on change run:
+
+ make watch
+
+## Running unittests
+Unittests are run with the testacular:
+
+ make testacular
+
+afterwards the watch command can be run in a new terminal:
+
+ make watch
+
+This will automatically execute unittests when a coffeescript file has been changed and saved.
+
+### PHPUnit
+To run phpunittests once a file changed, simply run
+
+ make phpunit
+
+## Clear compiled folder
+To clear the build/ folder run:
+
+ make clean
+
+## Run js unittests
+To run js unittests with the ci server, use
+
+ make test \ No newline at end of file
diff --git a/js/app/app.coffee b/js/app/app.coffee
new file mode 100644
index 000000000..82a839c8c
--- /dev/null
+++ b/js/app/app.coffee
@@ -0,0 +1,44 @@
+###
+
+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/>.
+
+###
+
+
+# app main
+angular.module('News', ['OC', 'ui']).config ($provide) ->
+ $provide.value 'Config', config =
+ markReadTimeout: 500
+ scrollTimeout: 500
+ feedUpdateInterval: 6000000
+ itemBatchSize: 20
+
+
+angular.module('News').run ['Persistence', (Persistence) ->
+ Persistence.init()
+]
+
+
+$(document).ready ->
+ # this is used to forces browser to reload content after refreshing
+ # and thus clearing the scroll cache
+ $(this).keyup (e) ->
+ if (e.which == 116) || (e.which == 82 && e.ctrlKey)
+ document.location.reload(true)
+ return false
diff --git a/js/app/services/activefeed.coffee b/js/app/services/activefeed.coffee
new file mode 100644
index 000000000..8af9f7573
--- /dev/null
+++ b/js/app/services/activefeed.coffee
@@ -0,0 +1,48 @@
+###
+
+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/>.
+
+###
+
+angular.module('News').factory '_ActiveFeed', ->
+
+ class ActiveFeed
+
+ constructor: ->
+ ###
+ Default value is all feeds
+ ###
+ @_id = 0
+ @_type = 3
+
+
+ handle: (data) ->
+ @_id = data.id
+ @_type = data.type
+
+
+ getType: ->
+ return @_type
+
+
+ getId: ->
+ return @_id
+
+
+ return ActiveFeed
diff --git a/js/app/services/feedtype.coffee b/js/app/services/feedtype.coffee
new file mode 100644
index 000000000..924c2f9aa
--- /dev/null
+++ b/js/app/services/feedtype.coffee
@@ -0,0 +1,31 @@
+###
+
+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/>.
+
+###
+
+
+angular.module('News').factory 'FeedType', ->
+
+ return feedType =
+ Feed: 0
+ Folder: 1
+ Starred: 2
+ Subscriptions: 3
+ Shared: 4 \ No newline at end of file
diff --git a/js/app/services/models/feedmodel.coffee b/js/app/services/models/feedmodel.coffee
new file mode 100644
index 000000000..25cc48d88
--- /dev/null
+++ b/js/app/services/models/feedmodel.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/>.
+
+###
+
+
+angular.module('News').factory '_FeedModel', ['_Model', (_Model) ->
+
+ class FeedModel extends _Model
+
+ constructor: (@_utils) ->
+ super()
+
+
+ add: (item) ->
+ if item.icon == 'url()'
+ item.icon = 'url(' + @_utils.imagePath('news', 'rss.svg') + ')'
+ super(item)
+
+
+
+ return FeedModel
+] \ No newline at end of file
diff --git a/js/app/services/models/foldermodel.coffee b/js/app/services/models/foldermodel.coffee
new file mode 100644
index 000000000..208bd2f4b
--- /dev/null
+++ b/js/app/services/models/foldermodel.coffee
@@ -0,0 +1,28 @@
+###
+
+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/>.
+
+###
+
+angular.module('News').factory '_FolderModel', ['_Model', (_Model) ->
+
+ class FolderModel extends _Model
+
+ return FolderModel
+] \ No newline at end of file
diff --git a/js/app/services/models/itemmodel.coffee b/js/app/services/models/itemmodel.coffee
new file mode 100644
index 000000000..d53f17f15
--- /dev/null
+++ b/js/app/services/models/itemmodel.coffee
@@ -0,0 +1,28 @@
+###
+
+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/>.
+
+###
+
+angular.module('News').factory '_ItemModel', ['_Model', (_Model) ->
+
+ class ItemModel extends _Model
+
+ return ItemModel
+] \ No newline at end of file
diff --git a/js/app/services/opmlparser.coffee b/js/app/services/opmlparser.coffee
new file mode 100644
index 000000000..5154e423c
--- /dev/null
+++ b/js/app/services/opmlparser.coffee
@@ -0,0 +1,78 @@
+###
+
+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/>.
+
+###
+
+angular.module('News').factory '_OPMLParser', ->
+
+ class Feed
+
+ constructor: (@_name, @_url) ->
+
+ getName: ->
+ return @_name
+
+ getUrl: ->
+ return @_url
+
+ isFolder: ->
+ return false
+
+
+ class Folder
+
+ constructor: (@_name) ->
+ @_items = []
+
+ add: (feed) ->
+ @_items.push(feed)
+
+ getItems: ->
+ return @_items
+
+ getName: ->
+ return @_name
+
+ isFolder: ->
+ return true
+
+
+ class OPMLParser
+
+ parseXML: (xml) ->
+ $xml = $($.parseXML(xml))
+ $root = $xml.find('body')
+ structure = new Folder('root')
+ @_recursivelyParse($root, structure)
+ return structure
+
+ _recursivelyParse: ($xml, structure) ->
+ for outline in $xml.children('outline')
+ $outline = $(outline)
+ if angular.isDefined($outline.attr('type'))
+ feed = new Feed($outline.attr('text'), $outline.attr('xmlUrl'))
+ structure.add(feed)
+ else
+ folder = new Folder($outline.attr('text'))
+ structure.add(folder)
+ @_recursivelyParse($outline, folder)
+
+
+ return OPMLParser
diff --git a/js/app/services/persistence.coffee b/js/app/services/persistence.coffee
new file mode 100644
index 000000000..26e547cd6
--- /dev/null
+++ b/js/app/services/persistence.coffee
@@ -0,0 +1,298 @@
+###
+
+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/>.
+
+###
+
+
+angular.module('News').factory '_Persistence', ->
+
+ class Persistence
+
+ constructor: (@_request, @_loading, @_config, @_activeFeed,
+ @_$rootScope) ->
+
+
+ init: ->
+ ###
+ Loads the initial data from the server
+ ###
+ @_loading.increase()
+
+ # items can only be loaded after the active feed is known
+ @getActiveFeed =>
+ @getItems @_activeFeed.getType(), @_activeFeed.getId(), null, =>
+ @_loading.decrease()
+
+ @getAllFolders(@_triggerHideRead)
+ @getAllFeeds(@_triggerHideRead)
+ @userSettingsRead(@_triggerHideRead)
+ @getStarredItems(@_triggerHideRead)
+
+
+ ###
+ ITEM CONTROLLER
+ ###
+ getItems: (type, id, offset, onSuccess, updatedSince=null) ->
+ # TODO
+ if updatedSince != null
+ data =
+ updatedSince: updatedSince
+ type: type
+ id: id
+ else
+ data =
+ limit: @_config.itemBatchSize
+ offset: offset
+ id: id
+ type: type
+
+ @_request.get 'news_items', {}, data, onSuccess
+
+
+ getItemById: (itemId) ->
+ url =
+ itemId: itemId
+
+ @_request.get 'news_item', url
+
+
+ getStarredItems: (onSuccess) ->
+ @_request.get 'news_starred_items', {}, {}, onSuccess
+
+
+ starItem: (itemId) ->
+ ###
+ Stars an item
+ ###
+ url =
+ itemId: itemId
+
+ @_request.post 'news_star_item', url
+
+
+
+ unstarItem: (itemId) ->
+ ###
+ Unstars an item
+ ###
+ url =
+ itemId: itemId
+
+ @_request.post 'news_unstar_item', url
+
+
+ readItem: (itemId) ->
+ ###
+ Sets an item as read
+ ###
+ url =
+ itemId: itemId
+
+ @_request.post 'news_read_item', url
+
+
+
+ unreadItem: (itemId) ->
+ ###
+ Sets an item as unread
+ ###
+ url =
+ itemId: itemId
+
+ @_request.post 'news_unread_item', url
+
+
+ ###
+ FOLDER CONTROLLER
+ ###
+ getAllFolders: (callback) ->
+ callback or= angular.noop
+ @_request.get 'news_folders', {}, {}, callback
+
+
+ getFolderById: (folderId) ->
+ url =
+ folderId: folderId
+ @_request.get 'news_folder', url
+
+
+ openFolder: (folderId) ->
+ ###
+ Save if a folder was opened
+ ###
+ url =
+ folderId: folderId
+