Skip to content

Commit da98367

Browse files
committed
Initial commit
0 parents  commit da98367

File tree

20 files changed

+1209
-0
lines changed

20 files changed

+1209
-0
lines changed

.travis.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
sudo: false
2+
dist: trusty
3+
language: php
4+
php:
5+
- 5.6
6+
- 7
7+
- 7.1
8+
env:
9+
global:
10+
- CORE_BRANCH=stable14
11+
matrix:
12+
- DB=pgsql
13+
14+
matrix:
15+
allow_failures:
16+
- env: DB=pgsql CORE_BRANCH=master
17+
include:
18+
- php: 5.6
19+
env: DB=sqlite
20+
- php: 5.6
21+
env: DB=mysql
22+
- php: 5.6
23+
env: DB=pgsql CORE_BRANCH=master
24+
fast_finish: true
25+
26+
27+
before_install:
28+
# enable a display for running JavaScript tests
29+
- export DISPLAY=:99.0
30+
- sh -e /etc/init.d/xvfb start
31+
- nvm install 8
32+
- npm install -g npm@latest
33+
- make
34+
- make appstore
35+
# install core
36+
- cd ../
37+
- git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b $CORE_BRANCH nextcloud
38+
- mv "$TRAVIS_BUILD_DIR" nextcloud/apps/timetracker
39+
40+
before_script:
41+
- if [[ "$DB" == 'pgsql' ]]; then createuser -U travis -s oc_autotest; fi
42+
- if [[ "$DB" == 'mysql' ]]; then mysql -u root -e 'create database oc_autotest;'; fi
43+
- if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY '';"; fi
44+
- if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "grant all on oc_autotest.* to 'oc_autotest'@'localhost';"; fi
45+
- cd nextcloud
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 timetracker
49+
- php -S localhost:8080 &
50+
- cd apps/timetracker
51+
52+
script:
53+
- make test
54+
55+
after_failure:
56+
- cat ../../data/nextcloud.log
57+
58+
addons:
59+
firefox: 'latest'
60+
mariadb: '10.1'
61+
62+
services:
63+
- postgresql
64+
- mariadb

COPYING

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

