Mailing List |
Source Code |
Diggler 0.9 supports a new feature - user defined tools.
Tools are a way for you to add your own menu items to the Diggler drop down. Each tool consists of:
- A name (that can also be the menu label)
- A regular expression pattern to match against
- An action to perform when the URL matches the regular expression
For example, if you want to see how many sites link to the current URL, you could create a tool by going into the Diggler Options dialog, clicking Add... and entering:
- "Search for links using Google" as the name
- "^http://(+*)$" as the pattern
- "http://www.google.ie/search?as_lq=$1&btnG=Search" as the action
The pattern is what you want to match against. In this case the pattern matches against any URL beginning with "http://". The action is the URL you wish to load when the pattern fires. In this case the action contains a $1. The $1 is replaced by the bracketed section of the regular expression. e.g. if the URL was http://www.bbc.co.uk/ then $1 would contain www.bbc.co.uk/.
If the current URL does not match the regular expression (e.g. the address begins with ftp:// when the expression is matching against http://), the tool is not shown in the menu. So the pattern also acts as the context that hides or shows the menu item.
For more info regular expressions, see some of the links at the bottom of this page.
The Diggler tool dialog has a combo which includes some commonly used patterns
- "^(+*)$" - Shows everything (except blank). If you want to match blank as well use .* instead of +*
- "^(ftp|http)://(.*)" - applies to ftp and http protocols only
- ^http://([a-zA-Z0-9]*).somedomain.com/.*$ - any site in the belonging to somedomain.com (e.g. news.somedomain.com, www2.somedomain.com etc.)
Your action may also expand out of specific parts of the original URL, by using these macros:
- $S - the whole URL
- $c - the scheme - e.g. http, ftp, https etc.)
- $h - the host (e.g. www.mozilla.org)
- $t - the port number (e.g. 80)
- $u - the username / password (e.g. fred:bloggs)
- $p - the path (e.g. /my/path/index.html)
- $1, $2 etc. - parts of the regular expression to be subsituted.
- http://dmoz.org/Computers/Programming/Languages/Regular_Expressions/ - A whole direction of links to various regexp sites.
- http://www.cuneytyilmaz.com/prog/jrx/ - A dynamic regular expression tester