Open jmillerdesign opened 9 years ago
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.
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.
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?
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.
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}' //
}
} );
+1 @devonzara; good thinking!
:+1: Any word on this?
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.
I'd be willing to help out on a PR if we can agree on a syntax.
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 notifications@github.com 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.
@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.
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