Makefile

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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 2016
5+
6+
# Generic Makefile for building and packaging a Nextcloud 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+
rm -rf $(source_build_directory)
117+
mkdir -p $(source_build_directory)
118+
tar cvzf $(source_package_name).tar.gz ../$(app_name) \
119+
--exclude-vcs \
120+
--exclude="../$(app_name)/build" \
121+
--exclude="../$(app_name)/js/node_modules" \
122+
--exclude="../$(app_name)/node_modules" \
123+
--exclude="../$(app_name)/*.log" \
124+
--exclude="../$(app_name)/js/*.log" \
125+
126+
# Builds the source package for the app store, ignores php and js tests
127+
.PHONY: appstore
128+
appstore:
129+
rm -rf $(appstore_build_directory)
130+
mkdir -p $(appstore_build_directory)
131+
tar cvzf $(appstore_package_name).tar.gz ../$(app_name) \
132+
--exclude-vcs \
133+
--exclude="../$(app_name)/build" \
134+
--exclude="../$(app_name)/tests" \
135+
--exclude="../$(app_name)/Makefile" \
136+
--exclude="../$(app_name)/*.log" \
137+
--exclude="../$(app_name)/phpunit*xml" \
138+
--exclude="../$(app_name)/composer.*" \
139+
--exclude="../$(app_name)/js/node_modules" \
140+
--exclude="../$(app_name)/js/tests" \
141+
--exclude="../$(app_name)/js/test" \
142+
--exclude="../$(app_name)/js/*.log" \
143+
--exclude="../$(app_name)/js/package.json" \
144+
--exclude="../$(app_name)/js/bower.json" \
145+
--exclude="../$(app_name)/js/karma.*" \
146+
--exclude="../$(app_name)/js/protractor.*" \
147+
--exclude="../$(app_name)/package.json" \
148+
--exclude="../$(app_name)/bower.json" \
149+
--exclude="../$(app_name)/karma.*" \
150+
--exclude="../$(app_name)/protractor\.*" \
151+
--exclude="../$(app_name)/.*" \
152+
--exclude="../$(app_name)/js/.*" \
153+
154+
.PHONY: test
155+
test: composer
156+
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c phpunit.xml
157+
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c phpunit.integration.xml

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Time Tracker
2+
Place this app in **nextcloud/apps/**
3+
4+
## Building the app
5+
6+
The app can be built by using the provided Makefile by running:
7+
8+
make
9+
10+
This requires the following things to be present:
11+
* make
12+
* which
13+
* tar: for building the archive
14+
* curl: used if phpunit and composer are not installed to fetch them from the web
15+
* npm: for building and testing everything JS, only required if a package.json is placed inside the **js/** folder
16+
17+
The make command will install or update Composer dependencies if a composer.json is present and also **npm run build** if a package.json is present in the **js/** folder. The npm **build** script should use local paths for build systems and package managers, so people that simply want to build the app won't need to install npm libraries globally, e.g.:
18+
19+
**package.json**:
20+
```json
21+
"scripts": {
22+
"test": "node node_modules/gulp-cli/bin/gulp.js karma",
23+
"prebuild": "npm install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
24+
"build": "node node_modules/gulp-cli/bin/gulp.js"
25+
}
26+
```
27+
28+
29+
## Publish to App Store
30+
31+
First get an account for the [App Store](http://apps.nextcloud.com/) then run:
32+
33+
make && make appstore
34+
35+
The archive is located in build/artifacts/appstore and can then be uploaded to the App Store.
36+
37+
## Running tests
38+
You can use the provided Makefile to run all tests by using:
39+
40+
make test
41+
42+
This will run the PHP unit and integration tests and if a package.json is present in the **js/** folder will execute **npm run test**
43+
44+
Of course you can also install [PHPUnit](http://phpunit.de/getting-started.html) and use the configurations directly:
45+
46+
phpunit -c phpunit.xml
47+
48+
or:
49+
50+
phpunit -c phpunit.integration.xml
51+
52+
for integration tests

appinfo/info.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
4+
<id>timetracker</id>
5+
<name>Time Tracker</name>
6+
<summary>Time Tracker App</summary>
7+
<description><![CDATA[Time Tracker App]]></description>
8+
<version>0.0.1</version>
9+
<licence>agpl</licence>
10+
<author mail="[email protected]" >Valentin Zagura</author>
11+
<namespace>TimeTracker</namespace>
12+
<category>tools</category>
13+
<bugs>http://example.com</bugs>
14+
<dependencies>
15+
<nextcloud min-version="14" max-version="14"/>
16+
</dependencies>
17+
<navigations>
18+
<navigation>
19+
<name>Time Tracker</name>
20+
<route>timetracker.page.index</route>
21+
</navigation>
22+
</navigations>
23+
</info>

appinfo/routes.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Create your routes in here. The name is the lowercase name of the controller
4+
* without the controller part, the stuff after the hash is the method.
5+
* e.g. page#index -> OCA\TimeTracker\Controller\PageController->index()
6+
*
7+
* The controller class has to be registered in the application.php file since
8+
* it's instantiated in there
9+
*/
10+
return [
11+
'routes' => [
12+
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
13+
['name' => 'page#do_echo', 'url' => '/echo', 'verb' => 'POST'],
14+
]
15+
];

composer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "Time Tracker",
3+
"description": "Time Tracker App",
4+
"type": "project",
5+
"license": "AGPL",
6+
"authors": [
7+
{
8+
"name": "Valentin Zagura"
9+
}
10+
],
11+
"require": {},
12+
"require-dev": {
13+
"phpunit/phpunit": "^5.4"
14+
}
15+
}

css/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#hello {
2+
color: red;
3+
}

img/app.svg

Lines changed: 56 additions & 0 deletions
Loading

js/script.js

Whitespace-only changes.

0 commit comments

Comments
 (0)