Permalink
Browse files

Version 0.1.1

  • Loading branch information...
1 parent 8bed0be commit 70d3de4b557df76f07351c3b8691096de3978382 @koostudios committed Apr 2, 2012
View
@@ -0,0 +1,7 @@
+Copyright (c) 2012 Alexander Yuen <koo.studios@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,12 +1,23 @@
-# Couchpress
+# CouchPress
A super lightweight and modular blogging engine or content management system built on NodeJS, Express and CouchDB. Its main aim is to be the go to CMS for NodeJS users.
## Features
-- Super lightweight (150 kb) with optional expansion through plugins
+- Super lightweight (< 150 kb) with optional expansion through plugins
- Ultra-themeable on the front and back for designers
- Built with NodeJS and CouchDB
- Made to be hackable and licensed under the MIT License
+## Changelog
+
+### Version 0.1
+
+ - Human readable creation times using Moment.js
+ - Ability to view single posts
+ - Rich text support with a custom WYSIWYG editor (a Markdown editor is on its way)
+ - Friendly URLs, post IDs and CouchDB document IDs with slugs
+ - A primitive admin area for adding and editing posts (go to '/admin' to take a look)
+ - New default front-end theme called "Soothe"
+
Write Relaxed.
View
@@ -1,5 +1,6 @@
# Articler Class - Handles all article functions
cradle = require 'cradle'
+moment = require 'moment'
class Articler
constructor: (host, port) ->
@@ -16,8 +17,17 @@ class Articler
else
docs = []
res.forEach (row) ->
- docs.push row
+ row.created_at = moment(row.created_at).fromNow()
+ docs.push row
callback null, docs
+
+ findById: (id, callback) ->
+ @db.get id, (err,res) ->
+ if (err)
+ callback err
+ else
+ res.created_at = moment(res.created_at).fromNow()
+ callback null, res
save: (articles, callback) ->
@db.save articles, (err, res) ->
View
@@ -2,9 +2,9 @@
exp = require 'express'
app = exp.createServer()
-# Articler Class
+# Articler Class - Remember to Change to Iris Couch
Articler = require('./articler').Articler
-article = new Articler 'http://localhost', 5984
+article = new Articler 'http://couchpress.iriscouch.com', 80
# App Configuration
app.configure () ->
@@ -15,24 +15,77 @@ app.configure () ->
app.use exp.methodOverride()
# Run App
-app.listen 1337
-console.log 'Server running at http://localhost:1337/'
+app.listen 16488
+console.log 'Server running at port 16488'
# Routing
app.get '/', (req, res) ->
- article.findAll (err, docs) ->
+ article.findAll (err, docs) ->
res.render 'index',
locals:
title: 'CouchPress'
articles: docs
-app.get '/new', (req, res) ->
- res.render 'new', {locals: {title: 'CouchPress / New Post'}}
+app.get '/view/:id', (req, res) ->
+ article.findById req.params.id, (err, docs) ->
+ res.render 'view',
+ locals:
+ title: 'Couchpress /' + docs.title
+ article: docs
-app.post '/new', (req, res) ->
+app.get '/admin', (req, res) ->
+ article.findAll (err, docs) ->
+ res.render 'admin/posts',
+ layout: 'admin/layout'
+ locals:
+ title: 'Posts'
+ articles: docs
+
+app.get '/admin/new', (req, res) ->
+ res.render 'admin/new',
+ layout: 'admin/layout',
+ locals:
+ title: 'New'
+
+app.get '/admin/edit/:id', (req, res) ->
+ article.findById req.params.id, (err, docs) ->
+ res.render 'admin/new'
+ layout: 'admin/layout'
+ locals:
+ title: 'Edit'
+ article: docs
+
+app.post '/admin/new', (req, res) ->
+ docs =
+ title: req.param 'title'
+ body: ''
+ res.render 'admin/new'
+ layout: 'admin/layout',
+ locals:
+ title: 'New'
+ article: docs
+
+app.post '/admin/edit', (req, res) ->
+ if (req.param 'slug')
+ slug = req.param 'slug'
+ else
+ slug = sluggify req.param 'title'
article.save {
+ _id: slug
title: req.param 'title'
body: req.param 'body'
+ _rev: req.param 'rev'
created_at: new Date()
}, (err, docs) ->
- res.redirect('/')
+ if (err)
+ res.render 'admin/error'
+ layout: 'admin/layout'
+ locals:
+ title: 'Error'
+ error: JSON.stringify(err)
+ else
+ res.redirect('/')
+
+# Other Functions
+sluggify = (title) ->
+ slug = title.slice(0,30).replace(/\ /ig, '-').toLowerCase()
View
@@ -0,0 +1,23 @@
+{
+ "name": "couchpress",
+ "description": "A super lightweight and modular CMS built on NodeJS, Express and CouchDB.",
+ "tags": ["cms", "content management" "blog", "blogging", "node","couchdb"],
+ "version": "0.1.0",
+ "homepage": "https://github.com/koostudios/Couchpress",
+ "author": "Alexander Yuen <koo.studios@gmail.com> (http://www.koostudios.com/)",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/koostudios/couchpress.git"
+ },
+ "bugs": "https://github.com/koostudios/couchpress/issues",
+ "engines": {"node": ">=0.6.x"},
+ "main": "server.js",
+ "dependencies": {
+ "coffee-script" : "1.2.x",
+ "express" : "0.5.x",
+ "jade" : "0.20.x",
+ "cradle" : "0.5.x",
+ "moment" : "1.5.x"
+ },
+ "license": "MIT"
+}
Oops, something went wrong.

0 comments on commit 70d3de4

Please sign in to comment.