Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
ritch committed Oct 29, 2012
0 parents commit 43a270b
Show file tree
Hide file tree
Showing 889 changed files with 166,213 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "bootstrap"]
path = bootstrap
url = [email protected]:deployd/bootstrap.git
40 changes: 40 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

/**
* Module dependencies.
*/

var express = require('express')
, http = require('http')
, path = require('path');

app = express();

app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(require('./middleware/templates')(path.join(__dirname, 'views')))
app.use(app.router);
app.use(require('less-middleware')({ src: __dirname + '/public' }));
app.use(express.static(path.join(__dirname, 'public')));
});

app.configure('development', function(){
app.use(express.errorHandler());
});

require('./routes');

http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});

var Index = require('./indexer');
var index = app.index = new Index();
index.crawl('docs', function (cache) {
app.docs = cache;
});
1 change: 1 addition & 0 deletions bootstrap
Submodule bootstrap added at 357154
48 changes: 48 additions & 0 deletions docs/basics/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--{
title: 'The "dpd" command line tool'
}-->

### Using the dpd command line tool.

Here is the help output of `dpd -h`:

Usage: dpd [options] [command]

Commands:

create [project-name]
create a project in a new directory
eg. `dpd create my-app`

keygen
generate a key for remote access (./.dpd/keys.json)

showkey
shows current key for connecting to remote dashboard (./.dpd/keys.json)

remote
open the remote dashboard in your browser

deploy [subdomain]
deploy a testing instance on deploydapp.com

*
[default] start the server in the current project in development mode
with an interactive shell/repl for interacting with the running server
e.g. dpd (starts server in current directory),
dpd my-app/app.dpd (starts app from file)

Options:

-h, --help output usage information
-V, --version output the version number
-m, --mongod [path] path to mongod executable (defaults to `mongod`)
-p, --port [port] port to host server (defaults to 2403)
-w, --wait wait for input before exiting
-d, --dashboard start the dashboard immediately
-o, --open open in a browser
-e, --environment [env] defaults to development
-H, --host [host] specify host for mongo server
-P, --mongoPort [mongoPort] mongodb port to connect to
-n, --dbname [dbname] name of the mongo database
-a, --auth prompts for mongo server credentials
28 changes: 28 additions & 0 deletions docs/basics/hosting-on-deploydapp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--{
title: 'Hosting your API on deploydapp.com',
tags: ['guide', 'deploydapp']
}-->

## Hosting your API on deploydapp.com

When you want to share your app with the world, you can use Deployd's beta hosting service to host it online in seconds.

*Note: this service is heavily in development and will change drastically in the future*

In your Deployd app folder, type the command:

dpd deploy [subdomain]

If you do not provide a subdomain, it will automatically use the app's folder name.

*Note: if you recieve a "not allowed" error, it means that the subdomain you requested is in use by another app and you don't have the credentials to push to it. In that case, you choose another subdomain.*

When it is done, you can access your app at `[subdomain].deploydapp.com`.

## Accessing Your App's Dashboard

To access your app's dashboard (for example, to add data), you can go to `[subdomain].deploydapp.com/dashboard` or type `dpd remote`. The Dashboard will prompt you for a key, type `dpd showkey` to print this key to the console and paste it into the box.

## Working with collaborators

To provide additional collaborators access to push new versions and access the dashboard, you can copy the `deployments.json` and `keys.json` files out of your app's `.dpd` directory and give them to your collaborators. Your collaborators can then paste these files in their own `.dpd` directory and use the `deploy`, `remote`, and `showkey` commands.
16 changes: 16 additions & 0 deletions docs/basics/public.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--{
title: 'The Public Directory',
tags: ['guide']
}-->

## The Public Directory

Deployd serves static files from its public directory. This directory is created when you run `dpd create`. These files will be served with the appropriate cache headers (Last-Modified and Etag) so browsers will cache them.

### Environments

TODO




12 changes: 12 additions & 0 deletions docs/basics/source-control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--{
title: 'Using Source Control with Deployd',
tags: ['guide']
}-->

## Using Source Control with Deployd

Deployd projects are designed to be committed to version control systems so teams can easily manage the source of their applications.

### Recommended Ignored Files

You shouldn't commit the `/data` or `.dpd` directories. The files in these directories are environment specific and should be kept out of version control. All other deployd files should be committed.
26 changes: 26 additions & 0 deletions docs/data/accessing-collections/from-the-browser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Accessing Collections - From the Browser

This guide outlines the various ways you can access Collections from a browser.

### dpd.js

`dpd.js` is an auto-generated library that updates as you update the resources in your Deployd API. All you have to do is include a `<script src="/dpd.js"></script>` and you're browser has access to all your Deployd Collections.

#### Examples

The following examples use a Collection that was created at `/todos` and have the following schema.



### Backbone.js

### Angular.js

### jQuery

### CORS

Deployd sends all the required CORS headers by default to any domain (though this will become a setting in an upcoming version). The most common bug when implementing a CORS client for Deploy is to include headers that are not allowed. A client must not send any custom headers besides the following:


Origin, Accept, Accept-Language, Content-Language, Content-Type, Last-Event-ID
95 changes: 95 additions & 0 deletions docs/data/accessing-collections/over-http.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!--{
title: 'Accessing Collections - Over HTTP',
tags: ['reference', 'collection', 'http', 'websockets', 'cors']
}-->

## Accessing Collections - Over HTTP

In this guide we will build an HTTP client from scratch to perform CRUD as well as listen for events from a Collection.

### REST

Most REST clients should work with Deployd Collections right away, though Deployd does not strictly follow REST. For example, Backbone.js and Angular's http utilities work with Deployd without modification.

### WebSockets

To fully implement the Collection API, a client must be compatible with WebSockets and Socket.IO specifically. Clients are responsible for sending heartbeat information as well as reconnecting in the case of unexpected disconnects.

### Building a Node.js Client

The following is implemented in node but the basic idea can be applied to any language/platform.

#### Basics

First we need a basic constructor and request method.

var request = require('request');

function Collection(url) {
this.url = url
}

Collection.prototype.request = function (options, fn) {
var url = this.url;

request(options, function (err, res, body) {
options.url = url + (options.url || '');

if(res.statusCode >= 400) {
err = body || {message: 'an unkown error occured'};
return fn(err);
}

fn(null, body);
});
}

This is actually everything we need to make HTTP requests to our Collection. Here's a simple query example:

var c = new Collection('http://foo.deploydapp.com/todos');

c.request({url: '?done=false'}, function(err, todos) {
console.log(todos); // [...]
});

This will create a new todo:

var todo = {
title: 'wash the car'
};

c.request({json: todo, method: 'POST'}, function(err, todo) {
console.log(todo); // {id: '...', ...}
});

Updating is also quite simple:

var todo = {
id: '06a5254f11ff7853',
done: true
};

c.request({json: todo, method: 'PUT'}, function(err, todo) {
console.log(todo); // {id: '...', ...}
});

This will delete the todo:

var id = '06a5254f11ff7853';

c.request({url: '/' + id, method: 'DELETE'}, function(err, todo) {
console.log(err); // null - if no error occurred
});

### Listening to Events

The simplest way to listen events is to use a Socket.IO client. You can find a list of clients [here](https://github.com/LearnBoost/socket.io/wiki).

Using the node.js Socket.IO is simple:

var io = require('socket.io-client');
var socket = io.connect('http://foo.deploydapp.com');

socket.on('my event', function (data) {
console.log(data); // emit()ed from the server
});
32 changes: 32 additions & 0 deletions docs/data/creating-collections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--{
title: 'Creating Collections',
tags: ['guide', 'collection']
}-->

## Creating Collections

A Collection is a Deployd [resource](/term/resource) that exposes a database-like API directly to clients over HTTP and WebSockets. Clients can run advanced queries, create and update objects, and bind to change events to sync with the Collection in realtime. You can create a Collection in the dashboard.

### Properties

Every Collection requires a set of properties that describe the data it can store. By default every object in a Collection is created with an `id`. If an object being `POST`ed or `PUT` into a Collection includes properties or values that don't match what the collection allows, they will be ignored. The following property types are available when creating a Collection:

- `String` - Acts like a JavaScript string
- `Number` - Stores numeric values, including floating points.
- `Boolean` - Either true or false. (To avoid confusion, Deployd will consider null or undefined to be false)
- `Object` - Stores any JSON object. Used for storing arbitrary data on an object without needing to validate schema.
- `Array` - Stores an array of any type.

### The Data Editor

Once you create a Collection from the dashboard, you can add and edit its data using the data editor. The data editor is designed to edit all sorts of data, including objects and arrays.

#### Useful Shortcuts

- Start typing in any cell to overwrite its existing value.
- Press Escape to undo your changes while you’re editing
- If you accidentally save a change, press Ctrl/Cmd-Z to reverse it.
- Press Ctrl-Delete to remove a row. Press Ctrl-Z to add it back. (heads up: it will have a different id)
- Press Ctrl-Enter to open up the modal editor for a string property; this lets you write long text values.
- Press Ctrl-Enter while in the modal editor to save it (pressing Enter will just create a new line)
- Press Tab to save the current property and edit the next one.
Empty file.
Empty file.
Empty file.
Empty file added docs/data/examples/chatroom.md
Empty file.
Empty file added docs/data/examples/gradebook.md
Empty file.
Empty file.
Loading

0 comments on commit 43a270b

Please sign in to comment.