janl / cozy forked from gurdiga/cozy
- Source
- Commits
- Network (2)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
.couchapprc | Sun Jul 26 14:46:24 -0700 2009 | |
| |
.gitignore | Tue Oct 13 15:44:46 -0700 2009 | |
| |
.vimrc | Mon Sep 21 07:40:36 -0700 2009 | |
| |
README.md | Tue Oct 13 18:17:57 -0700 2009 | |
| |
TODO.txt | Thu Oct 15 08:29:08 -0700 2009 | |
| |
_attachments/ | Fri Oct 16 02:21:29 -0700 2009 | |
| |
lib/ | Fri Oct 16 02:21:29 -0700 2009 | |
| |
meta/ | Thu Oct 15 19:51:15 -0700 2009 | |
| |
shows/ | Tue Oct 13 17:45:49 -0700 2009 | |
| |
tests.sh | Thu Sep 24 13:45:31 -0700 2009 | |
| |
tests/ | Tue Oct 13 17:58:36 -0700 2009 | |
| |
tmp/ | Thu Oct 15 19:51:15 -0700 2009 | |
| |
upload.sh | Thu Oct 15 19:51:15 -0700 2009 | |
| |
validate_doc_update.js | Fri Aug 14 03:31:57 -0700 2009 | |
| |
vendor/ | Thu Oct 15 08:26:18 -0700 2009 |
General
- All this is built for CouchDB. Thanks to Damien KATZ (http://damienkatz.net).
- All this is built on top of CouchApp. Thanks to Benoit CHESNEAU (http://benoitc.org) and Chris ANDERSON (http://jchrisa.net).
Forms
In good old days everything was centered around forms: all the specs were centered by forms and I believe that this approach is still practical.
Meta-form - a complete JSON description of form
"Meta" - because it is a simple, DRY, and readable description. Here is a simple form field description:
title: {
type: "textbox",
label: "The title"
}
Here you can add validation rulles and messages:
title: {
type: "textbox",
label: "The title",
validation: {
rules: {
required: true,
maxlen: 50,
minlen: 5
},
messages: {
required: "The title is required."
}
}
}
The meta-form is a collection o such fields:
mata.form = {
title: {
...
},
description: {
...
},
...
}
This is the most part of the logic in the application. No doubt there will come more, let us see it and we will figuire out a way to encode. From this structure a homegrown script generates HTML. With CouchApp jQuery plugin the form saves the data in CoudhDB.
The validation data is going to be used on both the client and the server.
Technical details
(almost) All the code is written using TDD. Tests are included:
- tests.(js|sh)
- tests/*
To test the entire source tree run the tests.sh in the application root. To test any module run tests.(js|sh) at any level.
Acceptance tests use jQuery and its testing framework QUnit. Adding a new page to the app should start with writing an acceptance test that would define the page components and functionality.
To upload (couchapp push) it to CouchDB run upload.sh in the application root.
Less code
Generally the tool is trying to capture as much as possible in JSON description and use as less code as possible. Why? Compared to code, metadata is easier and less expensive to test.
Code structure
Most of the CouchApp initial app structure is left untouched. Besides that:
- "./meta/" - I keep most of the application logic;
- "./lib/" - added a couple of libs: jh, meta, test_runner (a test runner for the server-side Javascript code), and a tiny library of useful Javascript functions;
- "./vendor/" - added the JSON2 Javascript library;
Notes
- this is a work in progress, good ideas are welcome;
- Javascript scripts expect /usr/local/bin/js as interpretter, so on Linux just say: # ln -s /usr/bin/js /usr/local/bin/js.
