EzDevInfo.com

Mention.js

Lightweight wrapper for adding <a href="https://github.com/user" class="user-mention">@user</a> mention functionality to Twitter Bootstraps Typeahead plugin Mention.js Test

Mention API - Mark a mention as READ

Using the API here: https://dev.mention.com/resources/alert_mentions/#put-accounts-id-alerts-alert-id-mentions-mention-id

From what I understand, if I want to mark a specific "mention" as read, I do something like this:

$browser = new \Buzz\Browser(new \Buzz\Client\Curl);

$params = ['read' => true]; //tried this

$url = "https://api.mention.net/api/accounts/" . $this->getAccountId() . "/alerts/{$alert_id}/mentions/{$mention_id}";


if(!empty($params))
{
    $url .= '?' . http_build_query($params); //i think this isnt needed because i pass $params below to the $browser->put but it was worth a try.
}

$response = $browser->put($url, array(
            "Authorization: Bearer {$this->getAccessToken()}",
            "Accept: application/json",
        ), $params);

if (200 != $response->getStatusCode()) {
    return false;
}

However, when I run the code, it doesn't produce any errors and infact returns a valid response, but the "read" flag is still set to false.

Also tried:

$params = ['read' => 'true']; //tried this
$params = ['read' => 1]; //tried this

Source: (StackOverflow)

Showing android popout listView

I am trying to implement something similar to facebook/twitter feature which is showing a list of users when you add "@" sign. My problem is i don't know how to implement this kind of pop out or floating view . is it dialog or fragment ?

enter image description here


Source: (StackOverflow)

Advertisements

How to use typeahead effect and @mention someone in a WYSIWYG Editor

Jquery mentions input is a great plugin to mention someone via dropdown select:

https://github.com/podio/jquery-mentions-input

But is it possible to use it in any WYSIWYG editors?

Currently we use redactor editor, but can't find a way to do that.


Source: (StackOverflow)

Convert JSON from Django to JavaScript Array and Loop to Populate 'users' Parameter in Mention.js

I'm probably going about this all wrong, so I need some guidance. I'm using mention.js for linking profiles in posts in an application I'm building. Getting this working with hard coded data is trivial. Just set it up as described in the docs.

Well, for my app, each user who is logged in belongs to an organization, and this organization comes from Django as JSON. I want to populate the mention.js dropdown from which to choose with these data so when a user types, their organization list comes up. I have the JSON logged to the terminal console and browser console:

[
    {
        "fields": {
            "avatar": "images/avatars/bob.png", 
            "name": "Bob Jones"
    }, 
        "model": "accounts.profile", 
        "pk": 5
    }, 
    {
        "fields": {
            "avatar": "images/avatars/sam.png", 
            "name": "Sam Smith"
    }, 
        "model": "accounts.profile", 
        "pk": 7
    }
]

So I'm getting the correct data from Django. I can parse the data relatively easily and print to the browser console:

console.log(profile_array[0].fields.name);

The next step is to get this into the mention.js users parameter. Based on @sainaen's answer, I have this in my JavaScript:

users: profile_array.map(function (profile) {
    return {
        username: profile.fields.name, // this still missing
        name: profile.fields.name,
        image: '/media/' + profile.fields.avatar
    };
})

The problem is that my profile does not have a username field. It's linked to the User model by a OneToOne relationship. So in my view, I'm actually returning two chunks of JSON: profiles (for name and avatar) and users (for username).

I realized that I can combine these JSON objects and so I did that.

But now I'm having trouble getting the username out for the users parameter in mention.js.

UPDATE

To solve this, I added a username field to my profile model. I added some code to a save override to autopopulate theusername of the profile model to be equal to user.username. Not sure if this is the best method, but it allows for @sainaen's answer to work.


Source: (StackOverflow)

Mentio and AngularJS Validation Issue

I have used mentio with a textarea something like below:

<textarea mentio
mentio-trigger-char="'@'"
mentio-search="searchPeople(term)"
ng-minlength="10" 
.....

So when typing inside the textarea, if the number of charectors is less than 10, the mentio-search function is not calling so that the @ suggestions are not displaying. The @ suggestions are showing only when there is no angular validation errors (that is, after the first 10 charecters)

How can this be fixed so that, I need to dispenter code herelay the @ suggestions even if the angularJS validation error is there.


Source: (StackOverflow)

How to use mention feature in Facebook using user account id in Facebook4jar api?

I am trying to make simple code using java , I uses in this facebook4jar .I want to mention group members using their IDs numbers . I searched on web, and understood this " To make mention using member id,you should use this form @[id:0]".I am trying to do this.but do not work on the following code ",If condition is working . program executes code inside if statement , and print group members ids , Also it comments them but only words not as a mention form.

