add build system (gulp)

This commit is contained in:
Hendrik Leppelsack 2015-10-27 18:52:09 +01:00
parent 62b3d5b626
commit 3bf54638eb
15 changed files with 344 additions and 165 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

13
gulpfile.js Normal file
View File

@ -0,0 +1,13 @@
var gulp = require('gulp'),
concat = require('gulp-concat'),
notify = require('gulp-notify');
gulp.task('scripts', function() {
return gulp.src([
'js/main.js',
'js/components/**/*.js'
])
.pipe(concat('script.js'))
.pipe(gulp.dest('js/public'))
.pipe(notify({message: 'Scripts task complete'}));
});

View File

@ -0,0 +1,3 @@
app.controller('addressbookCtrl', function() {
var ctrl = this;
});

View File

@ -0,0 +1,13 @@
app.directive('addressbook', function() {
return {
restrict: 'E',
scope: {},
controller: 'addressbookCtrl',
controllerAs: 'ctrl',
bindToController: {
addressBook: "=data"
},
templateUrl: OC.linkTo('contactsrework', 'templates/addressBook.html')
}
});

View File

@ -0,0 +1,9 @@
app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', function(scope, AddressBookService) {
var ctrl = this;
AddressBookService.then(function(addressBooks) {
scope.$apply(function() {
ctrl.addressBooks = addressBooks;
});
});
}]);

View File

@ -0,0 +1,9 @@
app.directive('addressbooklist', function() {
return {
scope: {},
controller: 'addressbooklistCtrl',
controllerAs: 'ctrl',
bindToController: {},
templateUrl: OC.linkTo('contactsrework', 'templates/addressBookList.html')
}
});

View File

@ -0,0 +1,6 @@
app.controller('contactCtrl', ['$filter', function($filter) {
var ctrl = this;
console.log($filter('vCard2JSON')(ctrl.data.addressData));
}]);

View File

@ -0,0 +1,11 @@
app.directive('contact', function() {
return {
scope: {},
controller: 'contactCtrl',
controllerAs: 'ctrl',
bindToController: {
data: '='
},
templateUrl: OC.linkTo('contactsrework', 'templates/contact.html')
}
});

View File

@ -0,0 +1,3 @@
app.controller('contactlistCtrl', function() {
var ctrl = this;
});

View File

@ -0,0 +1,12 @@
app.directive('contactlist', function() {
return {
priority: 1,
scope: {},
controller: 'contactlistCtrl',
controllerAs: 'ctrl',
bindToController: {
addressbook: '='
},
templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html')
};
});

86
js/main.js Normal file
View File

@ -0,0 +1,86 @@
/**
* ownCloud - contactsrework
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Hendrik Leppelsack <hendrik@leppelsack.de>
* @copyright Hendrik Leppelsack 2015
*/
var app = angular.module('contactsApp', ['ui.router']);
app.run(function($rootScope) {
$rootScope.addressBooks = [];
});
app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
template: '<div>Home</div>'
})
.state('contactlist',{
url: '/:addressBookId',
template: '<contactlist data-addressbook="addressBook"></contactlist>',
resolve: {
addressBook: function(AddressBookService, DavClient, $stateParams) {
return AddressBookService.then(function (addressBooks) {
var addressBook = addressBooks.filter(function (element) {
return element.displayName === $stateParams.addressBookId;
})[0];
return DavClient.syncAddressBook(addressBook, {accept: 'application/vCard+json'});
}).then(function (addressBook) {
return addressBook;
});
}
},
controller: function($scope, addressBook) {
$scope.addressBook = addressBook;
}
})
}]);
app.service('DavClient', function() {
var xhr = new dav.transport.Basic(
new dav.Credentials()
);
return new dav.Client(xhr);
});
app.service('DavService', ['DavClient', function(client) {
return client.createAccount({
server: OC.linkToRemoteBase('carddav'),
accountType: 'carddav'
});
}]);
app.service('AddressBookService', ['DavService', function(DavService){
return DavService.then(function(account) {
return account.addressBooks;
});
}]);
app.filter('JSON2vCard', function() {
return vCard.generate;
});
app.filter('vCard2JSON', function() {
return function(input, prop) {
var result = vCard.parse(input);
if(prop === undefined) {
return result;
}
if(result[prop] === undefined) {
return undefined;
}
result = result[prop][0];
if(result.value instanceof Array) {
return result.value.join(' ');
} else {
return result.value;
}
}
});

