routes/post.js
/**
 * Provides sidebar data needed for view layout.
 */
Provides sidebar data needed for view layout.
Provides sidebar data needed for view layout .
function handleSidebar(req, res, next, post, cb) {
  if (post._owner.length) {
    Post.findByAuthor(post._owner).ne('_id', post._id).run(function (err, posts) {
      if (err) return next(err);
      req.sidebar = {
        viewFile: 'post/_sidebar',
        data: {
          user: post._owner,
          posts: posts
        }
      };
      cb();
    });
  } else {
    User.findOne({ _id: post._owner}).populate('photo').run(function (err, user) {
      if (err) return next(err);
      Post.findByAuthor(post._owner).ne('_id', post._id).run(function (err, posts) {
        if (err) return next(err);
        req.sidebar = {
          viewFile: 'post/_sidebar',
          data: {
            user: user,
            posts: posts
          }
        };
        cb();
      });
    });
  }
}
function handleSidebar ( req , res , next , post , cb ) { if ( post . _owner . length ) { Post . findByAuthor ( post . _owner ) . ne ( '_id' , post . _id ) . run ( function ( err , posts ) { if ( err ) return next ( err ) ; req . sidebar = { viewFile : 'post/_sidebar' , data : { user : post . _owner , posts : posts } } ; cb ( ) ; } ) ; } else { User . findOne ( { _id : post . _owner } ) . populate ( 'photo' ) . run ( function ( err , user ) { if ( err ) return next ( err ) ; Post . findByAuthor ( post . _owner ) . ne ( '_id' , post . _id ) . run ( function ( err , posts ) { if ( err ) return next ( err ) ; req . sidebar = { viewFile : 'post/_sidebar' , data : { user : user , posts : posts } } ; cb ( ) ; } ) ; } ) ; } }
Provides sidebar data needed for view layout.
Provides sidebar data needed for view layout .