Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed #15
  • Loading branch information
koostudios committed May 3, 2012
1 parent 4894a8e commit 109fe18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions controllers/posts.coffee
Expand Up @@ -38,5 +38,8 @@ class Post
callback err
else
callback null, article

remove: (id, rev) ->
@db.remove id, rev

exports.posts = new Post()
8 changes: 8 additions & 0 deletions main.coffee
Expand Up @@ -133,6 +133,14 @@ app.post '/admin/settings', users.check, (req, res) ->
delete require.cache[require.resolve('./config')]
config = require('./config').config

app.get '/admin/delete/:id?', users.check, (req, res) ->
posts.findById req.params.id, (err, docs) ->
if err
renderError res, err
else
posts.remove docs._id, docs._rev
res.redirect '/admin'

app.get '/admin/edit/:id?', users.check, (req, res) ->
posts.findById req.params.id, (err, docs) ->
if err
Expand Down
2 changes: 1 addition & 1 deletion views/admin/posts.jade
Expand Up @@ -10,7 +10,7 @@ form(method= 'post', action= '/admin/new', id= 'newtitle')
span.status(class= article.status)= article.status
.right
a.edit(href= link)= 'Edit'
a.delete(href= 'admin/delete/' + article._id)= 'Delete'
a.delete(href= 'admin/delete/' + article._id, onClick= 'if (!confirm("Are you sure you want to delete this post?")) return false')= 'Delete'
span.created= article.created_at + ' by ' + article.user
- else
.article= "Sorry, no posts found."

0 comments on commit 109fe18

Please sign in to comment.