Permalink
Browse files

Merge

  • Loading branch information...
2 parents 385cdc0 + 2096ed3 commit 6a8ef0683a31d32d782274179b2c4846936e4fe0 @bergie committed Jan 6, 2012
Showing with 22 additions and 11 deletions.
  1. +1 −1 deps/create
  2. +12 −6 lib/blogsiple.coffee
  3. +9 −4 lib/schema.coffee
View
@@ -66,15 +66,21 @@ registerBlog = (blog) ->
addPlaceholderForEmpty: true
blog_resource.map 'get', 'workflow', (req, res) ->
- results = [
- {name: 'publish', label: 'Publish', action: {type: 'backbone_save', url: "/#{req.post.id}/publish"}, type: 'button'},
- {name: 'force_destroy', label: 'Delete', action: {type: 'backbone_destroy'}, type: 'button'}
- ]
+ results = []
+ if req.post.published.toString() == 'true'
+ results.push {name: 'unpublish', label: 'Unpublish', action: {type: 'http', http: {type: 'PUT'}, url: "/#{req.post.id}/unpublish"}, type: 'button'}
+ else
+ results.push {name: 'publish', label: 'Publish', action: {type: 'http', http: {type: 'PUT'}, url: "/#{req.post.id}/publish"}, type: 'button'}
+ results.push {name: 'destroy', label: 'Delete', action: {type: 'backbone_destroy'}, type: 'button'}
+
res.json results
blog_resource.map 'put', 'publish', (req, res) ->
- console.log 'PUBLISHED', req.post
- req.post.updateAttributes req.body, (err, item) ->
+ req.post.updateAttributes {published: true, published_at: (new Date())}, (err, item) ->
+ res.send server.rdfmapper.toJSONLD req.post, req
+
+ blog_resource.map 'put', 'unpublish', (req, res) ->
+ req.post.updateAttributes {published: false, published_at: null}, (err, item) ->
res.send server.rdfmapper.toJSONLD req.post, req
server.resource 'users', resourcer.getResource
View
@@ -4,26 +4,31 @@ exports.schema = schema = new Schema 'redis', {}
exports.Role = Role = schema.define 'Role',
name:
- type: Schema.String
+ type: String
index: true
exports.User = User = schema.define 'User',
email:
- type: Schema.String
+ type: String
index: true
exports.Blog = Blog = schema.define 'Blog',
title:
- type: Schema.string
+ type: String
length: 255
exports.Post = Post = schema.define 'Post',
title:
- type: Schema.String
+ type: String
length: 255
index: true
content:
type: Schema.Text
+ published:
+ type: Boolean
+ default: false
+ published_at:
+ type: Date
User.hasMany Role,
as: 'roles'

0 comments on commit 6a8ef06

Please sign in to comment.