← Back to team overview

elementary-dev-community team mailing list archive

Re: Pantheon Terminal clickable protocols

 

Based on the example you gave, basically to illustrate the idea:

this.clickable("""(https?|ftps?|((bzr|git|svn|hg)(+ssh)?)))://\S+""")

i.e. group the protocols that can have a +ssh suffix, and then add the
suffix as an option for this group, do make sure you've got all the
brackets correct. (Given that | is the 'or' operator here you might not
need to escape the +, but as mentioned before, just check the
documentation for this.)

On 09/24/2012 11:56 AM, David Gomes wrote:
> Thank you, I'll fix it when I get home, but I wish I didn't have to type
> all those +ssh for bzr, git, hg, svn...
> 
> On Sep 24, 2012 10:47 AM, "Pim Vullers" <pim@xxxxxxxxxxxxxx
> <mailto:pim@xxxxxxxxxxxxxx>> wrote:
> 
>     Normally a + in regexp means 'or', so you need to escape it. I you
>     should use guess \+, so git\+ssh. But you should check the escape
>     character in the regexp/function documentation.
> 
>     On 09/24/2012 11:44 AM, David Gomes wrote:
>     > Indeed, I fixed the ? on the branch, but the + sure looks weird.
>     Any ideas?
>     >
>     > David "Munchor" Gomes
>     >
>     > On Sep 24, 2012 10:04 AM, "Pim Vullers" <pim@xxxxxxxxxxxxxx
>     <mailto:pim@xxxxxxxxxxxxxx>
>     > <mailto:pim@xxxxxxxxxxxxxx <mailto:pim@xxxxxxxxxxxxxx>>> wrote:
>     >
>     >     The question mark can be used to include both http and https
>     by just
>     >     writing https? (which makes the s optional). I agree that
>     Sergey's list
>     >     (in combination with the one already listed, and I guess the +
>     needs
>     >     some escape in the regexp) should suffice. You definitely do
>     not want to
>     >     use * since that would allow invalid schemes to become
>     clickable which
>     >     does not help anybody.
>     >
>     >     On 09/24/2012 10:46 AM, David Gomes wrote:
>     >     > Thank you Shnatsel. What do you guys think of Mefrio's
>     option? If
>     >     I had
>     >     > "*" for all protocols then "omgwtf://" would be a protocol
>     and that's
>     >     > not right, is it?
>     >     >
>     >     > Regarding the RegEx syntax, I'll take another look at it
>     because you
>     >     > seem to be right.
>     >     >
>     >     > On Sun, Sep 23, 2012 at 12:16 PM, Sergey "Shnatsel" Davidoff
>     >     > <sergey@xxxxxxxxxxxxxxxx <mailto:sergey@xxxxxxxxxxxxxxxx>
>     <mailto:sergey@xxxxxxxxxxxxxxxx <mailto:sergey@xxxxxxxxxxxxxxxx>>
>     >     <mailto:sergey@xxxxxxxxxxxxxxxx
>     <mailto:sergey@xxxxxxxxxxxxxxxx> <mailto:sergey@xxxxxxxxxxxxxxxx
>     <mailto:sergey@xxxxxxxxxxxxxxxx>>>>
>     >     wrote:
>     >     >
>     >     >     2012/9/23 David Gomes <david@xxxxxxxxxxxxxxxx
>     <mailto:david@xxxxxxxxxxxxxxxx>
>     >     <mailto:david@xxxxxxxxxxxxxxxx <mailto:david@xxxxxxxxxxxxxxxx>>
>     >     >     <mailto:david@xxxxxxxxxxxxxxxx
>     <mailto:david@xxxxxxxxxxxxxxxx> <mailto:david@xxxxxxxxxxxxxxxx
>     <mailto:david@xxxxxxxxxxxxxxxx>>>>
>     >     >
>     >     >         Hey everyone,
>     >     >
>     >     >
>     >    
>     https://code.launchpad.net/~elementary-apps/pantheon-terminal/new-protocols
>     >     >
>     >     >         If you have some free time, please check that branch
>     and add
>     >     >         some new protocols (or tell us about other ones with a
>     >     reply to
>     >     >         this email):
>     >     >
>     >     >
>     >     >
>     >    
>     this.clickable("""(http?|ftp?|https?|ftps?|irc?|sftp?|mailto?)://\S+""");
>     >     >
>     >     >         The other day we discussed this on IRC and shnatsel and
>     >     voldyman
>     >     >         told me about lots of protocols. The channel wasn't
>     being
>     >     logged
>     >     >         at the time and I forgot some of the protocols they
>     suggested.
>     >     >
>     >     >
>     >     >     The following URI schemes are relevant in a terminal:
>     >     >
>     >     >     ldap, ldaps, nfs, smb, rsync, ssh, rlogin, telnet, git,
>     git+ssh,
>     >     >     bzr, bzr+ssh, svn, svn+ssh
>     >     >
>     >     >     Depending on the regexp syntax (and you seem to have a
>     really
>     >     weird
>     >     >     one here, with "?" after every URI option - that typically
>     >     makes the
>     >     >     last character optional) and implementation details, you
>     also
>     >     might
>     >     >     want to add matching a delimiter before the URI scheme,
>     so that
>     >     >     "omgwtfhttp://"; won't be treated as a URl.
>     >     >
>     >     >     --
>     >     >     Sergey "Shnatsel" Davidoff
>     >     >     OS architect @ elementary
>     >     >
>     >     >
>     >     >
>     >     >
>     >
>     >
>     >     --
>     >     Mailing list: https://launchpad.net/~elementary-dev-community
>     >     Post to     : elementary-dev-community@xxxxxxxxxxxxxxxxxxx
>     <mailto:elementary-dev-community@xxxxxxxxxxxxxxxxxxx>
>     >     <mailto:elementary-dev-community@xxxxxxxxxxxxxxxxxxx
>     <mailto:elementary-dev-community@xxxxxxxxxxxxxxxxxxx>>
>     >     Unsubscribe : https://launchpad.net/~elementary-dev-community
>     >     More help   : https://help.launchpad.net/ListHelp
>     >
> 
> 
>     --
>     Mailing list: https://launchpad.net/~elementary-dev-community
>     Post to     : elementary-dev-community@xxxxxxxxxxxxxxxxxxx
>     <mailto:elementary-dev-community@xxxxxxxxxxxxxxxxxxx>
>     Unsubscribe : https://launchpad.net/~elementary-dev-community
>     More help   : https://help.launchpad.net/ListHelp
> 
> 
> 



References