added rewritten js from appframwork-js branch

This commit is contained in:
Bernhard Posselt 2013-03-18 11:49:26 +01:00
Родитель 2eec5da48c
Коммит 8c5bf6f317
34 изменённых файлов: 46355 добавлений и 0 удалений

118
js/Gruntfile.coffee Normal file
Просмотреть файл

@ -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'])

58
js/Makefile Normal file
Просмотреть файл

@ -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

38
js/README.md Normal file
Просмотреть файл

@ -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

44
js/app/app.coffee Normal file
Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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
]

Просмотреть файл

@ -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
]

Просмотреть файл

@ -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
]

Просмотреть файл

@ -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

Просмотреть файл

@ -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
@_request.post 'news_open_folder', url
collapseFolder: (folderId) ->
###
Save if a folder was collapsed
###
url =
folderId: folderId
@_request.post 'news_collapse_folder', url
createFolder: (folderName, parentFolderId=0, onSuccess=null, onError=null) ->
data =
folderName: folderName
parentFolderId: parentFolderId
onSuccess or= angular.noop
onError or= angular.noop
@_request.post 'news_create_folder', {}, data, onSuccess, onError
deleteFolder: (folderId) ->
###
Save if a folder was collapsed
###
url =
folderId: folderId
@_request.post 'news_delete_folder', url
renameFolder: (folderId, folderName) ->
###
Save if a folder was collapsed
###
url =
folderId: folderId
data =
folderName: folderName
@_request.post 'news_rename_folder', url, data
###
FEED CONTROLLER
###
getAllFeeds: (callback) ->
callback or= angular.noop
@_request.get 'news_feeds', {}, {}, callback
getFeedById: (feedId) ->
url =
feedId: feedId
@_request.get 'news_feed', url
getActiveFeed: (onSuccess) ->
@_request.get 'news_active_feed', {}, {}, onSuccess
createFeed: (url, parentFolderId, onSuccess, onError) ->
data =
parentFolderId: parentFolderId
url: url
@_request.post 'news_create_feed', {}, data, onSuccess, onError
deleteFeed: (feedId) ->
url =
feedId: feedId
@_request.post 'news_delete_feed', url
moveFeed: (feedId, folderId) ->
###
moves a feed to a new folder
###
url =
feedId: feedId
data =
folderId: folderId
@_request.post 'news_move_feed', url, data
setFeedRead: (feedId, highestItemId) ->
###
sets all items of a feed as read
###
url =
feedId: feedId
data =
highestItemId: highestItemId
@_request.post 'news_set_feed_read', url, data
updateFeed: (feedId) ->
###
moves a feed to a new folder
###
url =
feedId: feedId
@_request.post 'news_update_feed', url
###
EXPORT CONTROLLER
###
exportOPML: ->
###
Prompts for an OPML download
###
@_request.get 'news_export_opml'
###
USERSETTINGS CONTROLLER
###
userSettingsRead: (callback=null) ->
###
Gets the configs for read settings
###
callback or= angular.noop
@_request.get 'news_user_settings_read', {}, {}, callback
userSettingsReadShow: ->
###
Sets the reader mode to show all
###
@_request.post 'news_user_settings_read_show'
userSettingsReadHide: ->
###
Sets the reader mode to show only unread
###
@_request.post 'news_user_settings_read_hide'
_trigerHideRead: ->
@_$rootScope.$broadcast('triggerHideRead')
return Persistence

Просмотреть файл

@ -0,0 +1,89 @@
###
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/>.
###
# request related stuff
angular.module('News').factory 'Persistence', ['_Persistence', 'Request',
'Loading', 'Config', '$rootScope', 'ActiveFeed',
(_Persistence, Request, Loading, Config, ActiveFeed, $rootScope) ->
return new _Persistence(Request, Loading, Config, ActiveFeed, $rootScope)
]
angular.module('News').factory 'Request',
['_Request', '$http', 'Publisher', 'Router',
(_Request, $http, Publisher, Router) ->
return new _Request($http, Publisher, Router)
]
# models
angular.module('News').factory 'ActiveFeed', ['_ActiveFeed', (_ActiveFeed) ->
return new _ActiveFeed()
]
angular.module('News').factory 'ShowAll', ['_ShowAll', (_ShowAll) ->
return new _ShowAll()
]
angular.module('News').factory 'StarredCount', ['_StarredCount',
(_StarredCount) ->
return new _StarredCount()
]
angular.module('News').factory 'FeedModel', ['_FeedModel', 'Utils',
(_FeedModel, Utils) ->
return new _FeedModel(Utils)
]
angular.module('News').factory 'FolderModel', ['_FolderModel', (_FolderModel) ->
return new _FolderModel()
]
angular.module('News').factory 'ItemModel', ['_ItemModel', (_ItemModel) ->
return new _ItemModel()
]
angular.module('News').factory 'Publisher',
['_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel',
'FolderModel', 'FeedModel',
(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel,
FolderModel, FeedModel) ->
# register items at publisher to automatically add incoming items
publisher = new _Publisher()
publisher.subscribeObjectTo(ActiveFeed, 'activeFeed')
publisher.subscribeObjectTo(ShowAll, 'showAll')
publisher.subscribeObjectTo(StarredCount, 'starred')
publisher.subscribeObjectTo(FolderModel, 'folders')
publisher.subscribeObjectTo(FeedModel, 'feeds')
publisher.subscribeObjectTo(ItemModel, 'items')
return publisher
]
# other classes
angular.module('News').factory 'OPMLParser', ['_OPMLParser', (_OPMLParser) ->
return new _OPMLParser()
]

Просмотреть файл

@ -0,0 +1,41 @@
###
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 '_ShowAll', ->
class ShowAll
constructor: ->
@_showAll = false
handle: (data) ->
@_showAll = data
getShowAll: ->
return @_showAll
return ShowAll

Просмотреть файл

@ -0,0 +1,41 @@
###
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 '_StarredCount', ->
class StarredCount
constructor: ->
@_count = 0
handle: (data) ->
@_count = data
getStarredCount: ->
return @_count
return StarredCount

Просмотреть файл

@ -0,0 +1,98 @@
/**
* 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/>.
*
*/
// Testacular configuration
// Generated on Tue Feb 12 2013 19:27:01 GMT+0100 (CET)
// base path, that will be used to resolve files and exclude
basePath = '../';
// list of files / patterns to load in the browser
files = [
JASMINE,
JASMINE_ADAPTER,
'vendor/jquery/jquery.js',
'vendor/jquery-ui/jquery-ui.js',
'vendor/angular/angular.js',
'vendor/angular/angular-mocks.js',
'vendor/angular-ui/angular-ui.js',
'../../appframework/js/tests/stubs/owncloud.js',
'../../appframework/js/public/app.js',
'tests/stubs/modules.js',
'build/app/directives/*.js',
'build/app/filters/*.js',
'build/app/services/**/*.js',
'build/tests/**/*Spec.js'
];
// list of files to exclude
exclude = [
'build/app/app.js'
];
// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters = ['progress'];
// web server port
port = 8080;
// cli runner port
runnerPort = 9100;
// enable / disable colors in the output (reporters and logs)
colors = true;
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;
// enable / disable watching file and executing tests whenever any file changes
autoWatch = true;
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['Chrome'];
// If browser does not capture in given timeout [ms], kill it
captureTimeout = 5000;
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;

33
js/package.json Normal file
Просмотреть файл

@ -0,0 +1,33 @@
{
"name": "owncloud-news",
"description": "ownCloud News App",
"version": "0.0.1",
"author": {
"name": "Bernhard Posselt",
"email": "nukeawhale@gmail.com"
},
"private": true,
"homepage": "https://github.com/owncloud/apps/tree/news/",
"repository": {
"type": "git",
"url": "git@github.com:owncloud/apps.git"
},
"bugs": "https://github.com/owncloud/apps/issues",
"contributors": [],
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.0",
"grunt-cli": "~0.1.6",
"coffee-script": "~1.4.0",
"grunt-contrib-coffee": "~0.4",
"grunt-contrib-concat": "~0.1.2",
"grunt-contrib-watch": "~0.2.0",
"grunt-coffeelint": "0.0.6",
"gruntacular": "~0.1.1",
"grunt-wrap": "~0.2.0",
"testacular": "~0.4.0",
"phantomjs": "~1.8.1-3",
"grunt-phpunit": "0.2.0"
},
"engine": "node >= 0.8"
}