153
js/public/script.js Normal file
View File

@ -0,0 +1,153 @@
/**
* ownCloud - contactsrework
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Hendrik Leppelsack <hendrik@leppelsack.de>
* @copyright Hendrik Leppelsack 2015
*/
var app = angular.module('contactsApp', ['ui.router']);
app.run(function($rootScope) {
$rootScope.addressBooks = [];
});
app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
template: '<div>Home</div>'
})
.state('contactlist',{
url: '/:addressBookId',
template: '<contactlist data-addressbook="addressBook"></contactlist>',
resolve: {
addressBook: function(AddressBookService, DavClient, $stateParams) {
return AddressBookService.then(function (addressBooks) {
var addressBook = addressBooks.filter(function (element) {
return element.displayName === $stateParams.addressBookId;
})[0];
return DavClient.syncAddressBook(addressBook, {accept: 'application/vCard+json'});
}).then(function (addressBook) {
return addressBook;
});
}
},
controller: function($scope, addressBook) {
$scope.addressBook = addressBook;
}
})
}]);
app.service('DavClient', function() {
var xhr = new dav.transport.Basic(
new dav.Credentials()
);
return new dav.Client(xhr);
});
app.service('DavService', ['DavClient', function(client) {
return client.createAccount({
server: OC.linkToRemoteBase('carddav'),
accountType: 'carddav'
});
}]);
app.service('AddressBookService', ['DavService', function(DavService){
return DavService.then(function(account) {
return account.addressBooks;
});
}]);
app.filter('JSON2vCard', function() {
return vCard.generate;
});
app.filter('vCard2JSON', function() {
return function(input, prop) {
var result = vCard.parse(input);
if(prop === undefined) {
return result;
}
if(result[prop] === undefined) {
return undefined;
}
result = result[prop][0];
if(result.value instanceof Array) {
return result.value.join(' ');
} else {
return result.value;
}
}
});
app.controller('addressbookCtrl', function() {
var ctrl = this;
});
app.directive('addressbook', function() {
return {
restrict: 'E',
scope: {},
controller: 'addressbookCtrl',
controllerAs: 'ctrl',
bindToController: {
addressBook: "=data"
},
templateUrl: OC.linkTo('contactsrework', 'templates/addressBook.html')
}
});
app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', function(scope, AddressBookService) {
var ctrl = this;
AddressBookService.then(function(addressBooks) {
scope.$apply(function() {
ctrl.addressBooks = addressBooks;
});
});
}]);
app.directive('addressbooklist', function() {
return {
scope: {},
controller: 'addressbooklistCtrl',
controllerAs: 'ctrl',
bindToController: {},
templateUrl: OC.linkTo('contactsrework', 'templates/addressBookList.html')
}
});
app.controller('contactCtrl', ['$filter', function($filter) {
var ctrl = this;
console.log($filter('vCard2JSON')(ctrl.data.addressData));
}]);
app.directive('contact', function() {
return {
scope: {},
controller: 'contactCtrl',
controllerAs: 'ctrl',
bindToController: {
data: '='
},
templateUrl: OC.linkTo('contactsrework', 'templates/contact.html')
}
});
app.controller('contactlistCtrl', function() {
var ctrl = this;
});
app.directive('contactlist', function() {
return {
priority: 1,
scope: {},
controller: 'contactlistCtrl',
controllerAs: 'ctrl',
bindToController: {
addressbook: '='
},
templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html')
};
});

View File

