Autolinker.js icon indicating copy to clipboard operation
Autolinker.js copied to clipboard

Add support for usernames across more social networks

Open jmillerdesign opened this issue 9 years ago • 11 comments

Could this either be added to the core, or could you explain how I could pass options to Autolinker.js to allow for this? It's limiting usernames to 15 characters, but other networks support longer usernames.

Twitter: 15 Instagram: 30 Facebook: 50 Tumblr: 32

jmillerdesign avatar Sep 04 '15 19:09 jmillerdesign

Hey, sorry for the late response here.

Currently Autolinker only has built-in support for Twitter and there's really no way to override it, but I like the idea of a username option and specifying which service it should link to. Will work on this.

gregjacobs avatar Nov 08 '15 03:11 gregjacobs

I feel like Twitter username should be something generic rather than tight to one service. It could default to twitter, but user should be able to defined the URL and syntax easily.

For this it would make sense to rename twitter thing to something else, so it would be a breaking change.

My usercase would be to use it with my own site's usernames, actually.

simison avatar Nov 08 '15 17:11 simison

Definitely agree, and interesting point too for your own website. I think we can maintain backward compatibility though for the options, where the newer username option would just override the twitter option if both are provided.

Any ideas on how you might like the options laid out for this? My initial thought is something like this:

Autolinker.link( text, {
    username : 'twitter'  // or 'facebook', 'instagram', 'tumblr', etc.
} );

And then for the use case of your own website, you can always use the replaceFn, but feeling like it should be a bit easier if possible. Maybe something like this:

Autolinker.link( text, {
    username : { 
        type: 'custom', 
        template: 'http://my.website.com/{username}' 
    }
} );

Thoughts?

gregjacobs avatar Nov 08 '15 20:11 gregjacobs

Yeah and I feel like passing regexp as an option should be possible as well, since someone might want to support _-. and capital letters and some just lowercase a-z.

Oh and sometimes you might want to recognise capital letters but have them lowercase at the URL.

simison avatar Nov 09 '15 00:11 simison

Personally, I'd prefer the term 'mention' rather than 'username', but that would break backwards compatibility unless made as an alias. Secondly, I'd probably use service rather than type.

I agree that there should be an optional regex option and a way to set the prefixing character/regex, seeing as services such as Google+ use a + instead of an @ symbol.

eg.

Autolinker.link( text, {
    mention: { 
        service: 'custom', // twitter (default), facebook, instagram, tumblr, google
        regex: '[A-Z][a-zA-Z0-9]{2, 13}',
        prefix: '+',
        template: 'http://my.website.com/{username}' // 
    }
} );

devonzara avatar Nov 09 '15 17:11 devonzara

+1 @devonzara; good thinking!

simison avatar Nov 10 '15 04:11 simison

:+1: Any word on this?

ReedD avatar Dec 01 '15 17:12 ReedD

Resurecting in 3...2...1 @devonzara Do you have any work done for your suggestion, I would like to get an implementation of this into a PR but wanted to double check if you had any work in progress.

antondomratchev avatar Apr 25 '16 19:04 antondomratchev

I'd be willing to help out on a PR if we can agree on a syntax.

jmillerdesign avatar Jun 13 '16 16:06 jmillerdesign

blockquote, div.yahoo_quoted { margin-left: 0 !important; border-left:1px #715FFA solid !important; padding-left:1ex !important; background-color:white !important; } Hey, yes, so sorry, I'm so crazy busy these days. What are your thoughts on that?

Sent from Yahoo Mail for iPhone

On Monday, June 13, 2016, 12:30 PM, J. Miller [email protected] wrote:

I'd be willing to help out on a PR if we can agree on a syntax.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

gregjacobs avatar Jun 13 '16 21:06 gregjacobs

@jmillerdesign : as of today, we have, mentions for Twitter and Instagram.

With the current structure, I guess it would be relatively easy to add Facebook and Tumblr if this is still wanted.

olafleur avatar Mar 03 '17 02:03 olafleur