     )
   )
 
+  ###### Json Routes
+  # These handle fetching local and remote json pages.
+  # Local pages are handled by the pagehandler, module.
+  app.get(///^/([a-z0-9-]+)\.json$///, (req, res) ->
+    file = req.params[0]
+    pagehandler.get(file, (page) =>
+      res.json(page)
+    )
+  )
+
+  # Remote pages use the http client to retrieve the page
+  # and sends it to the client.  TODO: consider caching remote pages locally.
+  app.get(///^/remote/([a-zA-Z0-9:\.-]+)/([a-z0-9-]+)\.json$///, (req, res) ->
+    getopts = {
+      host: req.params[0]
+      port: 80
+      path: "/#{req.params[1]}.json"
+    }
+    # TODO: This needs more robust error handling, just trying to
+    # keep it from taking down the server.
+    http.get(getopts, (resp) ->
+      responsedata = ''
+      resp.on('data', (chunk) ->
+        responsedata += chunk
+      )
+      resp.on('error', (e) ->
+        console.log("Error: #{e}")
+      )
+      resp.on('end', ->
+        res.json(JSON.parse(responsedata))
+      )
+    ).on('error', (e) ->
+      console.log "Error: #{e}"
+    )
+  )
+
+  ###### Favicon Routes
+  # Local favicons are handled by the favicon module.
   app.get('/favicon.png', (req,res) ->
     favicon.get(path.join(argv.status, "favicon.png"), (loc) ->
       res.sendfile(loc)
     )
   )
 
+  # Remote favicons redirect to the server they are needed from.
   app.get(///^/remote/([a-zA-Z0-9:\.-]+/favicon.png)$///, (req, res) ->
         res.redirect('remotefav')
   )

    identifierField: 'identifier'
  },
  ((id, done) ->
    console.log(id, done) if argv.debug
    process.nextTick( ->
      if owner
        if id is owner

  )

  ##### Routes used for openID authentication
  # Currently throws an error to next(err) when id is blank.
  # TODO: Handle that error more gracefully.
  app.post('/login',
    passport.authenticate('openid', { failureRedirect: 'notyourwiki'}),
    (req, res) ->
      res.redirect('index')
  )

  # Get and post routes to logout.  The post one is the only one that
  # gets used from client, but the get logout route seemed useful as well.
  app.post('/logout', (req, res) ->
    req.logout()
    res.redirect('index')
