Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

allow handleLinks to do aliases

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

So that we can make aliases for link shortcuts in handlelinks settings such as:  wikipedia =wp Make the following change to Everything/
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); } }


Replies are listed 'Best First'.
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.. ;)


        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?


Re: allow handleLinks to do aliases
by tye (Sage) 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..


Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2018-06-20 17:28 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.