import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.GroupMember;
import facebook4j.Post;
import facebook4j.Reading;
import facebook4j.ResponseList;
import facebook4j.auth.AccessToken;



public class Test {

public static void main(String[] args) throws FacebookException,InterruptedException {
    Facebook facebook = new FacebookFactory().getInstance();
    facebook.setOAuthAppId("****", "***");
    facebook.setOAuthPermissions("user_friends,user_groups,user_photos,user_videos,user_birthday,user_status,user_likes,user_activities,user_location");
    facebook.setOAuthAccessToken(new AccessToken("*****", null));






         ResponseList<GroupMember> members = facebook.groups().getGroupMembers("****") ;                 

        ResponseList<Post> feeds = facebook.getFeed("******",
                new Reading().limit(25));


            for (int i = 0; i < feeds.size(); i++) {


                Post post = feeds.get(i);


                String message = post.getMessage();


                String id = post.getId();
                if(message.equalsIgnoreCase("*****")){

                for (int j =0; j < members .size(); j++){
                    GroupMember Account=members.get(j);
                    String iD="@["+Account.getId()+":]";
                    System.out.println(Account.getId());
                    facebook.commentPost(id,iD);
                              }
                          }
                     }

                      }
             }

Source: (StackOverflow)

Trouble with twitter bot, function mention not working

I'm trying to make an automated twitter bot that posts tweets. I'm using this php code, but i keep getting an error that says: Fatal error: Call to undefined method tweet_bot::mention() in C:\wamp\www\proyectos\botprueba2\index.php on line 9

This is my code:

index.php

<?php
$api_key='xxx';
$api_secret='xxx';
$access_token ='xxx';
$access_token_key='xxx';
include("tweet_bot.php");
$tweet= new tweet_bot;
$tweet->setKey($api_key, $api_secret,$access_token , $access_token_key);
$result= $tweet->mention('Hello this is my first tweet bot');
Print_r($result);
?>

tweetbot.php

<?php
class tweet_bot
{
    function oauth()
    {
        require_once("twitteroauth/src/TwitterOAuth.php");
        $con = new TwitterOAuth($this->api_key, $this->api_secret, $this->access_token, $this->access_token_secret);
        return $con;
    }
    function tweet($text)
    {
        $con = $this->oauth();
        $status = $con->post('statuses/update', array('status' => $text));
        return $status;
    }
    function setKey($api_key,$api_secret,$access_token,$access_token_secret)
    {
        $this->api_key = $api_key;
        $this->api_secret = $api_secret;
        $this->access_token = $access_token;
        $this->access_token_secret = $access_token_secret;
    }
}
?>

Any help would be very appreciated.


Source: (StackOverflow)

jquery.mentionsInput and ckEditor

This is just to help the people who is looking for something like mentions in ckeditor.

I modified jquery.mentionsInput to work together with ckEditor and .. It is working :)

You can see this online: http://jsfiddle.net/us6qo3Lc/ (type: @ken)

<head>
    <meta charset="utf-8">
    <script src="jquery-1.11.0.min.js"></script>
    <script src="ckeditor.js"></script>
    <link rel='nofollow' href="sample.css" rel="stylesheet">

    <link rel='nofollow' href='jquery.mentionsInput.css' rel='stylesheet' type='text/css'>
    <script src='underscore-min.js' type='text/javascript'></script>

    <script src='autocomplete.js' type='text/javascript'></script>
</head>
<body>
    <form action="sample_posteddata.php" method="post">
        <textarea class="mention" cols="80" id="editor1" name="editor1" rows="10">
            teste <b>teste</b> teste <em>teste</em> teste
        </textarea>
        <p style="overflow: hidden">
            <input style="float: left" type="submit" value="Submit">
        </p>
    </form>
</body>
</html>

autocomplete.js is the code I created and it is in fiddle, ok ?

Well if someone with time, and knowledge, improve the code and maybe create a specific plugin with this .. I think the entire comunity will love.

I know the code is a mess .. so there are some space to improve it :)

I hope this help somebody .. thanks :)


Source: (StackOverflow)

Using at.js for '@mentions' -- can't display first/last name

I'm using the at.js '@who mentions'(https://github.com/ichord/At.js) in my Meteor chat application, and would like to do the following:

Display 'username: firstName lastName' in the @who list.

It's currently displaying username only.

The mongo collection stores the firstName in profile.firstName, lastName in profile.lastName

Current code in channel.js:

