 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Jun 05, 2008 1:52 am
New "Clickable URLs" package being included by default in v2.26 |
Because of several user requests, I am including a new default package with CMUD 2.26 (like the English Directions/Keypad packages). It is called "Clickable URLs" and contains two triggers:
Code: |
#REGEX {\b(((https?|ftp|telnet)://[\w\d:#@%/;$()~_?\+\-=&]+|www|ftp)(\.[\w\d:#@%/;$()~_?\+\-=&]+)+)\b} {SUB {<A '%1'>%1</A>}}
#REGEX {\b([\w\d._%+\-]+@[\w\d.\-]+\.[\w]{2,4})\b} {#SUB {<A 'mailto:%1'>%1</A>}} |
If you have suggestions on improving these regular expressions, let me know. But you should know that I'm *not* trying to match 100% of the URLs or email addresses out there. The complete regex for URLs is way too complex and slow for this purpose. So I'm just trying to match 99% of what people might use on a MUD for URLs or email addresses.
In the first case, I want to match anything with "http|https|ftp|telnet://", but if that isn't specified, then I will also match on any URL that starts with "www" or "ftp". This handles most simple cases where the http:// is left out.
When I was implementing this, I found a bug in the parsing of #SUB commands with "http://%1" in them. This was from a package called "SWmud Clickables" which I initially tested. But I found better regular expressions than that package was using. But in the process of testing that package, I found the bug with http://%1 where it was treating //%1 as a module reference.
I have also removed the "underline MXP tags" option and replaced this with a full "URL Style" in the styles box. The default is to just underline URLs, but you can change this style to anything else you want. This allows you to easily color URLs if you want (something that was more difficult before).
In order to include this package in *existing* sessions, you will need to Edit your session, then go to the Packages tab and click the + button to add the new "Clickable URLs" package to the list. You might also want to go into your Preferences and add this to the default list of packages loaded for new sessions.
In *new* installations of CMUD, both of those are set by default: the Clickable URLs package will be included automatically in new sessions.
So, this should help brand new users who are accustomed to clickable links. But it won't break anyone's existing session that might already have their own triggers or packages for doing this. It also makes a good example of how packages can be used to add useful features to CMUD that CMUD might not include by default (which is the main purpose of packages). |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Jun 05, 2008 1:53 am |
woot!
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Jun 05, 2008 4:25 am Re: New "Clickable URLs" package being included by default in v2.26 |
Love this - but have a simple request.
Can you also add in the option to make anything that ends in .com, .net, .org, and other common endings be clickable? The reason I ask is because a lot of times, websites will not start with www or http://. It's easy enough to add to the REGEX, but if you could do it from the start, it would make things that much easier.
Charneus |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Jun 05, 2008 11:22 am |
www.pidgin.im
That's admittedly a very oddball one.  |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Jun 05, 2008 5:08 pm |
Fang Xianfu wrote: |
www.pidgin.im matches. |
Oh I know, I was adding to Charneus' comment, something like:
pidgin.im
wouldn't match. Not that it matters, I felt humored. |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Jun 05, 2008 5:32 pm |
As I said, it isn't going to match everything. Trying to match unqualified domains (like pidgin.im) would end up matching too much other text from the MUD that isn't a host name. If MUDs really want their links to be clickable, then they should use the http:// as they are supposed to. Or they should use MXP to provide a proper link.
I don't see any easy way to add the .com, .net, and .org endings unless someone can take a look at the regular expression that I posted at the top and give me a suggestion. Because looking for .com (for example), would mean adding something to the beginning of the pattern to allow any starting characters, since it doesn't start with http: or www or ftp. And adding something to the beginning that would match any text would then screw up cases where it started with http: but didn't end in .com etc.
I could probably do it with a second regex, but I wanted to keep the number of triggers down to a minimum. |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Jun 05, 2008 6:31 pm |
Zugg wrote: |
As I said, it isn't going to match everything. Trying to match unqualified domains (like pidgin.im) would end up matching too much other text from the MUD that isn't a host name. If MUDs really want their links to be clickable, then they should use the http:// as they are supposed to. Or they should use MXP to provide a proper link.
I don't see any easy way to add the .com, .net, and .org endings unless someone can take a look at the regular expression that I posted at the top and give me a suggestion. Because looking for .com (for example), would mean adding something to the beginning of the pattern to allow any starting characters, since it doesn't start with http: or www or ftp. And adding something to the beginning that would match any text would then screw up cases where it started with http: but didn't end in .com etc.
I could probably do it with a second regex, but I wanted to keep the number of triggers down to a minimum. |
It honestly seems fine the way you have it. And my comment was more a joke than anything. |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Tue Jun 10, 2008 3:36 pm |
So where is this package?
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Tue Jun 10, 2008 4:06 pm |
If you've already installed 2.26, it will not show up by default under Default Packages with your session. You'll have to add it manually. However, creating a new session does show it under default, as was already pointed out in this post, chamenas.
Just go to Options -> General -> Scripting -> Packages Tab and click the green +. Add the package that way, and you're good.
Charneus |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Jun 10, 2008 7:43 pm |
Both of those match the regex, so something else must be wrong.
|
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Jun 10, 2008 8:11 pm |
OK, I already mentioned this in my first post, but I'll repeat it again:
Quote: |
In order to include this package in *existing* sessions, you will need to Edit your session, then go to the Packages tab and click the + button to add the new "Clickable URLs" package to the list. You might also want to go into your Preferences and add this to the default list of packages loaded for new sessions. |
The procedure that charneus gave only makes CMUD add the Clickable URL to *new* sessions. For *existing* sessions, follow the instructions above to add the package to your session. It's just like adding any other package to your session. You can also add it to your session by going into the Settings Editor and select File/Open and open the Clickable URLs package that should be in your /packages subdirectory. |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Jun 10, 2008 9:06 pm |
It is also possible that the Clickable URL package is in your "install" directory in the "packages" subdir. For example: Program Files/CMUD/Packages instead of in the "datafiles" My Documents/My Games/CMUD/Packages directory.
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Jun 11, 2008 2:01 am |
Oh god, why does it sound so difficult. So what you are saying is if I make a new session, it will have them. But if I want it in the sessions that I already have set up (all my connections) I need to go a different route?
|
|
|
 |
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Wed Jun 11, 2008 3:17 am |
If you want in a session you already have. Right click the session, edit session, and go to the packages tab. Then click the + button.
|
|
|
 |
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Wed Jun 11, 2008 3:24 am |
chamenas wrote: |
Oh god, why does it sound so difficult. So what you are saying is if I make a new session, it will have them. But if I want it in the sessions that I already have set up (all my connections) I need to go a different route? |
Obviously. I mean, I wouldn't want to have to go through and delete default packages from my sessions each time I upgraded to a new version of CMUD (example: I don't use the 'English Keypad' package).
Package Editor: File>Open
There it is.
Its possible its in a different folder, depending on where you save YOUR package files normally. So if you do that and can't find it, just check in the CMUD>packages folder for it. |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed Jun 11, 2008 12:59 pm |
Yeah, I just right clicked on the session before I logged in...
|
|
|
 |
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Wed Jun 11, 2008 3:43 pm |
Does anyone know how to hide a package?
|
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Jun 11, 2008 3:52 pm |
Hide from which view? In the package editor, unchecking "show default packages" will hide the ones on the default list.
|
|
|
 |
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Wed Jun 11, 2008 4:22 pm |
Okay, how do I set a package to be considered default?
Basically, I don't want the aforementioned package to show as a tab across the top. I want to forget about it. I already have that option unchecked. |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Jun 11, 2008 6:53 pm |
Go into your Preferences and then click on the Scripting page, then click on the Packages tab. Click the + button to add a package to this list. Anything in this list is considered to be a "default" package and will be hidden by default in the settings editor.
|
|
|
 |
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Sun Jun 15, 2008 6:41 pm |
Zugg, here is an old zMUD trigger I made that captures ALL current tlds (according to wikipedia), if you'd like to use this converted into a regex for this package (note there is an alias to add more tlds, and supports multiple tld additions at once):
Code: |
#CLASS {Hyper Links}
#ALIAS addtld {
#CLASS {Hyper Links}
#var tmptld {%-1}
#var tmptld %subchar( @tmptld, " ", "|")
#WHILE (@tmptld != "") {
#ADDITEM tlds %item( @tmptld, 1)
#DELNITEM tmptld 1
}
#CLASS 0
}
#VAR tlds {.com|.net|.org|.us|.uk|.arpa|.root|.aero|.asia|.biz|.cap|.coop|.edu|.gov|.info|.int|.jobs|.mil|.mobi|.museum|.name|.pro|.tel|.travel|.ac|.ad|.ae|.af|.ag|.ai|.al|.am|.an|.aq|.ar|.as|.at|.au|.aw|.ax|.az|.ba|.bb|.bd|.bf|.bh|.bi|.bg|.bj|.bm|.bn|.bo|.br|.bs|.bt|.bv|.bw|.by|.bz|.ca|.cc|.cd|.cf|.cg|.ch|.ci|.ck|.cl|.cm|.cn|.co|.cr|.cu|.cv|.cx|.cy|.cz|.de|.dj|.dk|.dm|.do|.dz|.ec|.ee|.eg|.er|.es|.et|.eu|.fi|.fj|.fk|.fm|.fo|.fr|.ga|.gb|.gd|.ge|.gf|.gg|.gh|.gi|.gl|.gm|.gn|.gp|.gq|.gr|.gs|.gt|.gu|.gw|.gy|.hk|.hm|.hn|.hr|.ht|.hu|.id|.ie|.il|.im|.in|.io|.iq|.ir|.is|.it|.je|.jm|.jo|.jp|.ke|.kg|.kh|.ki|.km|.kn|.kp|.kr|.kw|.ky|.kz|.la|.lb|.lc|.li|.lk|.lr|.ls|.lt|.lu|.lv|.ly|.ma|.mc|.md|.me|.mg|.mh|.mk|.ml|.mm|.mn|.mo|.mp|.mq|.mr|.ms|.mt|.mu|.mv|.mw|.mx|.my|.mz|.na|.nc|.ne|.nf|.ng|.ni|.nl|.no|.np|.nr|.nu|.nz|.om|.pa|.pe|.pf|.pg|.ph|.pk|.pl|.pm|.pn|.pr|.ps|.pt|.pw|.py|.qa|.re|.ro|.rs|.ru|.rw|.sa|.sb|.sc|.sd|.se|.sg|.sh|.si|.sj|.sk|.sl|.sm|.sn|.so|.sr|.st|.su|.sv|.sy|.sz|.tc|.td|.tf|.tg|.th|.tj|.tk|.tl|.tm|.tn|.to|.tp|.tr|.tt|.tv|.tw|.tz|.ua|.ug|.uy|.uz|.va|.vc|.ve|.vg|.vi|.vn|.vu|.wf|.ws|.ye|.yt|.yu|.za|.zm|.zw|.xn--zckzah|.xn--0zwm56d|.xn--11b5bs3a9aj6g|.xn--80akhbyknj4f|.xn--9t4b11yi5a|.xn--deba0ad|.xn--g6w251d|.xn--hgbk6aj7f53bba|.xn--hlcj6aya9esc7a|.xn--jxalpdlp|.xn--kgbechtv}
#VAR tmptld {}
#TRIGGER {(%q)({https://|http://|ftp://|telnet://|www.|ftp.}%x)(%q)} {#SUBSTITUTE {~<A '%quote(%2)'>%1%2%3~</A>}}
#TRIGGER {(%q)(%x)~@(%x)(%q)} {#SUBSTITUTE {~<A 'mailto: %quote(%2)~@%quote(%3)'>%1%2~@%3%4~</A>}}
#TRIGGER {(%q)(%x{@tlds})(%q)} {#SUBSTITUTE {~<A '%quote(%2)'>%1%2%3~</A>}}
#CLASS 0
|
|
|
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
 |
|
|