コード例 #1
0
ファイル: Router.js プロジェクト: zaneclaes/cc
	app.get(getStreamsId, function(req, res) {
		var parts = req.url.split('/'),
        end = parts[4].split('.'),
        format = end[1].split('?')[0],
        root = getJadeVariables(req)['root'],
        json = {};
        
		req.query.canonicalName = end[0];
		Stream.find(req.query).then(function(s) {
      if (!s) {
        throw new Error("Stream not found");
      }
      var params = JSON.parse( JSON.stringify( req.query ) );
      params.format = format;
      params.url = req.url;
      params.link = root + req.url;
      params.jadeVars = getJadeVariables();
      return s.present(params);
    }).then(function(obj) {
      if (format === 'json') {
        res.json(obj);
      }
      else if (format === 'html') {
        res.type('html');
        res.end(obj);
      }
      else if(format === 'rss') {
        //res.header('Content-Type:','application/rss+xml; charset=UTF-8');
        res.end(obj);
      }
      else {
        res.json({'error' : format})
      }
		}, exports.onError(req, res));
	});
コード例 #2
0
ファイル: Router.js プロジェクト: zaneclaes/cc
 app.post('/streams', requireLogin, function(req, res) {
   var stream = new Stream();
   stream.set('presentedAt', new Date(new Date().getTime() - 60000 * 60 * 24 * 30));
   stream.set('populatedAt', new Date(new Date().getTime() - 60000 * 60 * 24 * 30));
   stream.set('name', req.body.name);
   stream.set('user', Parse.User.current());
   stream.save().then(function(s){
     res.redirect('/streams/'+s.id);
   }, exports.onError(req, res));
 });
コード例 #3
0
ファイル: Router.js プロジェクト: zaneclaes/cc
 return function(items) {
   if (req.url === '/scheduled' && req.method === 'POST' && items.length > 0) {
     // Reschedule the first item(s) before scheduling.
     var map = {};
     for (var i in items) {
       var stream = req.streamMap[items[i].get('stream').id];
       if (stream && !map[stream.id]) {
         var spacing = parseInt( req.body.spacing || stream.getSpacing() );
         var scheduledAt = (new Date()).getTime() + spacing;
         items[i].set('scheduledAt', new Date(scheduledAt));
         map[stream.id] = true;
       }
     }
   }
   return Stream.schedule(items, true);
 }