Example #1
0
    db.collection('updates').findOne({_id: id}, function(err, doc) {
      var description = doc.status;
      doc.status = linkify(doc.status);
      doc.timeago = timeago(new Date(doc.posted_at));
      doc.slug = generateSlug(doc.status);
      doc.posted_at = new Date(doc.posted_at);
      if(user!==null){
        doc.hasUser = true;

        var disqusUser = {
          id: user.user_id,
          username: user.username,
          email: user.email
        }
        doc.user = disqusSignon(disqusUser);
      }
      res.send(generatePage({
        title: description + ' - cdnjs.com',
        page: {
          description: description,
          template: templates.newsfeed_item,
          data: doc
        }
      }));
    });
    createNode : function(tweet) {

        tweet.created_at = this.formatTime(tweet.created_at);
        tweet.text = linkify(tweet.text);
        var compiledTemplate = _.template(tweetTemplate);
        compiledTemplate = compiledTemplate({tweet: tweet});
        return compiledTemplate;
    },
Example #3
0
 function showInspector(row) {
   var prettyHtml = htmlStringify(row)
   var attachmentData = []
   var attachments = row.attachments || {}
   Object.keys(attachments).map(function(key) {
     attachmentData.push({
       name: key,
       url: state.remote + '/api/' + row.key + '/' + key
     })
   })
   
   showDialog('inspect', {
     html: htmlLinkify(prettyHtml, {escape: false}),
     attachments: attachmentData,
     hasAttachments: attachmentData.length > 0,
     key: row.key
   })
 }
Example #4
0
  present: function(text, opts) {
    if (!opts) opts = {};
    if (!text) return '<p></p>';

    // wrap in a <p> tag
    if (!opts.skipWrap && text.substring(0, 3) != '<p>')
      text = format('<p>%s</p>', text);

    // make links
    text = linkify(text, {escape: false, attributes: {target: '_blank'}});

    // link hashtags
    // this is not ideal because it hardcodes the search path
    text = text.replace(/( |^|>)#(\w+)/g, '$1<a href="/search?q=%23$2">#$2</a>');

    if (opts.maxlength)
      text = truncate(text, opts.maxlength);

    return text;
  },
Example #5
0
 _.each(docs, function(doc){
   doc.posted_at = new Date(doc.posted_at);
   doc.status = linkify(doc.status);
   doc.slug = generateSlug(doc.status);
   doc.timeago = timeago(new Date(doc.posted_at));
 });
Example #6
0
ejs.filters.linkify = function (str) {
	return linkify(str || '', { attributes: { target: '_blank' } });
};
Example #7
0
                    _.forEach(row, function(item) {

                        // skip header row;
                        if (rowIndex === 0 ) {
                            return;
                        }

                        if (item && typeof item.value !== 'undefined') {

                            var val = (item.value && item.value !== 'null') ? _s.trim(item.value) : false;

                            if (val) {
                                switch (itemIndex) {
                                    case 0:
                                        // date
                                        f.properties.timestamp = val ? new Date(val).toISOString() : '';
                                        break;
                                    case 1:
                                        // lat
                                        f.geometry.coordinates[1] = convertDegreesToDecimal(val).toFixed(5);
                                        break;
                                    case 2:
                                        // north/south
                                        if (val.toUpperCase() === 'S') {
                                            f.geometry.coordinates[1] = -f.geometry.coordinates[1];
                                        }
                                        break;
                                    case 3:
                                        // long
                                        f.geometry.coordinates[0] = convertDegreesToDecimal(val).toFixed(5);
                                        break;
                                    case 4:
                                        // east/west
                                        if (val.toUpperCase() === 'W') {
                                            f.geometry.coordinates[0] = -f.geometry.coordinates[0];
                                        }
                                        break;
                                    case 5:
                                        // location
                                        f.properties.location = val;
                                        break;
                                    case 6:
                                        // update-type
                                        f.properties.type = getFeatureTypeString(val);
                                        break;
                                    case 7:
                                        if (val !== 'null') {
                                            // weather
                                            f.properties.weather = {
                                                text: val
                                            };
                                            switch (val.toUpperCase()) {
                                                case 'SUNNY':
                                                    f.properties.weather.icon = 'wi-day-sunny';
                                                    break;
                                                case 'CLOUDY':
                                                    f.properties.weather.icon = 'wi-cloudy';
                                                    break;
                                                case 'RAINY':
                                                    f.properties.weather.icon = 'wi-rain';
                                                    break;
                                                default:
                                                    console.log(warn('Weather value not handled: '), val);
                                                    f.properties.weather.icon = 'wi-cloud';
                                            }
                                        }

                                        break;
                                    case 8:
                                        // temperature
                                        f.properties.temp = val;
                                        break;
                                    case 9:
                                        // image
                                        if (val !== 'null' && val.length && val !== '/') {
                                            f.properties.image.src = 'img/features/' + val + '.jpg';
                                        }
                                        break;
                                    case 10:
                                        // port
                                        f.properties.port = val.toUpperCase() === 'YES' ? true : false;
                                        break;
                                    case 11:
                                        // text
                                        val = linkify(val);
                                        val = twitter.autoLink(val);

                                        f.properties.summary = val;
                                        break;
                                    default:
                                        console.log(warn('Unhandled column: ' + itemIndex, val));
                                }
                            } else {
//                                console.warn(warn(sheetIndex, rowIndex, itemIndex, 'no value'));
                            }
                        } else {
//                            console.warn(warn(sheetIndex, rowIndex, itemIndex, 'no value'));
                        }

                        // Finished item
                        itemIndex++;

                    });