You are here: Foswiki>Tasks Web>Item12739 (05 Jul 2015, GeorgeClark)Edit Attach

Item12739: Add recent TWiki SpreadSheetPlugin features to Foswiki, and resolve "undefined" errors.

pencil
Priority: Enhancement
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Extension
Component: SpreadSheetPlugin
Branches: trunk master
Reported By: TimotheLitt
Waiting For:
Last Change By: GeorgeClark
I thought I'd quickly port in the Trash manager that I wrote on TWiki, but nothing is ever quick.

It relies on SpreadSheetPlugin, and the Foswiki version seems to have diverged - or at least, not kept up.

It relies on the triple-single quote string arguments, which aren't there.

Worse, the quoting rules in formatted search and other nesting seem to have gone astray - and the extra SPAN around ICON made that worse.

I've worked around this, but what should have been a quick conversion turned into a project.

You can pull EcoTrashManagerPlugin from TWiki's plugin page (or svn), and compare WebTrashManager.txt to the corresponding file here.

I claim that none of the changes should have been necessary for function (just the usual renames).

Also, note that the footer row in the tables under the first three tabs - the second column is centered under Foswiki, but left justified (as intended) under TWiki. (You need to have files in the Trash to see the tables.)

I get bunches of uninitialized value errors, which turn out to be from %CALCULATE. Lines 21 and 22 of = Foswiki::Plugins::SpreadSheetPlugin::Calc.pm= need to initialize $cPos and $rPos to -1 (indicating not in a table.)

 view: Use of uninitialized value $rPos in array element at /var/www/servers/foswiki/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm line 142., (and 139)

Foswiki::Func::saveTopic returns 1 on success - TWiki was documented to return undef in this case (as well as throw an exception on error, which Foswiki does). 1 looks like an error to careful callers of the TWiki API.

I was annoyed that the JQueryPlugin tab pane macros omit the JQ prefix here but have it there. Aliasing the JQ prefix would make conversion (and maintaining common sources) easier.

If you patch SpreadSheetPlugin and pseudo-install, you can play with the toy. Quick and dirty tests seem to show it works after the hacks - though the %TABLE problem is visually annoying.

Enjoy.

FWIW, I expect the other wiki to bundle this with their core as a standard plugin. Only (how many years over a decade) of user complaints?

-- TimotheLitt - 29 Jan 2014

Yea, SpreadSheetPlugin could need a bit of loving care. Though I wonder in how far your UI relies on it. Use of uninitialized values is never a good sign. These kind of things should be easily fixed.

On the JQueryPlugin divergence that you reported, well, TWiki added prefixes soon after the fork back in 2008 without a direct need for this change. Right now, both version of JQueryPlugin are massively different. The Foswiki TABPANE and BUTTON macros are basically the same names as there were back in July 2007. Lots of installs make use of it. So this can't be changed lighthearted without affecting backwards compatibility within Foswiki. I do share your concerns about cross project compatibility, which however we can't take care of infinitely. Actually we stopped looking at TWiki for quite some time now and just moved ahead. Which is good, imho, as I don't think some of the other's project development are particularly well thought out.

For now I'd suggest at least the following actions:

  • fix error warnings in SpreadSheetPlugin about use of uninitialized variables
  • review additional features added to the TWiki version and see in how far they make sense and are of sufficient quality to be included in the Foswiki version; note we had to diverge deliberately from the TWiki code in the past as it did not properly compute xor and the like
  • review in how far your UI realy realy needs the missing features in SpreadSheetPlugin; maybe simplifying things might be a good idea
  • remove all JQ prefixes on JQueryPlugin macros that are still part of the UI; this should be a sub-minute search and replace operation inside your plugin
  • review feature overlap of EcoTrashManagerPlugin / EcoTrashPlugin and TrashPlugin; the latter is a really simple plugin taking care of basic Trash housekeeping; it doesn't come with any specific UI though, just a REST handler that can be called from within a cron job or a button on the Trash WebHome to empty it according to the expiry constraints.

-- MichaelDaum - 30 Jan 2014

JQuery - I didn't know who changed the names (and I guess I don't really care). It would be trivial to alias them (so either name worked), but as you note (and I already did), yet another global search and replace made things work. Maybe something to add to twik2foswiki.

I also made my UI work - apparently - with SpreadSheetPlugin here. I just thought I'd note the issues. The most annoying wasn't a new function, it was the string argument triple quotuing that exists there but not here. It wasn't that hard to undo - but as this was buried in three levels of escapes (maybe four of varying flavors of sometimes escaped quotes), it seemed an unnecessary complication.

Hint: Someday a debug option that displays step-by-step variable expansion/parsing would go a long way to making writing wikicode easier.

Presumably you still want to be able to import applications from the other project. Besides the two outright bugs (Uninitialized variable in SpreadSheet and wrong justification in Table), I thought this would be an interesting example of where parsing changes broke something. But if compatibility is no longer a concern, so be it.

I'm not going to take on updating SpreadSheetPlugin. I've indicated the two lines with uninitialized variables that absolutely need to be fixed. Reviewing / merging other features is up to whoever maintains it here.

A description of the differences between the plugins is in the other item (I didn't mention there that yes, EcoTrashPlugin has a REST interface; that's an internal detail. Well, almost REST; it returns an HTML page rather than XML - but I don't have a use case for that.)

-- TimotheLitt - 30 Jan 2014

Setting this to Waiting for release. I've added a lot of the TWiki functions, but not all of them.

Added:

Not yet implemented in Foswiki:

  • FILTER - Filter out characters from a string. (Seems to duplicate REPLACE)
  • # GETHASH
  • # GETLIST - Get a saved list
  • # HASH2LIST - Convert hash to list
  • # HASHCOPY - Copy a hash
  • # HASHEACH - Evaluate & update each element
  • # HASHEXISTS - Test if hash exists
  • # HASHREVERSE - Swap keys and values
  • # ISDIGIT
  • # ISLOWER
  • # ISUPPER
  • # ISWIKIWORD
  • # LIST2HASH
  • # SETHASH - Set a hash for later use
  • # SETLIST - Save a list for later use
  • # SETMHASH - Modify a hash
  • # STDEV - Std. Deviation
  • # STDEVP - Std. Deviation population
  • # VAR - Variance sample
  • # VARP - Variance population

-- GeorgeClark - 12 Jan 2015

Reopening this because the TestCases/SpreadSheetPluginTests actually implements some of these which then fail. Adding
  • FILTER
  • ISDIGIT
  • ISUPPER
  • ISLOWER
  • ISWIKIWORD

-- GeorgeClark - 29 May 2015
 
Topic revision: r12 - 05 Jul 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy