Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Plugins ➜ Hyperlink URL plugin

Hyperlink URL plugin

Posting of new messages is disabled at present.

Refresh page


Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Fri 25 Jul 2003 02:41 AM (UTC)

Amended on Fri 25 Jul 2003 02:42 AM (UTC) by Nick Gammon

Message
This simple plugin detects lines with http://xxx arriving from the MUD, and converts the URL part into a hyperlink you can click on to go to the web site.

It is pretty simple. To do that it has to omit the "real" line from output and dummy up its own line with three parts:


  1. Before the hyperlink
  2. The hyperlink
  3. After the hyperlink


It doesn't know what colour the original line was in, so it just displays it in the default output colour (eg. white on black).

That means that lines with hyperlinks on them may display in the wrong colour. If this annoys you, don't install the plugin. :)

You can copy the plugin from below, or download it from:


http://www.mushclient.com/plugins/Hyperlink_URL.xml



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, July 25, 2003, 11:37 AM -->
<!-- MuClient version 3.42 -->

<!-- Plugin "Hyperlink_URL" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Hyperlink_URL"
   author="Nick Gammon"
   id="eb9ea32827509752b18f9d70"
   language="VBscript"
   purpose="Makes a URL on a line into a hyperlink"
   date_written="2003-07-25 11:35:21"
   requires="3.41"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Detects text starting with HTTP:xxx and makes that part into a hyperlink.

Limitations - 

1. Only detects one per line

2. The rest of the line will be shown in white on black -
   other colours will be discarded.
]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.vbs"/>

<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   match="(.*)(http\:\/\/(?:[A-Za-z0-9\.\\/\?])+)(.*)"
   omit_from_output="y"
   regexp="y"
   script="OnHyperlink"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Script  -->


<script>
<![CDATA[
sub OnHyperlink (name, line, wildcards)
  ColourTell RGBColourToName (NormalColour(8)), _
             RGBColourToName (NormalColour(1)), _
             wildcards (1)
  Hyperlink  wildcards (2), wildcards (2), "", "", "", 1
  ColourNote RGBColourToName (NormalColour(8)), _
             RGBColourToName (NormalColour(1)), _
             wildcards (3)
end sub


]]>
</script>


</muclient>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Norbert   USA  (61 posts)  Bio
Date Reply #1 on Fri 25 Jul 2003 08:16 PM (UTC)
Message
I've been using this trigger from the example you gave in the hyperlink thread and it works great except for it doent work if the link has a - or ~ in it, nor if the link wraps to a second line

Norbert

-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 25 Jul 2003 08:43 PM (UTC)
Message
It is hard if the link wraps to a 2nd line, if the MUD does a "hard" wrap because the line then becomes 2 lines and the trigger only matches one.

However the other problem is simple enough, just extend the regular expression, eg.

match="(.*)(http\:\/\/(?:[A-Za-z0-9\.\\/\?\-\~])+)(.*)"

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Norbert   USA  (61 posts)  Bio
Date Reply #3 on Wed 11 Feb 2004 04:27 AM (UTC)
Message
I've got the Hyperlink URL working great since I've updated the triggers.

<triggers>
  <trigger
   enabled="y"
   make_bold="y"
   match="(.*)(www\.(?:[A-Za-z0-9\.\\/\?\-\~\,\&amp;\=\_])+)(.*)"
   omit_from_output="y"
   regexp="y"
   script="OnHyperlink"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>

  <trigger
   enabled="y"
   match="(.*)(http\:\/\/(?:[A-Za-z0-9\.\\/\?\-\~\,\&amp;\=\_])+)(.*)"
   omit_from_output="y"
   regexp="y"
   script="OnHyperlink"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>


The only problem is, and not very often, that some links pop up a window that says:
Hyperlink action "(the link it tried)" - permission denied.

But when I select the text in the output window and right-click and click on Go to URL... the link will open up fine.

anyone know what maybe wrong or any solutions?

Norbert

-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 11 Feb 2004 05:54 AM (UTC)
Message
There is a check in the hyperlink code that the hyperlink must start with one of:

http://
https://
mailto:

Also, there is a bug in MUSHclient 3.43 and earlier that the https:// variant doesn't work anyway. This will be fixed in 3.44

Your problem is that you have expanded my idea to include www.xxxxxx - this does not start with "http://".

What you need to do is change the script a bit to convert it.

eg.


link = wildcards (2)
if left (link, 4) = "www." then
  link = "http://" & link
end if
Hyperlink  link, link, "", "", "", 1



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Norbert   USA  (61 posts)  Bio
Date Reply #5 on Wed 11 Feb 2004 11:53 AM (UTC)
Message
Thank you very much it works great

Norbert

-Do you know what it's like to fall in the mud and get kicked... in the head... with an iron boot?
Of course you don't, no one does. It never happens
It's a dumb question... skip it.
Top

Posted by 1of10   Canada  (54 posts)  Bio
Date Reply #6 on Sat 10 Apr 2004 07:35 AM (UTC)

Amended on Sat 10 Apr 2004 07:37 AM (UTC) by 1of10

Message
This is a, hopefully, completely complete URL match for the Hyperlink_URL plug-in:

match="^(.*)((?:(?:(?:https?|ftp)\:\/\/)|mailto\:)[\w\d\/\.,_\-=~#\?\&amp;\+\%:;@\|\$]+)(.*)$"

The above RegExp will match http://, https://, ftp:// and mailto: URLs, including, I hope, all legal URL characters.

Also, regarding the URL without the protocol, ie: www.some-host.com, a more proper check would be to check for the existance of a protocol, rather than just check if the URL starts with 'www.'. That method leaves out FTP URLs (ftp.some-host.com) and website URLs that don't start with 'www.'.

On the other hand, as I think more on the solution, I realize it would require a very complex RexExp to match only on a protocol-less URL, and not everything that somewhat resembles one. :p

One of Ten
Secondary Adjunct of Unimatrix Z03
Top

Posted by Haflinger   (9 posts)  Bio
Date Reply #7 on Sat 28 Aug 2004 12:54 AM (UTC)
Message
I've found another character this Plugin doesn't like..

http://g.msn.com/0VD0/02/26?m=fotp_donkey.wmv&csid=3&sd=mbr

Seems it breaks at the first = sign. Notice this doesn't wrap around to start a second line.

Have a good one,
Haflinger

Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #8 on Sun 05 Sep 2004 05:07 AM (UTC)
Message
In my original plugin there is a regexp that looks for URLs:


In the middle of that (inside square brackets) are the characters it allows:

[A-Za-z0-9\.\\/\?]

This basically means:

A-Z
a-z
0-9
period (.)
backslash (\)
forward slash (/)
question-mark (?)

Just add more to that list. I think an = sign can be itself, and an ampersand needs to be put as &amp;. So it could be:


[A-Za-z0-9\.\\/\?&amp;=]



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


32,643 views.

Posting of new messages is disabled at present.

Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.