Esempio n. 1
0
    $('#fre .it').each(function(idx, elem){
        var userId = $(elem).find('a.gender_male, a.gender_female').text();
        var sentDate = $(elem).find('.it_text .r').text();
        // console.log(sentDate);
        var dateMatch = sentDate.match(/(\d{2}).(\d{2}).(\d{4}) \[(\d{2}):(\d{2})\]/);
        
        if(dateMatch.length){
            var day = parseInt(dateMatch[1], 10);
            var month = parseInt(dateMatch[2], 10);
            var year = parseInt(dateMatch[3], 10);
            var hour = parseInt(dateMatch[4], 10);
            var minute = parseInt(dateMatch[5], 10);
            var blogDate = new Date(year, month - 1, day, hour, minute);
            var blogHtml = $(elem).find('.it_text').html();
	    blogHtml = entDecode(blogHtml);
	    
            var postDateDivIdx = blogHtml.indexOf('<div class="r">');
            if(postDateDivIdx > 0){
                blogHtml = blogHtml.substring(0, postDateDivIdx).trim();
            }
            // console.log(blogHtml);
            debugger;
	    blogHtml.replace(/<[^>]+>/g, '');
            var blogPost = {
                date : blogDate,
                author : userId,
                text : blogHtml,
                UUID : nodeUuid.v4()
            }
            
            // console.log(blogPost);
            blogPostsArray.push(blogPost);
        }
        // var text = $(elem).text();
    });
Esempio n. 2
0
  textForPost: function (post, community, userId, version) {
    const person = post.relations.user.get('name')
    const postName = decode(post.get('name'))

    return version === 'mention'
      ? `${person} mentioned you in "${postName}"`
      : `${person} posted "${postName}" in ${community.get('name')}`
  }