setTimeout(function () {
          var dbUsers = Meteor.users.find({_id: {$ne: Meteor.userId()}}).fetch();
          var users = _.sortBy(dbUsers, 'username');
          users = _.pluck(users, 'username');
          self.$('textarea[name=message]').atwho({
            at: '@',
            data: users,
          }).on('shown.atwho', function(event) {
            setIsMentioning(true);
          }).on('hidden.atwho', function(event) {
            setTimeout(function() { setIsMentioning(false); }, 100);
          });
        }, 500);

My new code in channel.js:

setTimeout(function () {
      var dbUsers = Meteor.users.find({_id: {$ne: Meteor.userId()}}).fetch();
      var users = _.map(dbUsers, function(user) { return _.pick(user, 'username', 'profile.firstName', 'profile.lastName'); });
      self.$('textarea[name=message]').atwho({
        at: '@',
        data: users,
        displayTpl: '<li>${firstName} ${lastName}, ${degree}</li>',
        insertTpl: ':${username}:'
      }).on('shown.atwho', function(event) {
        setIsMentioning(true);
      }).on('hidden.atwho', function(event) {
        setTimeout(function() { setIsMentioning(false); }, 100);
      });
    }, 500);

Here's the publication for users in users.js:

Meteor.publish('users', function() {
  if(this.userId) { // We should only send data to logged in users.
    // filter by organization
    var user = Meteor.users.findOne(this.userId);
    if(user.profile && user.profile.organizationId)
      return Meteor.users.find(
        {'profile.organizationId': user.profile.organizationId},
        {fields: {'username': 1, 'emails': 1, 'status': 1, 'profile.firstName': 1, 'profile.lastName': 1}}
      );
    else
      return Meteor.users.find({}, {fields: {'username': 1, 'emails': 1, 'status': 1}});
  }

  this.ready();
});

Here's the users subscription in routes.js:

teamRoutes = FlowRouter.group({
  prefix: '/teams/:team',
  middlewares: [AccountsTemplates.ensureSignedIn],
  subscriptions: function(params) {
    this.register('teamChannels', Meteor.subscribe('teamChannels', params.team));
    this.register('teamDirectChannels', Meteor.subscribe('teamDirectChannels', params.team));
    this.register('users', Meteor.subscribe('users', params.team));
    this.register('teams', Meteor.subscribe('myTeams'));
    this.register('reads', Meteor.subscribe('reads'));
    this.register('mentions', Meteor.subscribe('mentions'));
  }
});

Would really appreciate anyone who can explain to me what I'm doing wrong! Thanks so much.


Source: (StackOverflow)

Inconsistency on some Android mobile web browsers with tagging

