create new tag
, view all tags
NOTE: This is now a Plugin, see PowerEditPlugin, PowerEditPluginDev

PowerEditAddon Dev

Some time ago I developed a Java applet (see AppletBasedEditor) that provides some much-needed added functionality to the editor, such as macros, find, replace etc. I've updated this applet so it can be installed as an Addon BUT I don't want to submit it until we've cleared something up.

Because of the limitations of Java, I have a server script that acts as the target of all communications from the applet. This perl code is responsible for cacheing the topic text and then invoking 'preview' on the cached text. Obviously I want to re-use the existing 'preview' script code instead of copying it. Because preview is coded so it's only usable as a CGI script (taint checks on, &main, sub main defined, $query = new CGI) the script functionality is not available to another perl script (unless you know better).

At the moment I am (1) loading 'preview' into a variable (2) using s/// to edit off the bits I don't want (&main() and $query=new CGI) and (3) eval'ing the resulting edited script.

This is clearly horrible.

I can think of a couple of better ways to do this, but they require changes to the preview script. For example:

  • Support 'preview' of text held in a cache file (created by TWiki::Store::savePreview)
  • Split the 'preview' script into a 'CGI main' and a 'preview' module (implications for all the other scripts in bin, here)

Ideas, opinions?

-- CrawfordCurrie - 29 Sep 2001

Copy pasted to Codev.GettingTheBigPicture

-- HansDonner - 02 Oct 2001

Is there a reason for there being PowerEditAddonDev page but not PowerEditAddon? I have some installation-type feedback but am not sure where to put it, here? Somewhere in Support?

-- MattWilkie - 04 Oct 2001

There's now PowerEditAddon page because I don't want to release (unleash?) it yet, until the above question has had an airing. Please, add feedback here!

Oh, and I know the attached zip has problems (upper case directory names). WindowsME compressed folders are almost, but not quite, totally unusable for generating ZIPs! I have a fixed zip that I will update with this weekend.

-- CrawfordCurrie - 05 Oct 2001

Okay, here goes:

The zipfile extracts the PEA page to ./data/Plugins/PowerEditAddon.txt however the Plugins web does not exist in an out of the box 01Sept2001 twiki install. So you need to add instructions about copying ./data/_default/* to ./data/_Plugins/*.


./bin/view/Plugins/PowerEditAddon says

Add the following line to the "TWiki Addons" section of TextFormattingRules: 
      * PowerEditAddon: Power Editor Addon 

Should that be

      * Plugins.PowerEditAddon: Power Editor Addon
since the page for PEA gets installed to ./data/Plugins?


The next line says

The editor is invoked by putting the following line into your bin/view script, immediately after the line reading %EDITTOPIC%: 

I have four lines (200,212,219,223) which contain EDITTOPIC, all inside one code block which starts:

    if( $mirrorSiteName ) {
        # disable edit and attach
        $tmpl =~ s/%EDITTOPIC%/$mirrorLink | <strike>Edit<\/strike>/o;
Is that the right place?


I'm running TWiki 01Sept2001 on Cygwin.

-- MattWilkie - 26 Oct 2001

Thanks for the feedback, Matt. The Plugins web doesn't exist by default. The addon was implemented and documentation was created at a time before the Plugins topic template was available. At that time, it looked like documentation topics were to be placed in the "Plugins" web (seems logical to me). The template now suggests the TWiki web, which is created by default, so the action is to move the documentation topics to the TWiki web. This would also cure your second ailment.

The installation info, advising an edit of your bin/view script, is (of course) complete bollocks. I meant to say "templates/view.tmpl". Sorry for the confusion. What is intended is the addition of a new link for invoking the editor. Tip: if you want to do this in a way which isn't "in your face" to other users, create a skin. The simplest way to do this is to copy view.tmpl to view.power.tmpl and then use the url ...bin/view/MyWeb/MyPage?skin=power

I'm still looking for input from the core team on the question raised above... anyone?

-- CrawfordCurrie - 29 Oct 2001

No longer a fat CGI script, and I've added an HTML to Wiki Markup converter (using the sourceforge kizna HTML parser). Seems to work quite well. Update is attached, but I'm having a terrible time getting it all checked into CVS (machine keeps crashing when I run WinCVS)

-- CrawfordCurrie - 16 Feb 2003

Hello Crawford, I use TortoiseCVS</b without any trouble!
See also http://www.tortoisecvs.org

-- MartinRaabe - 17 Feb 2003

See also FatCgiScripts


Do I miss something, or does it not work on the 10-Dec-2002 version ? The applet starts up smile but shows not the topic's content but the following text frown :

Content-type: text/html

<H1>Software error:</H1>
<PRE>Undefined subroutine &amp;TWiki::Store::savePreview called at /data/intranet/twiki/bin/poweredit line 105.
For help, please send mail to the webmaster (<a href="mailto:root@einSTein.local">root@einSTein.local</a>), giving this error message 
and the time and date of the error.

and there is indeed no TWiki::Store::savePreview !

SvenTissot - 18 Feb 2003

I had similar input from RonKellam - here's his input for reference:

I'd just downloaded and installed your latest PowerEditAddon into a recent release of TWiki (around Feb 2003) - not sure of the official release name.

Aside from having to shuffle a few files to different directories (as discussed in Plugins/PowerEditAddonDev), the major snag I've hit is poweredit.pm's usage of Store::savePreview(), and readRemovePreview().

It seems that these functions were deleted from Store.pm in rev 1.47 on 20 Mar 2002 - 11 months ago. I don't know why.

Repatching them back into Store.pm got me a bit further, but then I ran into lock problems when I invoked a PowerEdit. Overriding the lock mechanism got me to into the editor, but I don't really want to work without locking. That's about where I've stopped...

and my response:

I have to test against the Dec2001 wiki, because I don't have a more recent installation. It's bad news about the preview functions being deleted, I can only hope there's an alternative. I really don't like using functions like this but the brain-dead Func interface is no alternative.

Because the invocation script is just the normal 'edit' script, the locking should be the same as usual. I put in a check in the 'poweredit' server script to try to increase security which is probably causing the problem. If you look into 'poweredit' you will see where it checks the identity of the client user against the lock file. Try commenting out this check. The only reason for the check is to try to ensure that a footpad can't simply use a poweredit url to get the raw topic text.

I need to grab a more recent release and check out what happened to the really useful preview functions. I'll also have a look at the lock problem. For the nonce, you can use the HTML2TWiki converter from the command line; there's a main program in the jar. If you java -cp <dir where jar is>/poweredit.jar com.ccsoft.edit.HTML2TWiki <HTML file to read> it should spit out the converted text.

-- CrawfordCurrie - 18 Feb 2003

OK, now works with latest release. I've also added programmable keys, and improved the HTML conversion to a point where it's really quite useable. I've updated the attached zip.

Feedback is welcome; please try it out. If it's good enough, I plan to (finally) release this version.

-- CrawfordCurrie - 02 Mar 2003

Recoded as a Plugin - see PowerEditPluginDev

-- CrawfordCurrie - 15 Mar 2003

Topic attachments
I Attachment History Action Size Date Who Comment
Compressed Zip archivezip PowerEditAddon.zip r4 r3 r2 r1 manage 220.1 K 2003-03-02 - 16:01 CrawfordCurrie Tested with 1/2003 release
Edit | Attach | Watch | Print version | History: r19 < r18 < r17 < r16 < r15 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r19 - 2004-01-28 - GrahamNorth
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.