@ -1,164 +0,0 @@
/**
* ownCloud - contactsrework
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Hendrik Leppelsack <hendrik@leppelsack.de>
* @copyright Hendrik Leppelsack 2015
*/
(function (OC, angular, $, vCard) {
var app = angular.module('contactsApp', ['ui.router']);
app.run(function($rootScope) {
$rootScope.addressBooks = [];
});
app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
template: '<div>Home</div>'
})
.state('contactlist',{
url: '/:addressBookId',
template: '<contactlist data-addressbook="addressBook"></contactlist>',
resolve: {
addressBook: function(AddressBookService, DavClient, $stateParams) {
return AddressBookService.then(function (addressBooks) {
var addressBook = addressBooks.filter(function (element) {
return element.displayName === $stateParams.addressBookId;
})[0];
return DavClient.syncAddressBook(addressBook, {accept: 'application/vCard+json'});
}).then(function (addressBook) {
return addressBook;
});
}
},
controller: function($scope, addressBook) {
$scope.addressBook = addressBook;
}
})
}]);
app.service('DavClient', function() {
var xhr = new dav.transport.Basic(
new dav.Credentials()
);
return new dav.Client(xhr);
});
app.service('DavService', ['DavClient', function(client) {
return client.createAccount({
server: OC.linkToRemoteBase('carddav'),
accountType: 'carddav'
});
}]);
app.service('AddressBookService', ['DavService', function(DavService){
return DavService.then(function(account) {
return account.addressBooks;
});
}]);
app.directive('addressbooklist', function() {
return {
scope: {},
controller: 'addressbooklistCtrl',
controllerAs: 'ctrl',
bindToController: {},
templateUrl: OC.linkTo('contactsrework', 'templates/addressBookList.html')
}
});
app.directive('addressbook', function() {
return {
restrict: 'E',
scope: {},
controller: 'addressbookCtrl',
controllerAs: 'ctrl',
bindToController: {
addressBook: "=data"
},
templateUrl: OC.linkTo('contactsrework', 'templates/addressBook.html')
}
});
app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', function(scope, AddressBookService) {
var ctrl = this;
AddressBookService.then(function(addressBooks) {
scope.$apply(function() {
ctrl.addressBooks = addressBooks;
});
});
}]);
app.controller('addressbookCtrl', function() {
var ctrl = this;
});
app.directive('contactlist', function() {
return {
priority: 1,
scope: {},
controller: 'contactlistCtrl',
controllerAs: 'ctrl',
bindToController: {
addressbook: '='
},
templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html')
};
});
app.controller('contactlistCtrl', function() {
var ctrl = this;
});
app.directive('contact', function() {
return {
scope: {},
controller: 'contactCtrl',
controllerAs: 'ctrl',
bindToController: {
data: '='
},
templateUrl: OC.linkTo('contactsrework', 'templates/contact.html')
}
});
app.controller('contactCtrl', ['$filter', function($filter) {
var ctrl = this;
console.log($filter('vCard2JSON')(ctrl.data.addressData));
}]);
app.filter('JSON2vCard', function() {
return vCard.generate;
});
app.filter('vCard2JSON', function() {
return function(input, prop) {
var result = vCard.parse(input);
if(prop === undefined) {
return result;
}
if(result[prop] === undefined) {
return undefined;
}
result = result[prop][0];
if(result.value instanceof Array) {
return result.value.join(' ');
} else {
return result.value;
}
}
});
})(OC, angular, jQuery, vCard);

24
package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "contactsrework",
"version": "0.1.0",
"description": "Place this app in **owncloud/apps/**",
"author": {
"name": "Hendrik Leppelsack",
"email": "hendrik@leppelsack.de"
},
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/Henni/contactsrework.git"
},
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/Henni/contactsrework/issues"
},
"homepage": "https://github.com/Henni/contactsrework#readme",
"devDependencies": {
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-notify": "^2.2.0"
}
}

View File

@ -3,7 +3,7 @@ script('contactsrework', 'vendor/angular/angular');
script('contactsrework', 'vendor/angular-ui-router/release/angular-ui-router');
script('contactsrework', 'vendor/dav/dav');
script('contactsrework', 'vendor/vcard/src/vcard');
script('contactsrework', 'script');
script('contactsrework', 'public/script');
style('contactsrework', 'style');
?>