Beispiel #1
0
router.get('/', function(req, res) {
	var message = cache.get(req.path)
	if (!message) {
		wp.posts().get(function( err, data ) {
		    if (err) res.render('error', {error: err.message})
			message = {posts: data}
			cache.set(req.path, message)
			res.render('index', message)		
		})
	}else{
		res.render('index', message)
	}
})
Beispiel #2
0
router.post('/articles', function(req, res) {
  var article = new Article(req.body).save((err, doc) => {
    if (err)
      return error(err)
    debug('['+doc.name+'] saved to storage.')
  })
  var wp = new WP({
      endpoint: 'http://syngulate.com/core/wp-json',
      username: 'syn_bot',
      password: 'R@F1Fnp(4xXjq6K!IC(T(Svk'
  });

  wp.posts().post({
      title: req.body.name,
      content: req.body.link,
      status: 'draft'
  }).then(function( response ) {
      article.editID = response.id
      article.editLink = 'http://syngulate.com/core/wp-admin/post.php?post='+response.id+'&action=edit'
      res.send(article);
  })
});
Beispiel #3
0
              Project.find({ $and: [ { $or: [{lead: u._id}, {contributors: u._id}] }, { $or: [{status: "active"}, {status:"complete"}]}] }).select('title slug').exec(function(err, projects){

                  // Because I'm the only one who has a different wp login than github login....
                  // Remove when we switch to github blogging
                  var wp_name = (name === 'acabunoc') ? 'abbycabs' : name;
                  wp.posts()
                    .author( wp_name )
                    .filter( 'posts_per_page', 65 )
                    .get(function( err, posts ) {
                      if ( err ) {
                          return console.log(err);
                      }

                      if(!is_self){
                        res.render('user/user.jade', {
                                                posts: posts,
                                                projects: projects,
                                                badges: badges,
                                                events: events,
                                                person: u,
                                                is_self: is_self})
                      } else {

                        Project.find({lead: u._id}).select('title slug status').exec(function(err, projects_review){

                        res.render('user/user.jade', {
                                                posts: posts,
                                                projects: projects,
                                                badges: badges,
                                                events: events,
                                                person: u,
                                                projects_review: projects_review,
                                                is_self: is_self});

                        });
                      }
                  });
              });
Beispiel #4
0
var WP = require( 'wordpress-rest-api' );
var wp = new WP({ endpoint: settings.website });

// get posts
wp.posts().get(function( err, data ) {
    if ( err ) {
        // handle err
        console.log("I got an error");
        console.log(err);
    }
    // do something with the returned posts
    console.log("I got an error");
    console.log(data);
});