Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

New bracket-link stuff

by theorbtwo (Prior)
on Apr 23, 2004 at 18:58 UTC ( [id://347710]=monkdiscuss: print w/replies, xml ) Need Help??

Allo, all.

I've been working on bracket-links lately. Specificly, I've fixed at least one bug, and added two new link types.

The first new link type is doc://. This is meant to combine the good bits of perldoc with the good bits of the onsite docs. It links to perldoc.com's documentation, like perldoc://. Unlike perldoc://, it links to actual docs, not a search for docs (currently for the documentation for 5.8.0. I will make this configurable at some point). It attempts to DWYM: If the link begins with "perl", it is to a manpage. If it does not, it is to a function. Thus, perlre, or stat DWYM, assuming you mean what I thought you did.

The more prosaic pseudo-URI-schema is href:// (also known as link://). This lets you link to whatever you like, even if it has a strange schema, or none at all. For example, to point to the "node template" setting in user settings directly, you can say "[href://?node=user+settings#Node-Template]" (?node=user+settings#Node-Template). If you're talking about a recent Mozilla in the CB, and want to link to the config screen, you can say [href://about:config] ([href://about:config]).

Oh, and the bug: At least some places where using | multiple times chopped things off. There are still bugs lurking, though. If you know of any, please reply with things that should be valid links (but aren't), and what you expected them to render like. (I don't promise to fix all of them, of course -- and I may even declare some of them to be features.)

I really want feedback on all of this -- please, don't consider any of the new things discussed here to be fixed yet -- meaning don't use them in nodes, except on this thread. OTOH, please try them out in the CB, to get a feel for them.

Update: Fixed stupidity.


Everything is subject to change

Replies are listed 'Best First'.
Re: New bracket-link stuff
by theorbtwo (Prior) on Apr 23, 2004 at 19:29 UTC

    Also fixed: [lucky://mu doch|mu!] -- |titles on lucky:// links.

    On the horizion:

    • [href://gopher://gopher.quux.org] cutting you off at the second ://.</code>
    • The multiple-| bug mentioned above, except for cases with a schema given.


    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).

Re: New bracket-link stuff
by davido (Cardinal) on Apr 24, 2004 at 05:15 UTC
    Bravo theorbtwo. From CB discussion to actual preliminary implementation in 24 hours!

    One thought on the ability to configure [doc://...] for different POD versions...

    You could allow for this type of format: [doc://podname:version]. I know of no POD containing a colon in its name. The trick would be that if the version number is for a version not available on www.perldoc.com, the DWIMery mechanism would go for the next higher or next lower version that does exist on the site. I would vote for "rounding down" to the nearest version. For example, if someone requests the following link: [doc://perlre:5.8.2], which doesn't exist at www.perldoc.com, the mechanism would round down to [doc://perlre:5.8.0].

    Also, it may be nice to allow for a user setting that sets the "default" POD version number to be used with the [doc:// tag.

    Some of this may be too much work; I don't know what the code looks like.

    One other question: Is there a defined behavior if this tag is used on core modules?

    Anyway, good job on getting this up and running so fast.


    Dave

      I was thinking for specific-version links, allowing doc://5.8.3/perlre, and making a drop-down in user settings to set your default.

      There is a defined behavior for use on any string not matching /^perl/: assuming it is a function. Thus, Time::Local links to the documentation of the (nonexistant) function Time::Local; if you wanted the documentation of that module, you should have said Time::Local. (Core modules are on cpan.) I may change that to output some plain ol text, as it's pretty clearly an error. I may even extend the DWYMery to link to the POD for that module, though I'm worried that we'll get into places where we are unable to do what you meant: is doc://open documentation on the module open, or the function open? (Yes, there is one of each.)


      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).

        Allow, detect, and strip trailing doublecolons. perl does this, so we should too. Then Open:: is distinct from open.
Re: New bracket-link stuff
by Juerd (Abbot) on Apr 25, 2004 at 09:47 UTC

    Why is the // still needed?

    [href://javascript:alert('foo')|And I don't think this is a good idea.]

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      The :// is needed because it seperates the pseudo-uri-schema from the rest-of-the-uri. (Real URIs use : for schemas that do not take a hostname next, but this isn't a real uri, and doesn't use quite the same syntax.)

      And as to the second point, we do bracket-link expansion before HTML verification, IIRC, and thus it doesn't make that sort of "attack" much easier. As always, look before you leap click. (And don't use a browser that lets people lie about where links point, like some unpatched IEs.)

      test

      The HTML filtering code could, at some point, be enhanced to check for this sort of attack, but I'm not sure I understand that code sufficently to do that -- that would be more of a tyeish project.


      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).

      I agree with theorbtwo, it's really an issue with the html filtering.

      Indeed, you can do that without brackets, like you type

      <a href="javascript:alert('foo')">this</a>
      you get this.
Re: New bracket-link stuff
by ambrus (Abbot) on Apr 24, 2004 at 21:34 UTC

    There's a problem where the title contains "://" too.

    If I write a link like [http://www.google.co.hu|lhs://rhs], its title gets only "lhs", not "lhs://rhs", but the link itself is correct, that is, it points to "http://www.google.co.hu". This is probably not related to this change, as it was like this before too. Is this behaivior on purpose or just a mistake?

    Example: lhs://rhs

    Update: removed "like" from first sentence, did not make sense there.

Re: New bracket-link stuff
by bart (Canon) on May 03, 2004 at 11:10 UTC
    A nice addition to [doc:// ... ] would seem to me, lookup into the official FAQ, like perldoc -q keywords does from the command line. I personally like [faq://keywords] as a syntax for the link.

    That could link to the FAQ section on perldoc.com, for example [faq://intersection] would point to the URL for the question "How do I compute the difference of two arrays? How do I compute the intersection of two arrays?" in perlfaq4.

    I'm not sure what a query with more than one result should yield. I'm inclined to think of a dynamic page on this site, with titles and links to its associated page on perldoc.com. Some mechanism to preselect one particular question in this list of results, in the link specification, would be extra nice.

    p.s. Currently, perldoc.com is having troubles. That way my example has to remain a bit on the abstract side.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: monkdiscuss [id://347710]
Approved by ybiC
Front-paged by castaway
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-03-28 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found