diff --git a/README.md b/README.md index db533a2..033d6b4 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,41 @@ -# How start the project +## Cotize -## Prerequises +Also known as "Bons comptes" is a java web app that helps friends to collect pledges in order to buy gift for birthday or other events. +- Cotize do not collect any money, just pledges. So make sure your friends are trustworthy :) +- Cotize is released under a derivate licence of the [WTFPL](http://www.wtfpl.net). So you can do anything you want to with it -- Java 8 +### Installation +#### Prerequises +- JDK8 +- Maven - MongoDB -## Actions +#### Get, Build, Run +1. Get: `git clone https://github.com/barmic/cotize.git` +2. Go to main folder: `cd cotize` +3. Configure by editing file: `./infra/run-config.json` (See below for config examples) +4. Buid: `mvn clean package` +5. Run: `java -jar target/BonsComptes-jar-with-dependencies.jar -conf run-config.json` +6. Test by accessing: http://localhost:5000/ -- Require : JDK8, Apache Maven -- To build run : mvn clean package -- Run application : java -jar target/BonsComptes-jar-with-dependencies.jar -conf run-config.json -- Access http://localhost:5000/ - -### Example of run-config.json +#### Example of run-config.json ```json { - "root_secret" : "abcdefghijkl", + "root_secret" : "abcdefghijkl", "base_url": "http://localhost:5000", "mail" : { "user" : "user@example.com", "password" : "", "port" : 465, - "host" : "smtp.example.com" + "host" : "smtp.example.com", + "use_ssl" : true }, "mongo" : { - "host" : "localhost", - "port" : 27017, - "collection" : "CotizeEvents", - "dbname" : "bonscomptes" + "host" : "localhost", + "port" : 27017, + "collection" : "CotizeEvents", + "dbname" : "bonscomptes" } } ``` @@ -37,3 +44,16 @@ - base_url : url used for link send by mail - mail : informations for send email - mongo : informations to access to mongodb + +#### Mail settings in run-config.js + +| | Gmail | Lilo | +|----------|----------------|---------------| +| user | user@gmail.com | user@lilo.org | +| password | password | password | +| port | 465 | 587 | +| host | smtp.gmail.com | mail.lilo.org | +| use_ssl | true | false | + +### Install Cotize as a Linux service +TODO diff --git a/backend/src/main/java/net/bons/comptes/integration/VertxModule.java b/backend/src/main/java/net/bons/comptes/integration/VertxModule.java index 444cbf5..aac9052 100644 --- a/backend/src/main/java/net/bons/comptes/integration/VertxModule.java +++ b/backend/src/main/java/net/bons/comptes/integration/VertxModule.java @@ -128,8 +128,8 @@ MongoClient provideMongoClient(Vertx vertx) { MailClient provideMailClient() { JsonObject mailConfig = this.config.getJsonObject("mail"); MailConfig config = new MailConfig().setHostname(mailConfig.getString("host")) - .setSsl(true) - .setPort(mailConfig.getInteger("port")) + .setSsl(mailConfig.getBoolean("use_ssl", true)) + .setPort(mailConfig.getInteger("port", 587)) .setUsername(mailConfig.getString("user")) .setPassword(mailConfig.getString("password")); diff --git a/backend/src/main/resources/cotize-js/event_store-proxy.js b/backend/src/main/resources/cotize-js/event_store-proxy.js new file mode 100644 index 0000000..02387bc --- /dev/null +++ b/backend/src/main/resources/cotize-js/event_store-proxy.js @@ -0,0 +1,75 @@ +/* + * Copyright 2014 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/** @module cotize-js/event_store */ +!function (factory) { + if (typeof require === 'function' && typeof module !== 'undefined') { + factory(); + } else if (typeof define === 'function' && define.amd) { + // AMD loader + define('cotize-js/event_store-proxy', [], factory); + } else { + // plain old include + EventStore = factory(); + } +}(function () { + + /** + @class + */ + var EventStore = function(eb, address) { + + var j_eb = eb; + var j_address = address; + var closed = false; + var that = this; + var convCharCollection = function(coll) { + var ret = []; + for (var i = 0;i < coll.length;i++) { + ret.push(String.fromCharCode(coll[i])); + } + return ret; + }; + + /** + + @public + @param projectId {string} + @param resultHandler {function} + */ + this.loadEvents = function(projectId, resultHandler) { + var __args = arguments; + if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') { + if (closed) { + throw new Error('Proxy is closed'); + } + j_eb.send(j_address, {"projectId":__args[0]}, {"action":"loadEvents"}, function(err, result) { __args[1](err, result &&result.body); }); + return; + } else throw new TypeError('function invoked with invalid arguments'); + }; + + }; + + if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = EventStore; + } else { + exports.EventStore = EventStore; + } + } else { + return EventStore; + } +}); \ No newline at end of file diff --git a/backend/src/main/resources/cotize-js/event_store.js b/backend/src/main/resources/cotize-js/event_store.js new file mode 100644 index 0000000..f6e7aa6 --- /dev/null +++ b/backend/src/main/resources/cotize-js/event_store.js @@ -0,0 +1,59 @@ +/* + * Copyright 2014 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +/** @module cotize-js/event_store */ +var utils = require('vertx-js/util/utils'); + +var io = Packages.io; +var JsonObject = io.vertx.core.json.JsonObject; +var JEventStore = net.bons.comptes.service.EventStore; +var DecisionProjectionProject = net.bons.comptes.service.model.DecisionProjectionProject; + +/** + @class +*/ +var EventStore = function(j_val) { + + var j_eventStore = j_val; + var that = this; + + /** + + @public + @param projectId {string} + @param resultHandler {function} + */ + this.loadEvents = function(projectId, resultHandler) { + var __args = arguments; + if (__args.length === 2 && typeof __args[0] === 'string' && typeof __args[1] === 'function') { + j_eventStore["loadEvents(java.lang.String,io.vertx.core.Handler)"](projectId, function(ar) { + if (ar.succeeded()) { + resultHandler(utils.convReturnDataObject(ar.result()), null); + } else { + resultHandler(null, ar.cause()); + } + }); + } else throw new TypeError('function invoked with invalid arguments'); + }; + + // A reference to the underlying Java delegate + // NOTE! This is an internal API and must not be used in user code. + // If you rely on this property your code is likely to break if we change it / remove it without warning. + this._jdel = j_eventStore; +}; + +// We export the Constructor function +module.exports = EventStore; \ No newline at end of file diff --git a/backend/src/main/resources/public/fav.ico b/backend/src/main/resources/public/fav.ico new file mode 100644 index 0000000..a92e980 Binary files /dev/null and b/backend/src/main/resources/public/fav.ico differ diff --git a/backend/src/main/resources/public/index.html b/backend/src/main/resources/public/index.html index ddb9a9d..91df2ff 100644 --- a/backend/src/main/resources/public/index.html +++ b/backend/src/main/resources/public/index.html @@ -1,5 +1,5 @@ - + + + + + + + + + + - - + - - -
-
- \ No newline at end of file + diff --git a/backend/src/main/resources/public/js/angular-trix.min.js b/backend/src/main/resources/public/js/angular-trix.min.js new file mode 100644 index 0000000..7f092be --- /dev/null +++ b/backend/src/main/resources/public/js/angular-trix.min.js @@ -0,0 +1,4 @@ +/*! angular-trix - v1.0.0 - 2015-12-09 +* https://github.com/sachinchoolur/angular-trix +* Copyright (c) 2015 Sachin; Licensed MIT */ +!function(){"use strict";angular.module("angularTrix",[]).directive("angularTrix",function(){return{restrict:"A",require:"ngModel",scope:{trixInitialize:"&",trixChange:"&",trixSelectionChange:"&",trixFocus:"&",trixBlur:"&",trixFileAccept:"&",trixAttachmentAdd:"&",trixAttachmentRemove:"&"},link:function(a,b,c,d){b.on("trix-initialize",function(){d.$modelValue&&b[0].editor.loadHTML(d.$modelValue)}),d.$render=function(){b[0].editor&&b[0].editor.loadHTML(d.$modelValue),b.on("trix-change",function(){d.$setViewValue(b.html())})};var e=function(d,e){b[0].addEventListener(d,function(f){"trix-file-accept"===d&&"true"===c.preventTrixFileAccept&&f.preventDefault(),a[e]({e:f,editor:b[0].editor})})};e("trix-initialize","trixInitialize"),e("trix-change","trixChange"),e("trix-selection-change","trixSelectionChange"),e("trix-focus","trixFocus"),e("trix-blur","trixBlur"),e("trix-file-accept","trixFileAccept"),e("trix-attachment-add","trixAttachmentAdd"),e("trix-attachment-remove","trixAttachmentRemove")}}})}(); \ No newline at end of file diff --git a/backend/src/main/resources/public/js/cotizeModule.js b/backend/src/main/resources/public/js/cotizeModule.js index 4c31309..5d63bc9 100644 --- a/backend/src/main/resources/public/js/cotizeModule.js +++ b/backend/src/main/resources/public/js/cotizeModule.js @@ -1,5 +1,7 @@ var cotizeModule = angular.module('cotizeApp', [ 'ngRoute', + 'ngSanitize', + 'angularTrix', 'cotizeControllers' ]); @@ -29,4 +31,4 @@ cotizeModule.config(['$routeProvider', otherwise({ redirectTo: '/index' }); - }]); \ No newline at end of file + }]); diff --git a/backend/src/main/resources/public/partials/contribution.html b/backend/src/main/resources/public/partials/contribution.html index b62091c..d06780b 100644 --- a/backend/src/main/resources/public/partials/contribution.html +++ b/backend/src/main/resources/public/partials/contribution.html @@ -4,9 +4,9 @@ -->

