I like the "display/download code" feature as it is. The code shows up as simple text in my browser and I can click "save as" to actually save the file. However, in the file save dialog the filename is always "index.pl". I was thinking that the HTTP "Content-Disposition" header could be used here; I'm sure you guys know what it's about. One, it could specify the filename explicitly (although I'm not sure how the node author would enter it); two, it could have the "attachment" type for the download dialog to popup immediately. I actually like that it doesn't pop up the d/l window right away, that behaviour can be preserved by leaving "inline" as the disposition type. Anywho, just thought it could be a bit of food for thought. I use Firefox btw.

Replies are listed 'Best First'.
Re: Displaycode suggestion
by theorbtwo (Prior) on Nov 25, 2004 at 18:27 UTC

    I like the idea -- I'm just not sure what the name should be... the name of the node with .pl appended, the nodeid with .pl appended, a cleanup of the node name...

    # $NODE is a common feature throughout the codebase, please, don't com +plaign about that element of my style. my $filename = $NODE->{title}; $filename =~ s/[^A-Za-z0-9.-]/_/g; $filename =~ s/__+/_/g; $filename .= '.pl';

    , perhaps?


    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 vote for $nodeid.pl. The node title is likely ambiguous, requires arbitrary scrubbing rules, and does not offer a reference back to the source node.

      Makeshifts last the longest.

      nodeid.pl ROCKS ... and incidentally, makes easy to find ones way back to the source.
      $filename =~ s/__+/_/g;
      $filename =~ y/_//s;
      Why not append a comment on the last line giving the node id the code was pulled from? For jerks like me who wind up copying files about and renaming a lot. Just an idea...

      Update: After chat in CB, found out it'll fubar either the she-bang line and/or some obfu. grrr

      ----
      Then B.I. said, "Hov' remind yourself nobody built like you, you designed yourself"

Re: Displaycode suggestion
by theorbtwo (Prior) on Nov 26, 2004 at 11:44 UTC

    Done. We now send a Content-Disposition: inline; filename="NNNN.pl" header. (Note that IE will try to save to NNNN_pl.txt if you do not have an association set up, or ignore the inline bit and try to save immediately if you do not. I think we have to agree to live with that.) Thanks for the suggestion, Original Anonymonk.


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

      Adding a timestamp to the filename title would seem to be a good idea. Ideally the last update time of the node.

      ---
      demerphq

      Wow that was fast :). Cool! :) By the way, do you maintain a dev/acc/production separate environments or do the changes to code go in right away?

        There is a sepperate test server, but minor changes are applied directly to the main server sometimes. (Possibly more often then they should be.)


        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: Displaycode suggestion
by ww (Archbishop) on Nov 25, 2004 at 18:04 UTC
    Might save you a few keystrokes...

    BUT!

    if the author has used a name which you've already used, you still have the keystrokes to do... or fall into a dialogue for
    overwrite | rename | whatever

    which some tired|careless users might miss | ignore to their detriment?