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

Feature idea for code tags

by goibhniu (Hermit)
on Nov 30, 2007 at 16:43 UTC ( [id://654143]=monkdiscuss: print w/replies, xml ) Need Help??

I had an idea that PMDevils might consider. My idea came when reading clipcommand.pl (Embed perl into your clipboard). In that post, antirice has 7 <code> blocks; one of them the "big one". I love the download tag (thanks to whomever coded that a long time ago), but each time I click one in this post, they're always defaulted to save as 648493.pl. It's no big deal to rename it, but my idea was that the author might be given the power to change the default save file name as an attribute to the code tag.

Thus, when antirice puts his little macros in code tags he could just enclose them in <code></code>; the default {nodeid}.pl would still hold. When he puts the big script in it might read <code savename="clipcommand.pl"></code>.

This might help out in other places where someone has put a sample data file in code tags (instead of after __DATA__) and then referred to a file name in their script enclosed in separate code tags. The file name could be in the savename attribute on the data file's opening code tag.

This is really just a brainstorm - I'm not complaining nor do I feel terribly inconvenienced as is. If PMDevils has plenty to do, then I'd rate this as a low priority snazzy feature instead of a "make the masses happy" feature.


I humbly seek wisdom.

Replies are listed 'Best First'.
Re: Feature idea for code tags
by roboticus (Chancellor) on Nov 30, 2007 at 20:58 UTC
    goibhniu:

    That's a pretty cool idea! I don't know how many people would use it, but I'd love it if it were widespread. (I have too many 6xxxxxx.pl files in my PM directory.)

    Might I offer one suggestion?

    If someone codes that up, it would be pretty nice to have the option of having the first few words (less Re:...) of the title. It would make it easier to recognize 'em in my directory.

    Of course ... I'm not sure that having a directory full of names like PLZHelpMe.pl, UrgentQuestion.pl, WhyshouldIuse.pl, etc. would be any better than numbers. At least with the numbers, you can put 'em in mostly chronological order.

    ...roboticus

Re: Feature idea for code tags
by moritz (Cardinal) on Dec 02, 2007 at 13:39 UTC
    I think an acceptable solution that doesn't change the syntax of <code> tags is to use a filename of the form $node_id . "_" . $index_of_code_tag.

    That proposed filename can be sent with the appropriate Content-Disposition HTTP header.

    That way no node author has to invent names, and when you save multiple code tags from one node you don't have to rename them manually to avoid name clashes.

      I leave implementation details to PMDev of course; I only have an idea. But the intent of my idea was to have the savename="" attribute be optional so that no one who didn't want to would have to use it.


      I humbly seek wisdom.
Re: Feature idea for code tags
by Erez (Priest) on Dec 02, 2007 at 07:55 UTC

    Thus, when antirice puts his little macros in code tags he could just enclose them in ; the default {nodeid}.pl would still hold. When he puts the big script in it might read <code savename="clipcommand.pl"></code>.

    I second that, for full scripts/programs. I don't mind having a snippet saved as a number.pl, but I like knowing what a program is without having to read/run it.

    Software speaks in tongues of man; I debug, therefore I code.

Re: Feature idea for code tags
by blazar (Canon) on Dec 02, 2007 at 13:30 UTC

    I personally believe that while I often just set the name explicitly when saving, the idea is great. I have a different and IMHO bigger problem, though: when I right-click on the download link in FF and select "save target as", it wants to save it as [download].htm which is much more annoying than than 123456.pl - I have to open in a new tab and "save as"... I don't know whether that's an issue with my browser/system and if it's fixable on the PM part.

Re: Feature idea for code tags
by jasonk (Parson) on Dec 01, 2007 at 16:04 UTC

    I can see that possibly getting abused with people trying to be clever (<code savename="bash">?). What might be just as useful, and potentially easier to implement is simply to add an index to the default name. So the first code block on the page would be 648493-1.pl, the second 648493-2.pl, etc...


    We're not surrounded, we're in a target-rich environment!
      I can see that possibly getting abused with people trying to be clever (<code savename="bash">?).
      Not a big deal, as long as you aren't browsing as root, stuff your downloads automatically into /bin, have your browser overwrite exising files without asking, and do a chmod a+x on each downloaded file without looking.

      So what? Let a malicious monk (I doubt there are many of them here) try to make me save a file as /sbin/init, and be assured there will be a post in Perl Monks Discussion warning all Monasterians about the scoundrel.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      This could be addressed by modifying the name - eg. prefixing all downloads with "pm-" or somesuch.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-18 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found