Skip to content

Commit

Permalink
intial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Aug 20, 2010
0 parents commit d0d4dd0
Show file tree
Hide file tree
Showing 63 changed files with 4,026 additions and 0 deletions.
1 change: 1 addition & 0 deletions .couchappignore
@@ -0,0 +1 @@
["config.json"]
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
config.json
40 changes: 40 additions & 0 deletions README.md
@@ -0,0 +1,40 @@
## Generated by CouchApp

CouchApps are web applications which can be served directly from [CouchDB](http://couchdb.apache.org). This gives them the nice property of replicating just like any other data stored in CouchDB. They are also simple to write as they can use the built-in jQuery libraries and plugins that ship with CouchDB.

[More info about CouchApps here.](http://couchapp.org)

## Deploying this app

Assuming you just cloned this app from git, and you have changed into the app directory in your terminal, you want to push it to your CouchDB with the CouchApp command line tool, like this:

couchapp push . http://name:password@hostname:5984/mydatabase

If you don't have a password on your CouchDB (admin party) you can do it like this (but it's a bad, idea, set a password):

couchapp push . http://hostname:5984/mydatabase

If you get sick of typing the URL, you should setup a `.couchapprc` file in the root of your directory. Remember not to check this into version control as it will have passwords in it.

The `.couchapprc` file should have contents like this:

{
"env" : {
"public" : {
"db" : "http://name:pass@mycouch.couchone.com/mydatabase"
},
"default" : {
"db" : "http://name:pass@localhost:5984/mydatabase"
}
}
}

Now that you have the `.couchapprc` file set up, you can push your app to the CouchDB as simply as:

couchapp push

This pushes to the `default` as specified. To push to the `public` you'd run:

couchapp push public

Of course you can continue to add more deployment targets as you see fit, and give them whatever names you like.
29 changes: 29 additions & 0 deletions _attachments/index.html
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>My New CouchApp</title>
<link rel="stylesheet" href="style/main.css" type="text/css">
</head>
<body>
<div id="account"></div>

<h1>Generated CouchApp</h1>

<div id="profile"></div>
<div id="items"></div>

<div id="sidebar">
<p>Edit welcome message.</p>
<p>Ideas: You could easily turn this into a photo sharing app, or a grocery list, or a chat room.</p>
</div>
</body>
<script src="vendor/couchapp/loader.js"></script>
<script type="text/javascript" charset="utf-8">
$.couch.app(function(app) {
$("#account").evently("account", app);
$("#profile").evently("profile", app);
$.evently.connect("#account","#profile", ["loggedIn","loggedOut"]);
$("#items").evently("items", app);
});
</script>
</html>
31 changes: 31 additions & 0 deletions _attachments/node/timeline.js
@@ -0,0 +1,31 @@
// based on the 'osb' test from @mikeal's tweetstream
var tweetstream = require('tweetstream'),
fs = require('fs'),
path = require('path'),
request = require('request'),
sys = require('sys');

var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json')));


var stream = tweetstream.createTweetStream({track:config.track,
username:config.username,
password:config.password});

function addFriend(stream, user) {
// automatically friend anyone who mentions the term...
stream.rest.friendships.create({id:tweet.user.screen_name, user_id:tweet.user.id, follow:true},
function (error, resp, body) {
if (body) sys.puts(body);
});
};

stream.addListener("tweet", function (tweet) {

tweet._id = tweet.id.toString();
request({uri:couch, method:'POST', headers:{'content-type':'application/json'}, body:JSON.stringify(tweet)},
function (e, resp, body) {
if (resp && resp.statusCode !== 201) sys.puts(sys.inspect(resp), sys.puts(body));
else {sys.puts(body)};
})
});
75 changes: 75 additions & 0 deletions _attachments/style/main.css
@@ -0,0 +1,75 @@
/* add styles here */

body {
font:1em Helvetica, sans-serif;
padding:4px;
}

h1 {
margin-top:0;
}

#account {
float:right;
}

