Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

allow handleLinks to do aliases

by castaway (Parson)
on May 15, 2005 at 11:06 UTC ( #457196=pmdevtopic: print w/ replies, xml ) Need Help??
castaway has raised the following topic:

So that we can make aliases for link shortcuts in handlelinks settings such as:  wikipedia =wp Make the following change to Everything/HTML.pm:
sub handleLinks { for(_test){ goto &$_ if $_ } my( $inner, $lastnodeid )= @_; my $title; my $HLS= getVars(getNode('handlelinks settings','setting')); my( $prefix, $nodeloc )= split( /:\/\//, $inner, 2 ); if($nodeloc){ ## change here $prefix = $1 if($$HLS{lc($prefix) =~ /^=(\w+)$/); ## ($nodeloc,$title)=split(/\|/,$nodeloc,2); my $cpantitle=$title || $nodeloc; my $escapedname=$query->escape($nodeloc); if($prefix){ if($$HLS{lc($prefix)}){ eval($$HLS{lc($prefix)}); } else { return "[$prefix://$nodeloc]"; } } } else { return linkNodeTitle($inner); } }

C.

Comment on allow handleLinks to do aliases
Select or Download Code
Re: allow handleLinks to do aliases
by theorbtwo (Prior) on May 15, 2005 at 11:12 UTC

    This doesn't allow for aliases to aliases. while ($HLS->{lc $prefix) =~ /^=(.*)/) {$prefix = $1} will keep going until it's done.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      This is true, however since these are not random people adding the aliases, but actual seasoned pmdevs, I would hope that would be a waste of cycles.. ;)

      C.

        Given the extreme difficulty in joining pmdev ... I'm not so sure we're that far away from "random people" ;-}

        (I had to say it before someone said it about me ;-)

Re: allow handleLinks to do aliases
by ysth (Canon) on May 15, 2005 at 14:16 UTC
    return "[$prefix://$nodeloc]"; had better become return "[$inner]"; then.

    I'd also like to see the // become optional; does anyone have a problem with doing that (for all prefixes)?

      Only hysterical ones, why change a long established tradition?

      C.

Re: allow handleLinks to do aliases
by tye (Cardinal) on May 15, 2005 at 14:31 UTC

    I thought we already had aliases where a setting value matching /^\w+$/ indicated an aliases. But perhaps that is only in the long-unfinished replacement?

    - tye        

      Presumably, since I don't see it in the current code..

      C.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2014-09-21 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls