1 | # Americano Cozy
|
2 |
|
3 | When you want to write [Cozy](http://cozy.io) applications with
|
4 | [Americano](https://github.com/frankrousseau/americano), you don't have the
|
5 | good helpers to write your models. Here are some that could make your life
|
6 | easier, notably about declaring your requests.
|
7 |
|
8 | ## Getting Started
|
9 |
|
10 | Add americano-cozy to the list of your plugins in the Americano configuration file. Then add it as a dependency of your project:
|
11 |
|
12 | npm install americano-cozy -g
|
13 |
|
14 |
|
15 | ## Models
|
16 |
|
17 | Do no think about including JugglingDB and its configuration for Cozy
|
18 | anymore, Americano Cozy does the job for you:
|
19 |
|
20 |
|
21 | ```coffeescript
|
22 | americano = require 'americano-cozy'
|
23 |
|
24 | module.exports = americano.getModel 'Task',
|
25 | done: Boolean
|
26 | completionDate: Date
|
27 | ```
|
28 |
|
29 | ## Requests
|
30 |
|
31 | Describe your Data System requests in a single file:
|
32 |
|
33 | ```coffeescript
|
34 | # server/models/requests.coffee
|
35 | americano = require 'americano-cozy'
|
36 |
|
37 | module.exports =
|
38 | task:
|
39 | all: americano.defaultRequests.all
|
40 | analytics:
|
41 | map: (doc) ->
|
42 | if doc.completionDate? and doc.done
|
43 | date = new Date doc.completionDate
|
44 | dateString = "#{date.getFullYear()}-"
|
45 | dateString += "#{date.getMonth() + 1}-#{date.getDate()}"
|
46 | emit dateString, 1
|
47 | reduce: (key, values, rereduce) ->
|
48 | sum values
|
49 | ```
|
50 |
|
51 | ## What about contributions?
|
52 |
|
53 | Here is what I would like to do next:
|
54 |
|
55 | * write tests
|
56 | * remove async from the dependency (use recursive functions instead)
|
57 | * make Data System URL configurable
|
58 |
|
59 | I didn't start any development yet, so you're welcome to participate!
|
60 |
|
61 | ## What is Cozy?
|
62 |
|
63 | ![Cozy Logo](https://raw.github.com/mycozycloud/cozy-setup/gh-pages/assets/images/happycloud.png)
|
64 |
|
65 | [Cozy](http://cozy.io) is a platform that brings all your web services in the
|
66 | same private space. With it, your web apps and your devices can share data
|
67 | easily, providing you
|
68 | with a new experience. You can install Cozy on your own hardware where no one
|
69 | profiles you. You install only the applications you want. You can build your
|
70 | own one too.
|
71 |
|
72 | ## Community
|
73 |
|
74 | You can reach the Cozy community via various support:
|
75 |
|
76 | * IRC #cozycloud on irc.freenode.net
|
77 | * Post on our [Forum](https://groups.google.com/forum/?fromgroups#!forum/cozy-cloud)
|
78 | * Post issues on the [Github repos](https://github.com/mycozycloud/)
|
79 | * Via [Twitter](http://twitter.com/mycozycloud)
|