Skip to content

Commit

Permalink
let config work!
Browse files Browse the repository at this point in the history
  • Loading branch information
layerssss committed Dec 6, 2012
1 parent 16da451 commit 58a011d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions app/controllers/config_controllser.coffee
@@ -0,0 +1,14 @@
exports.getConfigController = (app) ->
{Config} = app.settings.models
return {
# POST /config
change: (req, res, next) ->
Config.Load (err, config) ->
return res.send err,500 if err
config[k]=v for k,v of req.body.config
config.save (err) ->
return res.send(err, 500) if err
app.set k,v for k,v of config
req.flash 'info', 'successfully changed'
res.redirect 'back'
}
2 changes: 1 addition & 1 deletion app/views/config/_form.jade
@@ -1,4 +1,4 @@
form(method='post', action='/config',accept-charset='utf-8')
form(method='post', action='/config/',accept-charset='utf-8')
fieldset
.clearfix
label(for='config[sitename]') Sitename (required)
Expand Down
3 changes: 3 additions & 0 deletions config/routes.coffee
Expand Up @@ -19,6 +19,7 @@ module.exports = (app) ->
CommentsController = controllersGetter.getCommentsController app
SessionController = controllersGetter.getSessionController app
DashboardController = controllersGetter.getDashboardController app
ConfigController = controllersGetter.getConfigController app

# middleware for finding all posts published as individual pages
findPages = PostsController.findPages
Expand Down Expand Up @@ -53,6 +54,8 @@ module.exports = (app) ->
app.get '/admin/config' , DashboardController.config
app.get '/admin/new-post' , DashboardController.newPost

app.post '/config/' , requireLogin , ConfigController.change

app.get '/feed' , PostsController.feed

app.get '/:slug.:format?' , findPages , PostsController.showPage
Expand Down

0 comments on commit 58a011d

Please sign in to comment.