Esempio n. 3
0
 textForComment: function (comment, version) {
   const person = comment.relations.user.get('name')
   const blurb = decode(truncate(comment.get('text'), 80).text)
   const postName = comment.relations.post.get('name')
   return version === 'mention'
     ? `${person} mentioned you: "${blurb}" (in "${postName}")`
     : `${person}: "${blurb}" (in "${postName}")`
 },
 req.get(url).on('complete', function(data) {
 	if (data instanceof Error) {
 		if (_DEBUG)
 			_logger.error("Error al llamar funcion en arduino, Error : " + data);
 		return callback(data, null);
 	}
 	else
 	{
     var ret = decode(data);
 		return callback(null, data);
 	}
 }).on('error', function(error, response) {
Esempio n. 5
0
  sendCommentNotificationEmail: function (version) {
    const comment = this.comment()
    const reader = this.reader()
    if (!comment) return

    const post = comment.relations.post
    const commenter = comment.relations.user
    const text = RichText.qualifyLinks(comment.get('text'))
    const replyTo = Email.postReplyAddress(post.id, reader.id)
    const title = decode(post.get('name'))

    var postLabel = `"${title}"`
    if (post.get('type') === 'welcome') {
      var relatedUser = post.relations.relatedUsers.first()
      if (relatedUser.id === reader.id) {
        postLabel = 'your welcoming post'
      } else {
        postLabel = format("%s's welcoming post", relatedUser.get('name'))
      }
    }

    const communityIds = Activity.communityIds(this.relations.activity)
    if (isEmpty(communityIds)) return Promise.resolve()
    return Community.find(communityIds[0])
    .then(community => reader.generateToken()
      .then(token => Email.sendNewCommentNotification({
        version: version,
        email: reader.get('email'),
        sender: {
          address: replyTo,
          reply_to: replyTo,
          name: format('%s (via Hylo)', commenter.get('name'))
        },
        data: {
          community_name: community.get('name'),
          commenter_name: commenter.get('name'),
          commenter_avatar_url: commenter.get('avatar_url'),
          commenter_profile_url: Frontend.Route.tokenLogin(reader, token,
            Frontend.Route.profile(commenter) + '?ctt=comment_email'),
          comment_text: text,
          post_label: postLabel,
          post_title: title,
          comment_url: Frontend.Route.tokenLogin(reader, token,
            Frontend.Route.post(post) + '?ctt=comment_email' + `#comment-${comment.id}`),
          unfollow_url: Frontend.Route.tokenLogin(reader, token,
            Frontend.Route.unfollow(post, community)),
          tracking_pixel_url: Analytics.pixelUrl('Comment', {userId: reader.id})
        }
      })))
  },
Esempio n. 6
0
    rnd.link = function(href, _, text) {
	if (href.match(/^https?:\/\//)) {
	    href = u.texi_escape(html_decode(href))
	    return `@uref{${href},${text}}`
	}

	if (opt.plugins) {
	    let node_prefix = exports.node_prefix(href)
	    let hookresult = opt.plugins.run_hook('link_renderer', href,
						  node_prefix, opt)
	    if (hookresult.length) {
		href = hookresult[hookresult.length-1].data
	    }
	}

	if (opt.node_aliases && opt.node_aliases[href])
	    href = opt.node_aliases[href]

	href = u.texi_escape(html_decode(href))
	// info output doesn't like `:` & `.` in the ref label;
	// html/pdf output doesn't care about `.`
	text = text.replace(/[:]/g, ' ').replace(/\s+/g, ' ').trim()
	return `@mylink{${href},${text}}`
    }
Esempio n. 7
0
    rnd.code = function(code, lang, escaped) {
	if (opt.plugins) {
	    let hookresult = opt.plugins.run_hook('code',
						  code, lang, allthelinks, rnd)
	    for (let idx of hookresult) {
		if (idx.terminal) return idx.data
	    }
	    code = hookresult[hookresult.length-1].data
	}

	return ['\n',
		'@example',
		u.texi_escape(html_decode(code)),
		'@end example',
		'\n'].join("\n")
    }
Esempio n. 8
0
 static async parse(item) {
   try {
     const headReq = await this.headRequest(item.link)
     const newItem = Object.assign({}, headReq)
     if (!newItem.validDate) return false
     if (!(await this.checkDb(newItem.url))) return false
     newItem.title = decode(item.title)
     newItem.tweet_id = await this.postTweet(newItem)
     await this.dbInsert(newItem)
     console.log('Successfully tweeted and inserted into DB')
     return newItem
   } catch (e) {
     console.log(`Item parsing err: ${e}`)
     return false
   }
 }
Esempio n. 9
0
  $('h1#pagetitle').nextAll('table').each((index, element) => {
    // Find title
    let $children = $(element).children('tr')
    let title = decode($children.eq(1).find('h1').html().trim())
    let attributes = {
      title: title
    }

    // Loop through children and transform them via attributeMap
    $children.each((index, element) => {
      const attributeName = $(element).find('td').eq(0).html()
      if (attributeName) {
        const attr = attributeMap[attributeName]
        if (attr) {
          const $element = $(element).find('td').eq(1)
          attributes[attr.to] = attr.transform($element, $)
        }
      }
    })

    entries.push(attributes)
  })
Esempio n. 10
0
module.exports = function parseComment(msg) {
  if (msg.cmd === 'ROOM_BLOCK_MSG') {
    return {
      type: 'userBlocked',
      uid: String(msg.uid),
      nick: msg.uname,
    }
  }

  if (msg.cmd === 'SEND_GIFT') {
    return {
      type: 'sendGift',
      giftId: msg.data.giftId,
      giftType: msg.data.giftType,
      giftName: msg.data.giftName,
      giftCount: msg.data.num,
      nick: msg.data.uname,
    }
  }

  if (msg.cmd === 'DANMU_MSG') {
    return {
      type: 'comment',
      uid: String(msg.info[2][0]),
      nick: msg.info[2][1],
      text: decode(msg.info[1]),
      color: parseColor(msg.info[0][3]),
      isVip: msg.info[2][3] === '1',
      isAdmin: msg.info[2][2] === 1,
    }
  }

  return {
    type: 'unknownUserMsg',
    body: msg,
  }
}
Esempio n. 11
0
 .then(token => Email.sendPostMentionNotification({
   email: reader.get('email'),
   sender: {
     address: replyTo,
     reply_to: replyTo,
     name: format('%s (via Hylo)', user.get('name'))
   },
   data: {
     community_name: community.get('name'),
     post_user_name: user.get('name'),
     post_user_avatar_url: Frontend.Route.tokenLogin(reader, token,
       user.get('avatar_url') + '?ctt=post_mention_email'),
     post_user_profile_url: Frontend.Route.tokenLogin(reader, token,
       Frontend.Route.profile(user) + '?ctt=post_mention_email'),
     post_description: description,
     post_title: decode(post.get('name')),
     post_type: 'conversation',
     post_url: Frontend.Route.tokenLogin(reader, token,
       Frontend.Route.post(post) + '?ctt=post_mention_email'),
     unfollow_url: Frontend.Route.tokenLogin(reader, token,
       Frontend.Route.unfollow(post, community) + '?ctt=post_mention_email'),
     tracking_pixel_url: Analytics.pixelUrl('Mention in Post', {userId: reader.id})
   }
 })))
Esempio n. 12
0
    rnd.codespan = function(text) {
	return '@code{' + u.texi_escape(html_decode(text)) + '}'
    }
Esempio n. 13
0
    rnd.text = function(text) {
	return u.texi_escape(html_decode(text))
    }