feature description
to provide editting facilities on the preview page
whilst this is not
WYSIWYG, it does make it easier to corrolate and correct your source with the generated page because you can see both at the same time. this is a common feature supported by many (most?) other wikis engines.
implementation
i'm posting the changes i've made to my local installation in the hope that other people may find them useful.
--
WillNorris - 12 Aug 2004
templates
in order to support editting on the preview page, the following changes need to be made to a skin's preview template:
- add a
textarea
with a name of rawtext
- add a preview button
preview.tmpl
(add a preview button)
i had a more complete patch here, but twiki ate part of it and the rest of the page (text was chopped at a
textarea
tag); i'll attach the
sample preview template modifications instead
code changes
Index: UI.pm
===================================================================
RCS file: /home/cvs/cvsroot/projects/owiki/system/lib/Owiki/Attic/UI.pm,v
retrieving revision 1.1.2.5
diff -r1.1.2.5 UI.pm
2969c2969
< $qc->options(qw(topic skin submitChangeForm dontnotify cmd topicparent formtemplate text));
---
> $qc->options(qw(topic skin submitChangeForm dontnotify cmd topicparent formtemplate text rawtext));
2983a2984,3003
> my $rawText = $qc->{rawtext};
> if ( $rawText )
> {
> # if rawtext, show that in the preview instead of original text
> # (replacing the original text, it has been editted)
> $qc->{text} = $rawText;
> }
> else
> {
> # no rawtext; must be the first time into preview
> # (or, if this code ends up being (re)used more generally,
> # no rawtext field support on this page)
> $rawText = $qc->{text};
> }
>
> $rawText =~ s/&/&\;/go;
> $rawText =~ s/</<\;/go;
> $rawText =~ s/>/>\;/go;
> $rawText =~ s/\t/ /go;
>
3074a3095,3097
>
> # the raw edit text has to be (close to) the last substitution on the page
> $tmpl =~ s/%RAWTEXT%/$rawText/;
discussion