#profile {
border:4px solid #edd;
background:#fee;
padding:8px;
margin-bottom:8px;
}

#items {
border:4px solid #dde;
background:#eef;
padding:8px;
width:60%;
float:left;
}

#sidebar {
border:4px solid #dfd;
padding:8px;
float:right;
width:30%;
}

#items li {
border:4px solid #f5f5ff;
background:#fff;
padding:8px;
margin:4px 0;
}

form {
padding:4px;
margin:6px;
background-color:#ddd;
}

div.avatar {
padding:2px;
padding-bottom:0;
margin-right:4px;
float:left;
font-size:0.78em;
width : 60px;
height : 60px;
text-align: center;
}

div.avatar .name {
padding-top:2px;
}

div.avatar img {
margin:0 auto;
padding:0;
width : 40px;
height : 40px;
}

#items ul {
list-style: none;
}
1 change: 1 addition & 0 deletions _id
@@ -0,0 +1 @@
_design/tweb
4 changes: 4 additions & 0 deletions couchapp.json
@@ -0,0 +1,4 @@
{
"name": "Name of your CouchApp",
"description": "CouchApp"
}
11 changes: 11 additions & 0 deletions evently/items/_changes/data.js
@@ -0,0 +1,11 @@
function(data) {
// $.log(data)
var p;
return {
items : data.rows.map(function(r) {
p = (r.value && r.value.profile) || {};
p.message = r.value && r.value.message;
return p;
})
}
};
18 changes: 18 additions & 0 deletions evently/items/_changes/mustache.html
@@ -0,0 +1,18 @@
<p>Customize this format here: <tt>ddoc.evently.items._changes.mustache</tt></p>
<h3>Recent Messages</h3>
<ul>
{{#items}}
<li>
<div class="avatar">
{{#gravatar_url}}<img src="{{gravatar_url}}" alt="{{name}}"/>{{/gravatar_url}}
<div class="name">
{{nickname}}
</div>
</div>
<p>{{message}}</p>
<div style="clear:left;"></div>
</li>
{{/items}}
</ul>
<p><em>Protip:</em> If you setup continuous replication between this database and a remote one, this list will reflect remote changes in near real-time.</p>
<p>This would be a good place to add pagination.</p>
5 changes: 5 additions & 0 deletions evently/items/_changes/query.json
@@ -0,0 +1,5 @@
{
"view" : "recent-items",
"descending" : "true",
"limit" : 50
}
14 changes: 14 additions & 0 deletions evently/profile/profileReady/mustache.html
@@ -0,0 +1,14 @@
<p>Most applications will customize this template (<tt>ddoc.evently.profile.profileReady.mustache</tt>) for user input.</p>

<div class="avatar">
{{#gravatar_url}}<img src="{{gravatar_url}}"/>{{/gravatar_url}}
<div class="name">
{{name}}
</div>
</div>

<form>
<label>New message from {{nickname}}: <input type="text" name="message" size=60 value=""></label>
</form>

<div style="clear:left;"></div>
12 changes: 12 additions & 0 deletions evently/profile/profileReady/selectors/form/submit.js
@@ -0,0 +1,12 @@
function() {
var form = $(this);
var fdoc = form.serializeObject();
fdoc.created_at = new Date();
fdoc.profile = $$("#profile").profile;
$$(this).app.db.saveDoc(fdoc, {
success : function() {
form[0].reset();
}
});
return false;
};
1 change: 1 addition & 0 deletions language
@@ -0,0 +1 @@
javascript
3 changes: 3 additions & 0 deletions vendor/couchapp/README.md
@@ -0,0 +1,3 @@
## CouchApp - more than just a filesystem mapper

This is where documentation will go for the client and server JavaScript parts of CouchApp.

0 comments on commit d0d4dd0

Please sign in to comment.