demerphq, thanks for the patches. I wanted to comment on them here so the comments would be public.

I think what you've got is a pretty good start. In previous discussions (such as Re^2: formatting spoilers (not perfect)) other ideas were brought up that I think are worth including.

First, I'd factor out the 3 copies of identical (I believe) code so we can make improvements easily.

The basic method you chose is the correct one, IMO, including where in the process you process them (after CODE tags but before HTML filtering):

my $spoiler_pat = $VARS->{spoiler_pat}|| "<table><tr><td bgcolor='#000000'><font color='#000000'>". "%TEXT%". "</font></td></tr></table>"; while ( $text =~ m{<spoiler>(.*?)</spoiler>} ) { (my $repl = $spoiler_pat) =~ s/%TEXT%/$1/; $text =~ s{<spoiler>(.*?)</spoiler>}{$repl}; }

I wasn't fond of the %TEXT% magic string but I've since worked out how to make it not a problem, IMO (see below).

I'd like to have a few predefined choices like:

I'm not saying all of this needs to be implemented before you apply any patches. But I'd like the path for this design worked out well enough that patches that get applied won't be likely to get in the way of such an eventual solution (or something better based on discussions).

BTW, I'd like user settings to mostly become a set of links to other pages that aren't so huge, so I'd put this on a separate page, perhaps will other "node display" settings like text depth and "disable readmore" (maybe also CODE tags settings).

So, how to best implement the interface and the mechanism?

After bouncing around a few ideas, I think I'd have a form with a drop-down list of standard types and a field for filling in either a non-default color (for the TABLE method), non-default text to preface the spoiler (for DIV), or non-default text to use for the link that reveals the spoiler (for HTML comment and "omit")? These would populate the template and then the user could customize that (or just fill in the template directly). The settings page should show a sample spoiler. Spoilers would default to TABLE method for new users. Update: Actually, "link and omit" should be the default, as it would even work on my cell phone.

So the code to factor out would be nearly identical to what you wrote, except that it would simply remove the spoiler tags if $q->param("spoil") was set and it needs a way to fill in the current node ID for making the link with ;spoil=1 added.

Comments?

- tye        


In reply to Re^2: black tags (patches) by tye
in thread black tags by cog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.