I am using a jQuery plugin for allowing @mentions (tagging someone by inputing their name after an @ symbol). The plug-in can be found here (http://podio.github.io/jquery-mentions-input/), and it has been working rather well. The only issue (which may or may not have to do with the plug-in itself) that I've come across is that on certain Android devices, and particularly on certain mobile browsers, these @mentions will not work. Interestingly, I discovered that if I turned Predictive Text off on these devices, it seemed to make the issue go away, but I am curious if there is a way to make it work without having to create a possibly poor user experience (i.e. forcing the user to turn predictive text off in order to tag). The github repo for the plug in has addressed that there are some issues on Android, but it does not specify if that is referring to an Android App, or the web browsers for Android. If anyone has come across a similar issue, I'd love to hear about possible solutions.


Source: (StackOverflow)

At.js Mentions Callbacks and Duplicates

Anyone experience with At.js that can help out? I'm trying to:

  1. Get the inserted mentions in an array so that they can then be processed with PHP
  2. Prevent duplicate entries (not sure where to start with this one)

Little experience with Javascript and jQuery so any help appreciated. FYI I'm using At.js with the amazing Froala WYSIWYG Editor

Here is what I have to get the tags but I'm not sure how to get it into an array.

$(function(data){   
   $('#postTagsInput').atwho({
       at: '@', 
       data: 'URL'
});

$('#postTagsInput').on("inserted.atwho", function($li, query) {
   console.log(query);

   var postTags = query;
   $('#myResults').html(postTags);      
  });      
});

Source: (StackOverflow)

call a function inside a jQuery plugin from outside on-click event

i am using following library for auto complete and mention username in my application. my question is that how can i trigger init: function from onClick of a anchor tag instead of writing in text area. any suggestion? Here is a function that i tried to write. here is the plugin http://podio.github.io/jquery-mentions-input/

$("a").on('click', '.tag_user_btn', function(event) {
       event.preventDefault();
       var txtPost = $(this).parents('.post-comment').find('textarea');
       txtPost.val(txtPost.val()+" @a").focus().init();//call initilize function of library
 });

Source: (StackOverflow)

Invalid html returned when "www" or ".com" comes along url for a link which is created dynamically using regular expression in PHP

I am getting invalid html as out when i try to create link dynamically using regular expression using a pattern.

This is my function which creates link:

$message ="sddsdsd @@[Sanesh Sunny:ZGNjBQN9ac3K] dsdsdsd ";
    function convert_usertags_links($message,$extraParams){
            $tag_name = 'a'; //default a 
            $has_link = $new_tab = 0; //default no link
            $href = $target = $sel_id = $tag_col = "";
            $tag_col = 'tag_col';
            if(isset($extraParams['tag_name']) && $extraParams['tag_name']!="")
                $tag_name = $extraParams['tag_name'];
            if(isset($extraParams['tag_col']) && $extraParams['tag_col']!="")
                $tag_col = $extraParams['tag_col'];
            if(isset($extraParams['has_link']) && $extraParams['has_link']!="")
                $has_link = $extraParams['has_link'];
            if(isset($extraParams['new_tab']) && $extraParams['new_tab']!="")
                $new_tab = $extraParams['new_tab'];
            if(isset($extraParams['selector_id']) && $extraParams['selector_id']!="")
                $sel_id = $extraParams['selector_id'];
            $site_url = 'www.google.com/project/';
            if($has_link == 1)
                $href = " rel='nofollow' href='".$site_url."user/profile/$2' ";
            if($has_link == 1)
                $target = " target='_blank' ";
            /*
             * to match numbers only       
             */
            $pattern = "/@@\[([^:]*):(.*?)\]/"; 
            #$pattern = "/@@\[([^:]*):([0-9a-zA-Z]*)\]/";
            $matches = array();
            preg_match_all($pattern, $message, $matches);
            $output = preg_replace($pattern, "<".$tag_name." class='".$tag_col."' id='".$sel_id."_$2'".$href.$target." >$1</".$tag_name.">", $message);
            return $output;
        }

This functions works perfect in localhost but when i tried the same in my stagging server having site_url like "https://dsdsdsdsdsd.com/project" i am getting invalid html like:

<a class="tag_col" id="user_tag_link_ZGV3ZmZ9ac3K_ZGNjBQN9ac3K" rel='nofollow' href="&lt;a rel='nofollow' href=&quot;www.google.com/4thambit-v6/user/profile/ZGNjBQN9ac3K&quot; target=&quot;_blank&quot;&gt;www.google.com/4thambit-v6/user/profile/ZGNjBQN9ac3K&lt;/a&gt;" target="_blank">Sanesh Sunny</a>

The href contains another a tag inside... if i pass site_url as 192.168.1.X which is IP Adresss it is working fine but when i use "www" or ".com" inside sit_url the above invalid html is returned with another a tag inside href......

Any idea why this happening ? i tried few sites but no help....


Source: (StackOverflow)

How do I use templating in MentionsInput.js?

Note: This could be a documentation for the feature of templating the list item for the plugin jQuery.mentionsInput. So I request the users, not to close this or delete this question. TIA.

I am using jQuery.mentionsInput in my project. Everything works fine. I am calling the plug-in using this:

$(".mention").mentionsInput({
    onDataRequest: function (mode, query, callback) {
        $.getJSON('/usersList', function(responseData) {
            responseData = _.filter(responseData, function(item) { return item.name.toLowerCase().indexOf(query.toLowerCase()) > -1 });
            callback.call(this, responseData);
        });
    }
});

And the source of /usersList looks like this:

[
    {
        "id": "Praveen",
        "name": "Praveen Kumar",
        "avatar": "/img/users/1.jpg",
        "type": "user"
    },
    {
        "id": "jeff",
        "name": "Jeff Atwood",
        "avatar": "/img/users/2.jpg",
        "type": "user"
    },
    {
        "id": "pekka",
        "name": "Pekka Gaiser",
        "avatar": "/img/users/3.jpg",
        "type": "user"
    },
    {
        "id": "billgates",
        "name": "Bill Gates III",
        "avatar": "/img/users/4.jpg",
        "type": "user"
    }
]

If you could see, there's a Full Name (name) and a username (id) associated with every user. I would like the plug-in to display the username along with the full name, so I made an amendment to the JSON like this:

"name": "Praveen Kumar (@Praveen)",

But this gives an effect like below in the textarea:

Hello Praveen Kumar (@Praveen), how are you?

Instead of displaying like:

Hello Praveen Kumar, how are you?

I want this to be displayed only when the suggestion takes place and not during the insertion into the textbox. I know this can be changed using templates, but there's no documentation anywhere given on their website. Can someone help? I am using this:

templates: {
    wrapper: _.template('<div class="mentions-input-box"></div>'),
    autocompleteList: _.template('<div class="mentions-autocomplete-list"></div>')
}

Any heads-up on this part? Thanks in advance.


Source: (StackOverflow)