This repository has been archived by the owner on Jul 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1bdd20b
Showing
7 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" } ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>{{title}}</title> | ||
<link rel="stylesheet" href="/stylesheets/page.css" /> | ||
{{{head}}} | ||
</head> | ||
<body> | ||
{{{content}}} | ||
</body> | ||
</html> |