           res.redirect req.url
   ]
 
-  ['/submit', (req, res) ->
-    if not req.current_user?
-      render_layout "login.jade", {message: 'You need to log in to submit'}, req, res
-      return
+  [wrappers: [require_login_nice('You need to log in to submit')],
+   '/submit', (req, res) ->
     switch req.method
       when 'GET'
         render_layout "submit.jade", {headerbar_text: 'Submit', type: (req.query_data.type or 'link')}, req, res

                  #pass
  ]

  [
    '/__pubsub__', (req, res) ->
      switch req.method
        when 'GET'
          console.log "challenge accepted"
          res.writeHead 200
          res.write req.query_data['hub.challenge']
          res.end()
        when 'POST'
          res.writeHead 200
          require('./logic/diffbot').process_response(req.post_data)
          res.end()
  ]

  [
    '/admin/tracker', (req, res) ->
      switch req.method
        when 'GET'
          mongo.diffbot.find {}, {sort: [['timestamp', -1]], limit: 20}, (err, cursor) ->
            cursor.toArray (err, diffs) ->
              if err
                console.log err
              render_layout "admin/diffs.jade", {diffs: diffs}, req, res
  ]

  [
    '/admin/tracker/subscriptions', (req, res) ->
      if not req.current_user?
        res.writeHead 401, status: 'login_error'
        res.end 'not logged in'
        return
      switch req.method
        when 'GET'
          logic.diffbot.get_subscriptions (err, subscriptions) ->
            render_layout "admin/subscriptions.jade", {subscriptions: subscriptions}, req, res
        when 'POST'
          try
            _v.check(req.post_data.url, 'url must be a valid http(s):// url.').isUrl()
          catch e
            render_layout "message.jade", {message: ''+e}, req, res
            return
          logic.diffbot.subscribe req.post_data.url, req.current_user.username, (err) ->
            if err
              render_layout "message.jade", {message: ''+err}, req, res
              return
            res.redirect "/admin/tracker/subscriptions"
  ]
])


            res.end html
  ]

  [wrappers: [require_login],
   '/r/:key/recv', (req, res) ->
    switch req.method
      when 'GET'
        key = req.path_data.key
