This repo is a starting point to create a couchapp or an app for a garden market such as Garden20.
Fork me and modify!
This baseline has been carefully tweeked to make it easy to jump into writing apps. The technology choices have been carefully balanced for speed, flexibilty and ease of use. Here are some choices made:
- Using less for stylesheets, less is precompiled on the push.
- Including the baseline bootstrap less files.
- using jam to manage clientside dependecies.
- using handlebars for templating.
All of the above can be swapped out, but the owness will be on you to get the same benefit as we are providing with this baseline.
First off you will need a few things, you will need node
and npm
installed.
Kanso is the main tool for working with couchdb. It has great packages and provided the interface to the market.
npm install -g kanso
Jam will be used to manage the frontend dependencies. You actually might not need jam, because the dependencies are already in this repo. But if you want to add new dependencies, please use jam. Its fine to use other package managers as well. We just dont have time to show how to do so.
npm install -g jamjs
Follow the instructions here to get a garden for yourself.
You should now be ready to push this app to your garden. Try this:
kanso push http://127.0.0.1:5984/baseline
You should see a result like this:
Build complete: 900ms
Uploading...
OK: http://127.0.0.1/baseline/_design/baseline/_rewrite/
To visit the app type the following in your browser:
http://localhost:5984/baseline/_design/baseline/_rewrite/
There is a reason we use 127.0.0.1 for pushing and localhost for viewing. You can read about it here.
You can also minify your app, which means stylesheets and js into one file each, and greatly reduces. Push your app like this
kanso push http://127.0.0.1:5984/baseline --minify
Now that you have can push the app to your garden, you probably want to do your own work on it. Here are some things to do:
- Change the "name" property is probably the single most important thing to change off the bat. There is no namespacing and it should be globally unique so check that the name is not taken.
- Change the url to your github repo location
- Change the description and long description to match what you are building.
- Adjust the categories
- If you want to use flattr for payments, change the flattr_user_id. Or remove it otherwise.
At this point, please dont alter anything else.
The places you will most likely be editing are the following files:
js/app.js
which is your applications main entry point.css/app.less
which your stylesheet.templates/*
which will hold all of your templatescouch/ddoc.js
which is a couchdb design document.
After your app is all polished off, take some time to make some screenshots, icons, a favicon, and promotional images. Overwrite all the placeholder images in the img/promo
folder
You should push to a development market before you push to the main market. This will allow you to test installing your app before others see it.
Create an account, if you have not done so, at https://garden.iriscouch.com/garden/_design/garden/_rewrite/
Then push your app
kanso push https://garden.iriscouch.com/garden/_design/garden/_rewrite/upload --minify
You will need a 'developer' account. For now, just use futon to signup for an account here:
https://garden20.iriscouch.com/_utils/
Then push your app
kanso push http://garden20.com/market/upload --minify
You will be prompted for your username and password.
You will need to add it to the list of attachments in kanso.json
. eg
"attachments": ["css", "img", "jam", "js", "index.html", "application.appcache", "templates", "newfolder"],
If you add new files in the js dir that are not managed by jam, you will have to tell jam to minify them. Alter jam in kanso.json
. eg
"jam" : {
"include" : ["js/app", "domReady", "js/newfile]
}
Lets say your js library is called cooljs
jam install cooljs
Then modify your js/app.js
file as so:
define('js/app',[
'jquery',
'underscore',
'handlebars',
'couchr',
'garden-app-support',
'hbt!templates/test',
'cooljs'
],
function($, _, handlebars, couch, garden, template, cooljs){
....
cooljs.rule();
...
You can find available packages here: jamjs.org
If you dont find your cooljs library just bug someone on #jamjs and they will probably help you add it.
We turned this on by default so you will be aware of where to handle read security. Alter couch/ddoc.js
and modify the validate_doc_update function.