Permalink
Browse files

first commit

  • Loading branch information...
olegp committed Jan 29, 2012
0 parents commit 1bdd20b4c605191b8f3956f129e878dc963efd8e
Showing with 109 additions and 0 deletions.
  1. +14 −0 README.md
  2. +22 −0 actions.js
  3. +6 −0 index.js
  4. +15 −0 package.json
  5. +29 −0 public/stylesheets/page.css
  6. +12 −0 templates/index.html
  7. +11 −0 templates/page.html
@@ -0,0 +1,14 @@
+# Notes
+
+Notes is an example of a [Common Node](http://olegp.github.com/common-node/) application using [Stick](http://github.com/olegp/stick/) and [Mongo Sync](http://github.com/olegp/mongo-sync/).
+
+To try it out, you will need to have Common Node installed globally (via `npm install common-node -g`) as well as MongoDB running on localhost.
+
+Then, simply:
+
+ git clone git@github.com:olegp/notes.git
+ cd notes
+ npm install
+ common-node .
+
+From the browser, navigate to http://localhost:8080/ to see the webapp in action.
@@ -0,0 +1,22 @@
+var Application = require("stick").Application;
+var mongo = new (require("mongo-sync").Server)();
+
+var app = exports.app = Application();
+app.configure("params", "route", "render");
+app.render.base = resolve(module, "templates");
+app.render.master = "page.html";
+
+function get(request) {
+ var context = {
+ title : "Notes",
+ notes : mongo.db("test").getCollection("posts").find().toArray()
+ };
+ return app.render("index.html", context);
+}
+
+app.get("/", get);
+
+app.post("/", function(request) {
+ mongo.db("test").getCollection("posts").save({name: request.params.name});
+ return get();
+});
@@ -0,0 +1,6 @@
+var Application = require("stick").Application;
+
+var app = exports.app = Application();
+app.configure("notfound", "error", "static", "params", "mount");
+app.static(resolve(module, "public"));
+app.mount("/", require("./actions"));
@@ -0,0 +1,15 @@
+{
+ "name": "notes",
+ "keywords": ["common-node"],
+ "description": "Common Node example using Stick and Mongo Sync",
+ "version": "0.1.0",
+ "author": "Oleg Podsechin <oleg@ionsquare.com>",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/olegp/notes.git"
+ },
+ "main": "./index.js",
+ "engines": { "node": ">= 0.6.0" },
+ "dependencies" : { "mongo-sync": ">= 0.1.0", "stick": ">= 0.1.0" },
+ "licenses": [ { "type": "MIT" } ]
+}
@@ -0,0 +1,29 @@
+html, body {
+ margin: 0;
+ padding: 0;
+ font-family: sans-serif;
+ background: #eeeeee;
+}
+
+li {
+ margin: 0.8em;
+}
+
+#header {
+ background-color: #eeff66;
+}
+
+#header h1 {
+ font-weight: normal;
+ font-size: 28px;
+ margin: 0;
+}
+
+#body {
+ background-color: #ffffff;
+}
+
+#header, #body {
+ padding: 30px;
+ border-bottom: 1px solid #aaaaaa;
+}
@@ -0,0 +1,12 @@
+<div id="header">
+ <h1>{{title}}</h1>
+</div>
+<div id="body">
+ <form method="post" action=".">
+ <input type="text" name="name" /> <input type="submit" value="Post" />
+ </form>
+ <ul>
+ {{#notes}}
+ <li>{{name}}</li> {{/notes}}
+ </ul>
+</div>
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>{{title}}</title>
+<link rel="stylesheet" href="/stylesheets/page.css" />
+{{{head}}}
+</head>
+<body>
+{{{content}}}
+</body>
+</html>

0 comments on commit 1bdd20b

Please sign in to comment.