997
js/public/app.js Normal file
Просмотреть файл

@ -0,0 +1,997 @@
(function(angular, $, undefined){
/**
* ownCloud News App - v0.0.1
*
* 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
*
*/
// Generated by CoffeeScript 1.4.0
/*
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', ['OC', 'ui']).config(function($provide) {
var config;
return $provide.value('Config', config = {
markReadTimeout: 500,
scrollTimeout: 500,
feedUpdateInterval: 6000000,
itemBatchSize: 20
});
});
angular.module('News').run([
'Persistence', function(Persistence) {
return Persistence.init();
}
]);
$(document).ready(function() {
return $(this).keyup(function(e) {
if ((e.which === 116) || (e.which === 82 && e.ctrlKey)) {
document.location.reload(true);
return false;
}
});
});
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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('_ActiveFeed', function() {
var ActiveFeed;
ActiveFeed = (function() {
function ActiveFeed() {
/*
Default value is all feeds
*/
this._id = 0;
this._type = 3;
}
ActiveFeed.prototype.handle = function(data) {
this._id = data.id;
return this._type = data.type;
};
ActiveFeed.prototype.getType = function() {
return this._type;
};
ActiveFeed.prototype.getId = function() {
return this._id;
};
return ActiveFeed;
})();
return ActiveFeed;
});
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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('FeedType', function() {
var feedType;
return feedType = {
Feed: 0,
Folder: 1,
Starred: 2,
Subscriptions: 3,
Shared: 4
};
});
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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; };
angular.module('News').factory('_FeedModel', [
'_Model', function(_Model) {
var FeedModel;
FeedModel = (function(_super) {
__extends(FeedModel, _super);
function FeedModel(_utils) {
this._utils = _utils;
FeedModel.__super__.constructor.call(this);
}
FeedModel.prototype.add = function(item) {
if (item.icon === 'url()') {
item.icon = 'url(' + this._utils.imagePath('news', 'rss.svg') + ')';
}
return FeedModel.__super__.add.call(this, item);
};
return FeedModel;
})(_Model);
return FeedModel;
}
]);
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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; };
angular.module('News').factory('_FolderModel', [
'_Model', function(_Model) {
var FolderModel;
FolderModel = (function(_super) {
__extends(FolderModel, _super);
function FolderModel() {
return FolderModel.__super__.constructor.apply(this, arguments);
}
return FolderModel;
})(_Model);
return FolderModel;
}
]);
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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; };
angular.module('News').factory('_ItemModel', [
'_Model', function(_Model) {
var ItemModel;
ItemModel = (function(_super) {
__extends(ItemModel, _super);
function ItemModel() {
return ItemModel.__super__.constructor.apply(this, arguments);
}
return ItemModel;
})(_Model);
return ItemModel;
}
]);
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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('_OPMLParser', function() {
var Feed, Folder, OPMLParser;
Feed = (function() {
function Feed(_name, _url) {
this._name = _name;
this._url = _url;
}
Feed.prototype.getName = function() {
return this._name;
};
Feed.prototype.getUrl = function() {
return this._url;
};
Feed.prototype.isFolder = function() {
return false;
};
return Feed;
})();
Folder = (function() {
function Folder(_name) {
this._name = _name;
this._items = [];
}
Folder.prototype.add = function(feed) {
return this._items.push(feed);
};
Folder.prototype.getItems = function() {
return this._items;
};
Folder.prototype.getName = function() {
return this._name;
};
Folder.prototype.isFolder = function() {
return true;
};
return Folder;
})();
OPMLParser = (function() {
function OPMLParser() {}
OPMLParser.prototype.parseXML = function(xml) {
var $root, $xml, structure;
$xml = $($.parseXML(xml));
$root = $xml.find('body');
structure = new Folder('root');
this._recursivelyParse($root, structure);
return structure;
};
OPMLParser.prototype._recursivelyParse = function($xml, structure) {
var $outline, feed, folder, outline, _i, _len, _ref, _results;
_ref = $xml.children('outline');
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
outline = _ref[_i];
$outline = $(outline);
if (angular.isDefined($outline.attr('type'))) {
feed = new Feed($outline.attr('text'), $outline.attr('xmlUrl'));
_results.push(structure.add(feed));
} else {
folder = new Folder($outline.attr('text'));
structure.add(folder);
_results.push(this._recursivelyParse($outline, folder));
}
}
return _results;
};
return OPMLParser;
})();
return OPMLParser;
});
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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('_Persistence', function() {
var Persistence;
Persistence = (function() {
function Persistence(_request, _loading, _config, _activeFeed, _$rootScope) {
this._request = _request;
this._loading = _loading;
this._config = _config;
this._activeFeed = _activeFeed;
this._$rootScope = _$rootScope;
}
Persistence.prototype.init = function() {
/*
Loads the initial data from the server
*/
var _this = this;
this._loading.increase();
this.getActiveFeed(function() {
return _this.getItems(_this._activeFeed.getType(), _this._activeFeed.getId(), null, function() {
return _this._loading.decrease();
});
});
this.getAllFolders(this._triggerHideRead);
this.getAllFeeds(this._triggerHideRead);
this.userSettingsRead(this._triggerHideRead);
return this.getStarredItems(this._triggerHideRead);
};
/*
ITEM CONTROLLER
*/
Persistence.prototype.getItems = function(type, id, offset, onSuccess, updatedSince) {
var data;
if (updatedSince == null) {
updatedSince = null;
}
if (updatedSince !== null) {
data = {
updatedSince: updatedSince,
type: type,
id: id
};
} else {
data = {
limit: this._config.itemBatchSize,
offset: offset,
id: id,
type: type
};
}
return this._request.get('news_items', {}, data, onSuccess);
};
Persistence.prototype.getItemById = function(itemId) {
var url;
url = {
itemId: itemId
};
return this._request.get('news_item', url);
};
Persistence.prototype.getStarredItems = function(onSuccess) {
return this._request.get('news_starred_items', {}, {}, onSuccess);
};
Persistence.prototype.starItem = function(itemId) {
/*
Stars an item
*/
var url;
url = {
itemId: itemId
};
return this._request.post('news_star_item', url);
};
Persistence.prototype.unstarItem = function(itemId) {
/*
Unstars an item
*/
var url;
url = {
itemId: itemId
};
return this._request.post('news_unstar_item', url);
};
Persistence.prototype.readItem = function(itemId) {
/*
Sets an item as read
*/
var url;
url = {
itemId: itemId
};
return this._request.post('news_read_item', url);
};
Persistence.prototype.unreadItem = function(itemId) {
/*
Sets an item as unread
*/
var url;
url = {
itemId: itemId
};
return this._request.post('news_unread_item', url);
};
/*
FOLDER CONTROLLER
*/
Persistence.prototype.getAllFolders = function(callback) {
callback || (callback = angular.noop);
return this._request.get('news_folders', {}, {}, callback);
};
Persistence.prototype.getFolderById = function(folderId) {
var url;
url = {
folderId: folderId
};
return this._request.get('news_folder', url);
};
Persistence.prototype.openFolder = function(folderId) {
/*
Save if a folder was opened
*/
var url;
url = {
folderId: folderId
};
return this._request.post('news_open_folder', url);
};
Persistence.prototype.collapseFolder = function(folderId) {
/*
Save if a folder was collapsed
*/
var url;
url = {
folderId: folderId
};
return this._request.post('news_collapse_folder', url);
};
Persistence.prototype.createFolder = function(folderName, parentFolderId, onSuccess, onError) {
var data;
if (parentFolderId == null) {
parentFolderId = 0;
}
if (onSuccess == null) {
onSuccess = null;
}
if (onError == null) {
onError = null;
}
data = {
folderName: folderName,
parentFolderId: parentFolderId
};
onSuccess || (onSuccess = angular.noop);
onError || (onError = angular.noop);
return this._request.post('news_create_folder', {}, data, onSuccess, onError);
};
Persistence.prototype.deleteFolder = function(folderId) {
/*
Save if a folder was collapsed
*/
var url;
url = {
folderId: folderId
};
return this._request.post('news_delete_folder', url);
};
Persistence.prototype.renameFolder = function(folderId, folderName) {
/*
Save if a folder was collapsed
*/
var data, url;
url = {
folderId: folderId
};
data = {
folderName: folderName
};
return this._request.post('news_rename_folder', url, data);
};
/*
FEED CONTROLLER
*/
Persistence.prototype.getAllFeeds = function(callback) {
callback || (callback = angular.noop);
return this._request.get('news_feeds', {}, {}, callback);
};
Persistence.prototype.getFeedById = function(feedId) {
var url;
url = {
feedId: feedId
};
return this._request.get('news_feed', url);
};
Persistence.prototype.getActiveFeed = function(onSuccess) {
return this._request.get('news_active_feed', {}, {}, onSuccess);
};
Persistence.prototype.createFeed = function(url, parentFolderId, onSuccess, onError) {
var data;
data = {
parentFolderId: parentFolderId,
url: url
};
return this._request.post('news_create_feed', {}, data, onSuccess, onError);
};
Persistence.prototype.deleteFeed = function(feedId) {
var url;
url = {
feedId: feedId
};
return this._request.post('news_delete_feed', url);
};
Persistence.prototype.moveFeed = function(feedId, folderId) {
/*
moves a feed to a new folder
*/
var data, url;
url = {
feedId: feedId
};
data = {
folderId: folderId
};
return this._request.post('news_move_feed', url, data);
};
Persistence.prototype.setFeedRead = function(feedId, highestItemId) {
/*
sets all items of a feed as read
*/
var data, url;
url = {
feedId: feedId
};
data = {
highestItemId: highestItemId
};
return this._request.post('news_set_feed_read', url, data);
};
Persistence.prototype.updateFeed = function(feedId) {
/*
moves a feed to a new folder
*/
var url;
url = {
feedId: feedId
};
return this._request.post('news_update_feed', url);
};
/*
EXPORT CONTROLLER
*/
Persistence.prototype.exportOPML = function() {
/*
Prompts for an OPML download
*/
return this._request.get('news_export_opml');
};
/*
USERSETTINGS CONTROLLER
*/
Persistence.prototype.userSettingsRead = function(callback) {
if (callback == null) {
callback = null;
}
/*
Gets the configs for read settings
*/
callback || (callback = angular.noop);
return this._request.get('news_user_settings_read', {}, {}, callback);
};
Persistence.prototype.userSettingsReadShow = function() {
/*
Sets the reader mode to show all
*/
return this._request.post('news_user_settings_read_show');
};
Persistence.prototype.userSettingsReadHide = function() {
/*
Sets the reader mode to show only unread
*/
return this._request.post('news_user_settings_read_hide');
};
Persistence.prototype._trigerHideRead = function() {
return this._$rootScope.$broadcast('triggerHideRead');
};
return Persistence;
})();
return Persistence;
});
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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('Persistence', [
'_Persistence', 'Request', 'Loading', 'Config', '$rootScope', 'ActiveFeed', function(_Persistence, Request, Loading, Config, ActiveFeed, $rootScope) {
return new _Persistence(Request, Loading, Config, ActiveFeed, $rootScope);
}
]);
angular.module('News').factory('Request', [
'_Request', '$http', 'Publisher', 'Router', function(_Request, $http, Publisher, Router) {
return new _Request($http, Publisher, Router);
}
]);
angular.module('News').factory('ActiveFeed', [
'_ActiveFeed', function(_ActiveFeed) {
return new _ActiveFeed();
}
]);
angular.module('News').factory('ShowAll', [
'_ShowAll', function(_ShowAll) {
return new _ShowAll();
}
]);
angular.module('News').factory('StarredCount', [
'_StarredCount', function(_StarredCount) {
return new _StarredCount();
}
]);
angular.module('News').factory('FeedModel', [
'_FeedModel', 'Utils', function(_FeedModel, Utils) {
return new _FeedModel(Utils);
}
]);
angular.module('News').factory('FolderModel', [
'_FolderModel', function(_FolderModel) {
return new _FolderModel();
}
]);
angular.module('News').factory('ItemModel', [
'_ItemModel', function(_ItemModel) {
return new _ItemModel();
}
]);
angular.module('News').factory('Publisher', [
'_Publisher', 'ActiveFeed', 'ShowAll', 'StarredCount', 'ItemModel', 'FolderModel', 'FeedModel', function(_Publisher, ActiveFeed, ShowAll, StarredCount, ItemModel, FolderModel, FeedModel) {
var publisher;
publisher = new _Publisher();
publisher.subscribeObjectTo(ActiveFeed, 'activeFeed');
publisher.subscribeObjectTo(ShowAll, 'showAll');
publisher.subscribeObjectTo(StarredCount, 'starred');
publisher.subscribeObjectTo(FolderModel, 'folders');
publisher.subscribeObjectTo(FeedModel, 'feeds');
publisher.subscribeObjectTo(ItemModel, 'items');
return publisher;
}
]);
angular.module('News').factory('OPMLParser', [
'_OPMLParser', function(_OPMLParser) {
return new _OPMLParser();
}
]);
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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('_ShowAll', function() {
var ShowAll;
ShowAll = (function() {
function ShowAll() {
this._showAll = false;
}
ShowAll.prototype.handle = function(data) {
return this._showAll = data;
};
ShowAll.prototype.getShowAll = function() {
return this._showAll;
};
return ShowAll;
})();
return ShowAll;
});
}).call(this);
// Generated by CoffeeScript 1.4.0
/*
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('_StarredCount', function() {
var StarredCount;
StarredCount = (function() {
function StarredCount() {
this._count = 0;
}
StarredCount.prototype.handle = function(data) {
return this._count = data;
};
StarredCount.prototype.getStarredCount = function() {
return this._count;
};
return StarredCount;
})();
return StarredCount;
});
}).call(this);
})(window.angular, jQuery);

Просмотреть файл

@ -0,0 +1,52 @@
###
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 '_ActiveFeed', ->
beforeEach module 'News'
beforeEach inject (@_ActiveFeed, @FeedType) =>
@data =
id: 5
type: 3
it 'should be Subscriptions by default', =>
active = new @_ActiveFeed()
expect(active.getType()).toBe(@FeedType.Subscriptions)
it 'should set the correct feed id', =>
active = new @_ActiveFeed()
active.handle(@data)
expect(active.getId()).toBe(5)
it 'should set the correct feed type', =>
active = new @_ActiveFeed()
active.handle(@data)
expect(active.getType()).toBe(3)

Просмотреть файл

@ -0,0 +1,49 @@
###
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 'FeedType', ->
beforeEach module 'News'
beforeEach inject (@FeedType) =>
it 'should have the correct folder number', =>
expect(@FeedType.Feed).toBe(0)
it 'should have the correct folder number', =>
expect(@FeedType.Folder).toBe(1)
it 'should have the correct folder number', =>
expect(@FeedType.Starred).toBe(2)
it 'should have the correct folder number', =>
expect(@FeedType.Subscriptions).toBe(3)
it 'should have the correct folder number', =>
expect(@FeedType.Shared).toBe(4 )

Просмотреть файл

@ -0,0 +1,46 @@
###
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 '_FeedModel', ->
beforeEach module 'News'
beforeEach inject (@_FeedModel, @_Model) =>
it 'should extend model', =>
expect(new @_FeedModel instanceof @_Model).toBeTruthy()
it 'should bind an imagepath to the item if the url is empty', =>
item =
id: 3
icon: 'url()'
utils =
imagePath: jasmine.createSpy('utils')
model = new @_FeedModel(utils)
model.add(item)
expect(utils.imagePath).toHaveBeenCalledWith('news', 'rss.svg')

Просмотреть файл

@ -0,0 +1,32 @@
###
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 '_FolderModel', ->
beforeEach module 'News'
beforeEach inject (@_FolderModel, @_Model) =>
it 'should extend model', =>
expect(new @_FolderModel instanceof @_Model).toBeTruthy()

Просмотреть файл

@ -0,0 +1,32 @@
###
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 '_ItemModel', ->
beforeEach module 'News'
beforeEach inject (@_ItemModel, @_Model) =>
it 'should extend model', =>
expect(new @_ItemModel instanceof @_Model).toBeTruthy()

Просмотреть файл

@ -0,0 +1,36 @@
###
ownCloud - News
@author Raghu Nayyar
@copyright 2012 Raghu Nayyar me@iraghu.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 '_OPMLParser', ->
beforeEach module 'News'
beforeEach inject (@_OPMLParser) =>
@parser = new @_OPMLParser()
it 'should return only the root folder when parsing empty OPML', =>
@data = @parser.parseXML('')
expect(@data.getName()).toBe('root')

Просмотреть файл

@ -0,0 +1,359 @@
###
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 '_Persistence', ->
beforeEach module 'News'
beforeEach inject (@_Persistence, @$rootScope) =>
@req =
post: jasmine.createSpy('POST')
get: jasmine.createSpy('GET').andCallFake (url, p1, p2, callback) ->
if callback
callback()
@config =
itemBatchSize: 12
@active =
getType: -> 3
getId: -> 1
@loading =
increase: ->
decrease: ->
it 'should should show a loading sign when init', =>
loading =
increase: jasmine.createSpy('loading')
decrease: jasmine.createSpy('finished loading')
pers = new @_Persistence(@req, loading, @config, @active, @$rootScope)
pers.init()
expect(loading.increase).toHaveBeenCalled()
expect(loading.decrease).toHaveBeenCalled()
###
FEED CONTROLLER
###
it 'should get all feeds', =>
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getAllFeeds()
expect(@req.get).toHaveBeenCalledWith('news_feeds', {}, {}, angular.noop)
it 'should get a feed by id', =>
url =
feedId: 1
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getFeedById(url.feedId)
expect(@req.get).toHaveBeenCalledWith('news_feed', url)
it 'create a correct request for moving a feed', =>
data =
folderId: 4
url =
feedId: 3
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.moveFeed(url.feedId, data.folderId)
expect(@req.post).toHaveBeenCalledWith('news_move_feed', url, data)
it 'shoud send a correct request for marking all items read', =>
data =
highestItemId: 4
url =
feedId: 3
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.setFeedRead(url.feedId, data.highestItemId)
expect(@req.post).toHaveBeenCalledWith('news_set_feed_read', url, data)
it 'send a correct feed update request', =>
url =
feedId: 3
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.updateFeed(url.feedId)
expect(@req.post).toHaveBeenCalledWith('news_update_feed', url)
it 'send a correct get active feed request', =>
succs = angular.noop
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getActiveFeed(succs)
expect(@req.get).toHaveBeenCalledWith('news_active_feed', {}, {}, succs)
it 'send a correct feed delete request', =>
url =
feedId: 3
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.deleteFeed(url.feedId)
expect(@req.post).toHaveBeenCalledWith('news_delete_feed', url)
it 'send a correct feed create request', =>
data =
parentFolderId: 5
url: 'http://google.de'
onsuccess = angular.noop
onerror = angular.noop
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.createFeed(data.url, data.parentFolderId, onsuccess, onerror)
expect(@req.post).toHaveBeenCalledWith('news_create_feed', {}, data,
onsuccess, onerror)
###
FOLDER CONTROLLER
###
it 'should do a proper get all folders request', =>
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getAllFolders()
expect(@req.get).toHaveBeenCalledWith('news_folders', {}, {}, angular.noop)
it 'should get a folder by id', =>
url =
folderId: 5
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getFolderById(url.folderId)
expect(@req.get).toHaveBeenCalledWith('news_folder', url)
it 'send a correct collapse folder request', =>
url =
folderId: 3
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.collapseFolder(url.folderId)
expect(@req.post).toHaveBeenCalledWith('news_collapse_folder', url)
it 'send a correct open folder request', =>
url =
folderId: 3
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.openFolder(url.folderId)
expect(@req.post).toHaveBeenCalledWith('news_open_folder', url)
it 'should do a proper folder create request', =>
data =
folderName: 'check'
parentFolderId: 4
onsuccess = -> 1
onerror = -> 2
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.createFolder(data.folderName, data.parentFolderId, onsuccess, onerror)
expect(@req.post).toHaveBeenCalledWith('news_create_folder', {}, data,
onsuccess, onerror)
it 'should do a proper folder delete request', =>
url =
folderId: 2
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.deleteFolder(url.folderId)
expect(@req.post).toHaveBeenCalledWith('news_delete_folder', url)
it 'should do a proper folder rename request', =>
url =
folderId: 2
data =
folderName: 'host'
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.renameFolder(url.folderId, data.folderName)
expect(@req.post).toHaveBeenCalledWith('news_rename_folder', url, data)
###
ITEM CONTROLLER
###
it 'should send a autopaging request', =>
data =
type: 2
id: 5
limit: @config.itemBatchSize
offset: 3
success = angular.noop
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getItems(data.type, data.id, data.offset, success, null)
expect(@req.get).toHaveBeenCalledWith('news_items', {}, data, success)
it 'should send a load newest items request', =>
data =
type: 2
id: 5
updatedSince: 1333
success = angular.noop
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getItems(data.type, data.id, 0, success, data.updatedSince)
expect(@req.get).toHaveBeenCalledWith('news_items', {}, data, success)
it 'send a correct get item by id request', =>
url =
itemId: 5
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getItemById(url.itemId)
expect(@req.get).toHaveBeenCalledWith('news_item', url)
it 'send a correct get starred items request', =>
success = angular.noop
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.getStarredItems(success)
expect(@req.get).toHaveBeenCalledWith('news_starred_items', {}, {},
success)
it 'send a correct star item request', =>
url =
itemId: 2
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.starItem(url.itemId)
expect(@req.post).toHaveBeenCalledWith('news_star_item', url)
it 'send a correct unstar item request', =>
url =
itemId: 2
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.unstarItem(url.itemId)
expect(@req.post).toHaveBeenCalledWith('news_unstar_item', url)
it 'send a correct read item request', =>
url =
itemId: 2
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.readItem(url.itemId)
expect(@req.post).toHaveBeenCalledWith('news_read_item', url)
it 'send a correct unread item request', =>
url =
itemId: 2
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.unreadItem(url.itemId)
expect(@req.post).toHaveBeenCalledWith('news_unread_item', url)
###
EXPORT CONTROLLER
###
it 'should have an export request', =>
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.exportOPML()
expect(@req.get).toHaveBeenCalledWith('news_export_opml')
###
USERSETTINGS CONTROLLER
###
it 'should do a proper get user settings read request', =>
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.userSettingsRead()
expect(@req.get).toHaveBeenCalledWith('news_user_settings_read', {}, {},
angular.noop)
it 'should do a proper get user settings read req and call callback', =>
callback = ->
1 + 1
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.userSettingsRead(callback)
expect(@req.get).toHaveBeenCalledWith('news_user_settings_read', {}, {},
callback)
it 'should do a proper user settings read show request', =>
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.userSettingsReadShow()
expect(@req.post).toHaveBeenCalledWith('news_user_settings_read_show')
it 'should do a proper user settings read hide request', =>
pers = new @_Persistence(@req, @loading, @config, @active, @$rootScope)
pers.userSettingsReadHide()
expect(@req.post).toHaveBeenCalledWith('news_user_settings_read_hide')

Просмотреть файл

@ -0,0 +1,42 @@
###
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 '_ShowAll', ->
beforeEach module 'News'
beforeEach inject (@_ShowAll) =>
it 'should be false by default', =>
showAll = new @_ShowAll()
expect(showAll.getShowAll()).toBeFalsy()
it 'should set the correct showAll value', =>
showAll = new @_ShowAll()
showAll.handle(true)
expect(showAll.getShowAll()).toBeTruthy()

Просмотреть файл

@ -0,0 +1,42 @@
###
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 '_StarredCount', ->
beforeEach module 'News'
beforeEach inject (@_StarredCount) =>
it 'should be 0 by default', =>
starred = new @_StarredCount()
expect(starred.getStarredCount()).toBe(0)
it 'should set the correct starred count', =>
starred = new @_StarredCount()
starred.handle(3)
expect(starred.getStarredCount()).toBe(3)

23
js/tests/stubs/modules.js Normal file
Просмотреть файл

@ -0,0 +1,23 @@
/**
* 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 definition for testing
angular.module('News', ['OC', 'ngMock']);

3
js/vendor/angular-ui/.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,3 @@
node_modules
*.coffee.js
.idea

1316
js/vendor/angular-ui/angular-ui.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1764
js/vendor/angular/angular-mocks.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

14604
js/vendor/angular/angular.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

14850
js/vendor/jquery-ui/jquery-ui.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

9597
js/vendor/jquery/jquery.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1400
js/vendor/momentjs/moment.js поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу