Skip to content

Commit c22af30

Browse files
committed
Add swanviewer
1 parent abeef2c commit c22af30

26 files changed

+1565
-0
lines changed

.travis.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
sudo: required
2+
dist: trusty
3+
language: php
4+
php:
5+
- 5.6
6+
- 7
7+
env:
8+
global:
9+
- CORE_BRANCH=stable9
10+
matrix:
11+
- DB=pgsql
12+
13+
matrix:
14+
allow_failures:
15+
- env: DB=pgsql CORE_BRANCH=master
16+
include:
17+
- php: 5.6
18+
env: DB=sqlite
19+
- php: 5.6
20+
env: DB=mysql
21+
- php: 5.6
22+
env: DB=pgsql CORE_BRANCH=master
23+
fast_finish: true
24+
25+
before_install:
26+
# install firefox and enable a display for running JavaScript tests
27+
- export DISPLAY=:99.0
28+
- sh -e /etc/init.d/xvfb start
29+
- sudo apt-get update
30+
- sudo apt-get -y install python3-setuptools firefox mariadb-server
31+
- sudo easy_install3 requests ocdev
32+
- nvm install 5.9
33+
- npm install -g npm@latest
34+
- make
35+
# install core
36+
- cd ../
37+
- ocdev setup core --dir owncloud --branch $CORE_BRANCH --no-history
38+
- mv swanviewer owncloud/apps/
39+
40+
before_script:
41+
- createuser -U travis -s oc_autotest
42+
- mysql -u root -e 'create database oc_autotest;'
43+
- mysql -u root -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY '';"
44+
- mysql -u root -e "grant all on oc_autotest.* to 'oc_autotest'@'localhost';"
45+
- cd owncloud
46+
- mkdir data
47+
- ./occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass=''
48+
- ./occ app:enable swanviewer
49+
- ocdev server &
50+
- cd apps/swanviewer
51+
52+
script:
53+
- make test

AUTHORS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Authors
2+
3+
* Hugo Gonzalez Labrador (CERN): <[email protected]>
4+

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
owncloud-swanviewer (0.0.1)
2+
* **Security**: Security description here
3+
* **Backwards incompatible change**: Changes in the API
4+
* **New dependency**: New dependencies such as a new ownCloud or PHP version
5+
* **Bugfix**: Bugfix description
6+
* **Enhancement**: New feature description

COPYING

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

LICENSE

100644100755
File mode changed.

Makefile

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# This file is licensed under the Affero General Public License version 3 or
2+
# later. See the COPYING file.
3+
# @author Bernhard Posselt <[email protected]>
4+
# @copyright Bernhard Posselt 2012, 2014
5+
6+
# Generic Makefile for building and packaging an ownCloud app which uses npm and
7+
# Composer.
8+
#
9+
# Dependencies:
10+
# * make
11+
# * which
12+
# * curl: used if phpunit and composer are not installed to fetch them from the web
13+
# * tar: for building the archive
14+
# * npm: for building and testing everything JS
15+
#
16+
# If no composer.json is in the app root directory, the Composer step
17+
# will be skipped. The same goes for the package.json which can be located in
18+
# the app root or the js/ directory.
19+
#
20+
# The npm command by launches the npm build script:
21+
#
22+
# npm run build
23+
#
24+
# The npm test command launches the npm test script:
25+
#
26+
# npm run test
27+
#
28+
# The idea behind this is to be completely testing and build tool agnostic. All
29+
# build tools and additional package managers should be installed locally in
30+
# your project, since this won't pollute people's global namespace.
31+
#
32+
# The following npm scripts in your package.json install and update the bower
33+
# and npm dependencies and use gulp as build system (notice how everything is
34+
# run from the node_modules folder):
35+
#
36+
# "scripts": {
37+
# "test": "node node_modules/gulp-cli/bin/gulp.js karma",
38+
# "prebuild": "npm install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
39+
# "build": "node node_modules/gulp-cli/bin/gulp.js"
40+
# },
41+
42+
app_name=$(notdir $(CURDIR))
43+
build_tools_directory=$(CURDIR)/build/tools
44+
source_build_directory=$(CURDIR)/build/artifacts/source
45+
source_package_name=$(source_build_directory)/$(app_name)
46+
appstore_build_directory=$(CURDIR)/build/artifacts/appstore
47+
appstore_package_name=$(appstore_build_directory)/$(app_name)
48+
npm=$(shell which npm 2> /dev/null)
49+
composer=$(shell which composer 2> /dev/null)
50+
51+
all: build
52+
53+
# Fetches the PHP and JS dependencies and compiles the JS. If no composer.json
54+
# is present, the composer step is skipped, if no package.json or js/package.json
55+
# is present, the npm step is skipped
56+
.PHONY: build
57+
build:
58+
ifneq (,$(wildcard $(CURDIR)/composer.json))
59+
make composer
60+
endif
61+
ifneq (,$(wildcard $(CURDIR)/package.json))
62+
make npm
63+
endif
64+
ifneq (,$(wildcard $(CURDIR)/js/package.json))
65+
make npm
66+
endif
67+
68+
# Installs and updates the composer dependencies. If composer is not installed
69+
# a copy is fetched from the web
70+
.PHONY: composer
71+
composer:
72+
ifeq (, $(composer))
73+
@echo "No composer command available, downloading a copy from the web"
74+
mkdir -p $(build_tools_directory)
75+
curl -sS https://getcomposer.org/installer | php
76+
mv composer.phar $(build_tools_directory)
77+
php $(build_tools_directory)/composer.phar install --prefer-dist
78+
php $(build_tools_directory)/composer.phar update --prefer-dist
79+
else
80+
composer install --prefer-dist
81+
composer update --prefer-dist
82+
endif
83+
84+
# Installs npm dependencies
85+
.PHONY: npm
86+
npm:
87+
ifeq (,$(wildcard $(CURDIR)/package.json))
88+
cd js && $(npm) run build
89+
else
90+
npm run build
91+
endif
92+
93+
# Removes the appstore build
94+
.PHONY: clean
95+
clean:
96+
rm -rf ./build
97+
98+
# Same as clean but also removes dependencies installed by composer, bower and
99+
# npm
100+
.PHONY: distclean
101+
distclean: clean
102+
rm -rf vendor
103+
rm -rf node_modules
104+
rm -rf js/vendor
105+
rm -rf js/node_modules
106+
107+
# Builds the source and appstore package
108+
.PHONY: dist
109+
dist:
110+
make source
111+
make appstore
112+
113+
# Builds the source package
114+
.PHONY: source
115+
source:
116+
make build
117+
make test
118+
rm -rf $(source_build_directory)
119+
mkdir -p $(source_build_directory)
120+
tar cvzf $(source_package_name).tar.gz ../$(app_name) \
121+
--exclude-vcs \
122+
--exclude="../$(app_name)/build" \
123+
--exclude="../$(app_name)/js/node_modules" \
124+
--exclude="../$(app_name)/*.log" \
125+
--exclude="../$(app_name)/js/*.log" \
126+
127+
# Builds the source package for the app store, ignores php and js tests
128+
.PHONY: appstore
129+
appstore:
130+
make build
131+
make test
132+
rm -rf $(appstore_build_directory)
133+
mkdir -p $(appstore_build_directory)
134+
tar cvzf $(appstore_package_name).tar.gz ../$(app_name) \
135+
--exclude-vcs \
136+
--exclude="../$(app_name)/build" \
137+
--exclude="../$(app_name)/tests" \
138+
--exclude="../$(app_name)/Makefile" \
139+
--exclude="../$(app_name)/*.log" \
140+
--exclude="../$(app_name)/phpunit*xml" \
141+
--exclude="../$(app_name)/composer.*" \
142+
--exclude="../$(app_name)/js/node_modules" \
143+
--exclude="../$(app_name)/js/tests" \
144+
--exclude="../$(app_name)/js/test" \
145+
--exclude="../$(app_name)/js/*.log" \
146+
--exclude="../$(app_name)/js/package.json" \
147+
--exclude="../$(app_name)/js/bower.json" \
148+
--exclude="../$(app_name)/js/karma.*" \
149+
--exclude="../$(app_name)/js/protractor.*" \
150+
--exclude="../$(app_name)/package.json" \
151+
--exclude="../$(app_name)/bower.json" \
152+
--exclude="../$(app_name)/karma.*" \
153+
--exclude="../$(app_name)/protractor\.*" \
154+
--exclude="../$(app_name)/.*" \
155+
--exclude="../$(app_name)/js/.*" \
156+
157+
# Command for running JS and PHP tests. Works for package.json files in the js/
158+
# and root directory. If phpunit is not installed systemwide, a copy is fetched
159+
# from the internet
160+
.PHONY: test
161+
test:
162+
ifneq (,$(wildcard $(CURDIR)/js/package.json))
163+
cd js && $(npm) run test
164+
endif
165+
ifneq (,$(wildcard $(CURDIR)/package.json))
166+
$(npm) run test
167+
endif
168+
ifeq (, $(shell which phpunit 2> /dev/null))
169+
@echo "No phpunit command available, downloading a copy from the web"
170+
mkdir -p $(build_tools_directory)
171+
curl -sSL https://phar.phpunit.de/phpunit.phar -o $(build_tools_directory)/phpunit.phar
172+
php $(build_tools_directory)/phpunit.phar -c phpunit.xml
173+
php $(build_tools_directory)/phpunit.phar -c phpunit.integration.xml
174+
else
175+
phpunit -c phpunit.xml
176+
phpunit -c phpunit.integration.xml
177+
endif

README.md

100644100755
File mode changed.

appinfo/app.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* ownCloud - swanviewer
4+
*
5+
* This file is licensed under the Affero General Public License version 3 or
6+
* later. See the COPYING file.
7+
*
8+
* @author Hugo Gonzalez Labrador (CERN) <[email protected]>
9+
* @copyright Hugo Gonzalez Labrador (CERN) 2017
10+
*/
11+
12+
namespace OCA\SwanViewer\AppInfo;
13+
14+
use OCP\AppFramework\App;
15+
16+
require_once __DIR__ . '/autoload.php';
17+
18+
$app = new App('swanviewer');
19+
$container = $app->getContainer();
20+
21+
22+
$domains = \OC::$server->getConfig()->getSystemValue("cbox.swan.cspdomains", ['cdnjs.cloudflare.com', 'root.cern.ch']);
23+
$policy = new \OCP\AppFramework\Http\EmptyContentSecurityPolicy();
24+
foreach($domains as $domain) {
25+
$policy->addAllowedScriptDomain($domain);
26+
$policy->addAllowedFrameDomain($domain);
27+
$policy->addAllowedStyleDomain($domain);
28+
}
29+
\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy);
30+
31+
\OCP\Util::addScript('swanviewer', 'script');
32+
\OCP\Util::addStyle('swanviewer', 'style');

appinfo/autoload.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* ownCloud - swanviewer
4+
*
5+
* This file is licensed under the Affero General Public License version 3 or
6+
* later. See the COPYING file.
7+
*
8+
* @author Hugo Gonzalez Labrador (CERN) <[email protected]>
9+
* @copyright Hugo Gonzalez Labrador (CERN) 2017
10+
*/
11+
12+
namespace OCA\SwanViewer\AppInfo;
13+
14+
use OCP\AppFramework\App;
15+
16+
/**
17+
* Additional autoloader registration, e.g. registering composer autoloaders
18+
*/
19+
// require_once __DIR__ . '/../vendor/autoload.php';

appinfo/info.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<info>
3+
<id>swanviewer</id>
4+
<name>Swan Viewer</name>
5+
<description>This app enables the open in SWAN functionality</description>
6+
<licence>AGPL</licence>
7+
<author>Hugo Gonzalez Labrador (CERN)</author>
8+
<version>0.0.1</version>
9+
<namespace>SwanViewer</namespace>
10+
<category>other</category>
11+
<dependencies>
12+
<owncloud min-version="9.0" />
13+
</dependencies>
14+
</info>

appinfo/routes.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* ownCloud - swanviewer
4+
*
5+
* This file is licensed under the Affero General Public License version 3 or
6+
* later. See the COPYING file.
7+
*
8+
* @author Hugo Gonzalez Labrador (CERN) <[email protected]>
9+
* @copyright Hugo Gonzalez Labrador (CERN) 2017
10+
*/
11+
12+
/**
13+
* Create your routes in here. The name is the lowercase name of the controller
14+
* without the controller part, the stuff after the hash is the method.
15+
* e.g. page#index -> OCA\SwanViewer\Controller\PageController->index()
16+
*
17+
* The controller class has to be registered in the application.php file since
18+
* it's instantiated in there
19+
*/
20+
return [
21+
'routes' => [
22+
['name' => 'page#do_config', 'url' => '/config', 'verb' => 'GET'],
23+
['name' => 'page#do_eosinfo', 'url' => '/eosinfo', 'verb' => 'GET'],
24+
['name' => 'page#do_load', 'url' => '/load', 'verb' => 'GET'],
25+
]
26+
];

0 commit comments

Comments
 (0)