use Mojo::UserAgent instead of Mojo::Client
[angular-mojolicious.git] / README
1 REST JSONP server using mojolicious for <angular/>
2
3
4 <angular/>: Complex web apps made simple
5 http://angularjs.org/
6
7
8 mojolicious: the web in the box!
9 http://mojolicious.org/
10
11
12 This is my attempt to implement REST API described at:
13
14 http://docs.getangular.com/REST.Basic
15
16 using CouchDB HTTP view API
17
18 http://wiki.apache.org/couchdb/HTTP_view_API
19
20 to provide storage for experimenting with local datasets using angular $resource API.
21 You can also query CouchDB views $xhr("JSON", ...) in angular through angular-server.pl
22
23
24 At it's current stage it provides support for angular $resource get, query and $save
25
26 http://angularjs.org/Service:$resource
27
28
29 Data can also be serve static json files stored in:
30
31         public/json/:database/:entity/:key
32
33 which can be used to provide data using external stand-alone scripts.
34
35
36
37 Replication of data between instances using angular REST API can be done with:
38
39         # create local CouchDB database
40         $ curl -X PUT http://localhost:5984/demo
41         {"ok":true}
42
43         $ ./angular-replicate.pl \
44                 http://dpavlin.getangular.com/data/conference \
45                 http://localhost:3000/data/demo
46
47 Replication is currently good only for initial import of data since it doesn't
48 support incremental replication and dies if data is allready present.
49
50
51 Installation:
52
53         $ git submodule init
54         $ git submodule update
55
56 Optionally build angular to get single file download
57
58         $ cd public/angular
59         $ rake compile
60         $ cd -
61
62 Start it with:
63
64         $ ./angular-server.pl daemon --reload  
65
66
67 Angular examples available:
68
69 - template/Cookbook - examples from wiki working against github version of angular
70 - template/conferece - conference submission example using mojolicious REST API server
71 - public/app/conference - new application layout with latest example confernce submission
72
73         $ curl -X PUT http://localhost:5984/conference/_design/symposium \
74                 -d @public/app/conference/_design/symposium
75
76
77
78 CouchDB examples:
79
80         couchdb-changes.pl - simple _changes feed watcher using Mojo::UserAgent documented at
81
82                 http://wiki.apache.org/couchdb/HTTP_database_API#Changes
83
84
85         couchdb-trigger.pl - FSM document with hook for user-defiend triggers
86
87                 trigger/shell.pm - execute shell commands
88                 trigger/email.pm - skeleton for sending e-email
89                 trigger/KinoSearch.pm - full-text search
90
91         $ curl -X PUT http://localhost:5984/demo
92         {"ok":true}
93
94         $ ./couchdb-trigger.pl http://localhost:5984/demo trigger/shell.pm
95
96         $ curl -X POST http://localhost:5984/demo/ -H 'Content-type:application/json' -d \
97                 '{"trigger":{"command":"notify-send \"CouchDB trigger notify example\""}}'
98
99
100         couchdb-external-kinosearch.pl - external searcher for KinoSearch indexes
101                 (configuration for CouchDB is included at end of file)
102
103         $ ./couchdb-trigger.pl http://localhost:5984/demo trigger/KinoSearch.pm
104
105         $ curl -X PUT http://localhost:5984/demo/text -d '{"text":"foobar bla bla"}'
106         {"ok":true,"id":"text","rev":"1-cf9bb608f93af7f4e5e40656a6e50096"}
107
108         $ curl 'http://localhost:5984/demo/_kinosearch?include_docs=true;q=foobar'
109
110
111
112 Roadmap:
113
114 + implement angular-server.pl which implements REST API supported by $resource in angular
115 + persistency to local CouchDB, and use views to query data
116 + implement CouchDB _changes and FSM inside document as base for queue or triggers
117 - tests