{{ project.content.name }}

-

{{ project.content.description }}

+

-

Contribution de {{ contribution.author }}

+

Contributions

Le projet a déjà réunis {{ project.content.amount }} € !

-
+
+

{{ contribution.author }}, participez

-
- -
- - +
+
+
+ +
+ + +
+
-
-
-
diff --git a/backend/src/main/resources/public/partials/main.html b/backend/src/main/resources/public/partials/main.html index 324949d..865fc3d 100644 --- a/backend/src/main/resources/public/partials/main.html +++ b/backend/src/main/resources/public/partials/main.html @@ -38,48 +38,40 @@

Créer un projet

-
-
- - -
- -
-
-
- - -
- -
+
+
+ +
-
- +
-
- - -
+
+
+ +
-
-
- -
- -
+
+
+ +
-
- + +
+ +
+ + +
-
\ No newline at end of file +
diff --git a/backend/src/main/resources/public/partials/project.html b/backend/src/main/resources/public/partials/project.html index 40ed071..554733b 100644 --- a/backend/src/main/resources/public/partials/project.html +++ b/backend/src/main/resources/public/partials/project.html @@ -4,7 +4,7 @@ -->

{{project.content.name}}

-

{{project.content.description}}

+

Contributions

Le projet a déjà réunis {{project.content.amount}} € !

@@ -30,36 +30,28 @@

Contributions

Participez

-
-
+
+
-
- -
+
-
+
- +
-
+
@ - +
-

- Permet d'éditer votre contribution -

-
-
-
-
- + Permet d'éditer votre contribution.
-
+
+
diff --git a/infra/run-config.json b/infra/run-config.json index 5d12668..258d11a 100644 --- a/infra/run-config.json +++ b/infra/run-config.json @@ -1,11 +1,12 @@ { - "root_secret" : "azerty", + "root_secret" : "azerty", "base_url": "http://localhost:5000", "mail" : { - "user" : "@gmail.com", + "user" : "", "password" : "", "port" : 465, - "host" : "smtp.gmail.com" + "host" : "", + "use_ssl" : true }, "mongo" : { "host" : "localhost", @@ -13,4 +14,4 @@ "collection" : "CotizeEvents", "dbname" : "bonscomptes" } -} \ No newline at end of file +}