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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |