Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Jan 6, 2012
2 parents 385cdc0 + 2096ed3 commit 6a8ef06
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion deps/create
Submodule create updated 1 files
+15 −4 src/jquery.Midgard.midgardWorkflows.js
18 changes: 12 additions & 6 deletions lib/blogsiple.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions lib/schema.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6a8ef06

Please sign in to comment.