Skip to:
Content
Pages
Categories
Search
Top
Bottom

@ links (mentions)


  • Michael
    Member

    @michael888

    Have been working on my forum recently, and I have though tof something I’d like to add to it.

    Now, I’m no plugin developer, or PHP junkie, but I’d like to know what steps would be needed to turn @ links (mentions, like those found on Twitter) into links that take the user to a members profile page/or maybe even the member’s website (if any).

    Example:

    @matt‘ would become ‘@matt

    It would obviously have to scan through the post, check for any mentions, check if the user exists, and if it does, then apply the link. Now, I have no idea how this would be implemented – I hope to learn more soon. :)

    This may not be a very great idea to have for a bbPress forum, but I think it would be nice. Could anyone help me with this?

    Peace, Michael

Viewing 21 replies - 1 through 21 (of 21 total)

  • OKTeaRoom
    Member

    @oktearoom

    http://bbpress.org/plugins/topic/easy-twitter-links/#post-4191

    Has a conflict with the video plugin on my forum but other than that it work(ed) fine.

    if you look at the buddypress code for activity-notifications (can’t remember the filename) but they have a simple function that filters the content, checks for @<username> string, then validates against the usertable and rewrites the content with a link.


    Michael
    Member

    @michael888

    @OKTeaRoom – I will have a look at that – though I’d also need to find out how to check for member existance.

    @etiviti – Thanks, I’ll download it and run through the code. I’m sure it’ll be easy to make the plugin.


    Michael
    Member

    @michael888

    Right, I have looked at the Easy Twitter Links plugin, but I’m not sure how to alter it to run through the post. I’d probably have some idea if I managed to find the code BuddyPress uses. I wish I could grep the folder, but I don’t have Linux…


    kevinjohngallagher
    Member

    @kevinjohngallagher

    BBprogress had two versions of this one mate, they should still be kicking around somewhere. The first one used Ajax to convert the links (it pinged a search page for @username).

    That said… My issue with it at the time is my issue with what you’re trying to achieve as well. 9/10 when someone is typing “@Michael R” they are replying to a post above. To that end, the “@Michael R” should link to that post, not to the person’s profile page. What you effectively need is a “reply to” button as well as a “quote” button that pre populates the “@Michael R” information.

    Writing that functionality isn’t a problem (check out the quote plugin), but rather that there is no hook in BBpress that doesn’t hardcode output from the core to the bottom of each post. Not only would you need a plugin, but you’d also need a theme with additional hooks/function calls.

    Its definitely doable though, once yu have defined exactly what it is you’re after/the need is for it :)


    Gautam
    Member

    @gautam-gupta

    I am currently in the process of writing a plugin for it.


    Michael
    Member

    @michael888

    @kevinjohngallagher – I see. I did think of that, but I didn’t realize how neccesary it is. Seems it could work.

    @Gautam – Thanks – will it be the same as the one found on Twitter/Vanilla, and maybe with Kevin’s suggestion?


    Gautam
    Member

    @gautam-gupta

    Currently it adds an option in the admin panel to let the admin choose whether to link the users to the profile page or to their website (if website doesn’t exist, then they’re linked to profile page), and it filters each post for all @username, if the username exists, then it links it.


    Michael
    Member

    @michael888

    Great – thanks Gautam. Looking forward to it. :) (Are you maybe calling it bbMentions? ;) )


    Gautam
    Member

    @gautam-gupta

    I have named it Easy Mentions.


    Michael
    Member

    @michael888

    Nice :)


    Gautam
    Member

    @gautam-gupta

    Ok, the plugin is ready. Just waiting for it to get approved.


    Gautam
    Member

    @gautam-gupta

    Replying to kevinjohngallagher’s post (maybe its in spam, but I got an email notification as I am subscribed to topic):

    1) Making “@” links is cool, and very “twitter generation”, even if its not something that’s totally globalised yet. But the “@” link is not pointing at what you’re replying to. We’re faking the functionality without the reasoning, which in the end will just confuse users.

    On Twitter, you post on your profile page. People read it on their feed, and reply on their own Profile page. So a link to “@kev” goes to the page where “kev” has written his post. That’s the point of it, to link to someone’s post.

    Here, we’re making the link “@kev” go to “/profiles/kev/” for the user to not see the post. That’s exactly the opposite of the purpose of the “‘@” linking system :)

    –> That’s basically the work of a reply plugin, not of a mentioning plugin. I also have future plans with the plugin like linking #tag, etc. Even if I do something like that which you have mentioned, then a single user can make multiple posts, then which post will the plugin link to?

    2) The other issue is that Twitter names don’t have spaces, while BBpress / wordpress names can. So if i write “@Michael R Thanks for your reply”, how does the plugin know where the username ends? What if it finds a “michael” in the usertable, it will then link “@Michael” to “/profiles/michael/” and the message will read “R Thanks for your reply”. In Twitter, it parses at the first space; but we can’t do that here.

    Oh that will also involve looping through queries until you find a match, so first for Michael, then for Michael R, then for Michael R Thanks etc. Ofcourse there could/should be a word/search limit – either way there is huge potential for database issues there. Imagine adding up to 5 sql searches, per “@” per post, per page load.

    The initial solution, and i suppose this is for Gautam, is to make a search of the user table for all users who have posted on the topic being replied to, which should narrow it down considerably, though it should be noted that if you have “Michael” and “Michael R”, or any similar naming issues, the plugin will not know that…

    –> That can’t be helped. The plugin first checks if that username exists, if not, then checks if that nicename exists. This will be also mentioned on the plugin page.

    3) You are effectively allowing a user to search your database for anything you put after your “@” symbol. Now this one is a little bit of scaremongering, but we’ve all seen bad coding before. What if I write “@drop table wp_usermeta hi bob, how much fun would this be :)“. There is a reason that we try to make sure we don’t take database queries from the user.

    –> 1) This is what is used to match the username – /[@]+([A-Za-z0-9-_]+)/, so there is no point of mysql commands going in there.

    If you want to test the plugin (how it works), you are free to use this as sandbox – http://forum.gaut.am/

    I have made some posts to test the plugin here.


    Michael
    Member

    @michael888

    Gautam, this looks great. Can’t wait to try it out. :)

    That can’t be helped. The plugin first checks if that username exists, if not, then checks if that nicename exists. This will be also mentioned on the plugin page.

    Is there no way to test as far as three spaces in (until it finds a username)?


    Gautam
    Member

    @gautam-gupta

    Replying to kevinjohngallagher’s post (which again went in spam):

    Let me put it this way, and outside of your plugin (which is excellent), why would someone need a link to a profile page from inside MY post, when there is a link to it one post up on your post. It serves, very little actual purpose. Anyway, that’s my PM/BA head coming out again, and that’s not liked here. Sorry.

    When Michael R said he was looking for something “like Twitter”. In this instance, it looks like twitter but acts differently (because on twitter your profile page is also the page you posted on). That’s just going to confuse the users, as the “@bob” was invented to allow people to follow conversations back the way.

    1) There is a space in the display name of Michael R, not the username – it is michael888 (though it doesnt mean that a bb username cant have spaces)

    2) I have already said that a single user can post multiple posts, so there is nothing that this plugin can interfere in. (Or you give a solution, if you have one)

    It has the potential to be a massive overhead. Again, highly unlikely, but what if someone added a spam post with just hundreds of “@bob a a @bob a b @bob a c”. I know its small stuff, but that’s 9sql queries right there. We’re really opening up the potential for someone to make a single post take 100s of SQL queries.

    There is no absolute solution for the space problem. Already, almost all sites don’t accept it (space in username), so almost all the people on net prefer taking usernames without spaces. Even if I put the code to match the spaces, then it might overload the server with so many requests.

    Update: I don’t prefer exploding the text with @ and space, that would have a huge long process…

    There is no necessity for spaces.


    Windhamdavid
    Member

    @windhamdavid

    Gautum – very nice! Have you investigated the use of @user mentions over at TestBP.org Perhaps integrating the two would be a great idea for future compatibility?


    Michael
    Member

    @michael888

    @Gautam:

    There is no absolute solution for the space problem. Already, almost all sites don’t accept it (space in username), so almost all the people on net prefer taking usernames without spaces. Even if I put the code to match the spaces, then it might overload the server with so many requests.

    Update: I don’t prefer exploding the text with @ and space, that would have a huge long process…

    There is no necessity for spaces.

    +1. Most people don’t do it anyway. They think,”username” and then automatically assume that there should be no spaces. As small as my forum is, there are no members that have spaces in their usernames (except me, however I changed it to use my display name).

    Now, is the process for finding spaces really that long, or long enough to make the server load heavy?


    Gautam
    Member

    @gautam-gupta

    @kevinjohngallagher

    Ok, so now I am adding a Reply link below each post (via jQuery). When the user clicks the link, it scrolls down to postform, with @<post-link><user-name> in text.

    But there’s another hurdle in this – post form is only displayed on the last page, so I’ll just make an option to show reply link, and tell the users how they can show post form on all pages.


    Gautam
    Member

    @gautam-gupta

    @kevinjohngallagher

    I am using javascript to only generate the @<user-link><user-name> in the post textbox when the user clicks the reply link below each post.


    Gautam
    Member

    @gautam-gupta

    The plugin is now released – http://bbpress.org/plugins/topic/easy-mentions/


    Gautam
    Member

    @gautam-gupta

    @kevinjohngallagher

    The code you wrote would make the script echo all the usernames in the source code. Think if there are hundreds of usernames or a user database like that of wordpress, which has thousands of usernames, will you echo all of them? And try to match each of that with javascript!?

Viewing 21 replies - 1 through 21 (of 21 total)

You must be logged in to reply to this topic.