Skip to content

Commit

Permalink
Item347: Rebranding SpreadSheetPlugin
Browse files Browse the repository at this point in the history
It already worked in compatibility mode so it was about time to rebrand it


git-svn-id: http://svn.foswiki.org/trunk@1071 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
KennethLavrsen authored and KennethLavrsen committed Nov 30, 2008
1 parent f583af9 commit 8b78a50
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 42 deletions.
20 changes: 10 additions & 10 deletions ...etPlugin/data/TWiki/SpreadSheetPlugin.txt → ...tPlugin/data/System/SpreadSheetPlugin.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%META:TOPICINFO{author="PeterThoeny" date="1192240197" format="1.0" version="1.56"}%
---+!! TWiki Spreadsheet Plugin
---+!! Foswiki Spreadsheet Plugin

This Plugin adds spreadsheet capabilities to %WIKITOOLNAME% topics. Formulae like ==%<nop>CALC{"$INT(7/3)"}%== are evaluated at page view time. They can be placed in table cells and outside of tables. In other words, this Plugin provides general formula evaluation capability, not just classic spreadsheet functions.

Expand Down Expand Up @@ -685,7 +685,7 @@ Plugin settings are stored as [[%SYSTEMWEB%.PreferenceSettings][preference setti
a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>SPREADSHEETPLUGIN_SHORTDESCRIPTION%==

* One line description, is shown in the %SYSTEMWEB%.TextFormattingRules topic:
* Set SHORTDESCRIPTION = Add spreadsheet calculation like ="$SUM( $ABOVE() )"= to TWiki tables and other topic text
* Set SHORTDESCRIPTION = Add spreadsheet calculation like ="$SUM( $ABOVE() )"= to Foswiki tables and other topic text

* Debug plugin: (See output in =data/debug.txt=)
* Set DEBUG = 0
Expand All @@ -701,21 +701,21 @@ a plugin setting write ==%<nop>&lt;plugin&gt;_&lt;setting&gt;%==, i.e. ==%<nop>S

---++ Plugin Installation Instructions

__Note:__ You do not need to install anything on the browser to use this plugin. Below installation instructions are for the administrator who needs to install this plugin on the TWiki server.
__Note:__ You do not need to install anything on the browser to use this plugin. Below installation instructions are for the administrator who needs to install this plugin on the Foswiki server.

* Download the ZIP file from the <nop>%TOPIC% home
* Unzip ==SpreadSheetPlugin.zip== in your twiki installation directory. Content:
| *File:* | *Description:* |
| ==data/System/%TOPIC%.txt== | Plugin topic |
| ==data/System/%TOPIC%.txt,v== | Plugin topic repository |
| ==lib/Foswiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
* TWiki 4 and up: Visit =configure= in your TWiki installation, and enable the Plugin in the {Plugins} section.
* Visit =configure= in your Foswiki installation, and enable the Plugin in the {Plugins} section.
* Test if the "Total" in the first table in this topic is correct.

---++ Plugin Info

| Plugin Author: | TWiki:Main/PeterThoeny |
| Copyright: | &copy; 2001-2007, Peter Thoeny, [[http://www.twiki.net/][TWIKI.NET]] |
| Copyright: | &copy; 2001-2007, Peter Thoeny, [[http://www.twiki.net/][TWIKI.NET]]; &copy; 2008 Foswiki Contributors |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Plugin Version: | 13 Oct 2007 (15270) |
| Change History: | <!-- specify latest version first -->&nbsp; |
Expand All @@ -726,23 +726,23 @@ __Note:__ You do not need to install anything on the browser to use this plugin.
| 11 Mar 2007: | Fixing bug in $VALUE() and $INT(), introduced by version 09 Mar 2007 |
| 09 Mar 2007: | Added $EXP(), $LN(), $LOG(), $PI(), $SQRT(); fixed $ROUND() bug, contributed by TWiki:Main/SergejZnamenskij |
| 23 Jan 2007: | Enhanced documentation |
| 18 Dec 2006: | Added $LISTRAND(), $LISTSHUFFLE(), $LISTTRUNCATE(); fixed spurious newline at end of topic, contributed by TWiki:Main/MichaelDaum |
| 18 Dec 2006: | Added $LISTRAND(), $LISTSHUFFLE(), $LISTTRUNCATE(); fixed spurious newline at end of topic, contributed by Foswiki:Main/MichaelDaum |
| 10 Oct 2006: | Enhanced documentation |
| 13 May 2006: | Added $SETIFEMPTY(); fixes in documentation |
| 17 Jun 2005: | Added $NOEXEC(), $EXEC() |
| 25 Mar 2005: | Fixed evaluation bug when using <nop>SpeedyCGI accelerator; code refactor to load module only when needed, contributed by TWiki:Main/CrawfordCurrie |
| 25 Mar 2005: | Fixed evaluation bug when using <nop>SpeedyCGI accelerator; code refactor to load module only when needed, contributed by Foswiki:Main/CrawfordCurrie |
| 24 Oct 2004: | Added $EXISTS(), contributed by TWiki:Main/RodrigoChandia; added $PERCENTILE() |
| 18 Oct 2004: | Added $LISTJOIN() |
| 26 Sep 2004: | Added $FORMAT(KB), $FORMAT(MB), contributed by TWiki:Main/ArthurClemens; added $FORMAT(KBMB), $EVEN(), $ODD() |
| 17 Jul 2004: | Added $WORKINGDAYS(), contributed by TWiki:Main/CrawfordCurrie |
| 26 Sep 2004: | Added $FORMAT(KB), $FORMAT(MB), contributed by Foswiki:Main/ArthurClemens; added $FORMAT(KBMB), $EVEN(), $ODD() |
| 17 Jul 2004: | Added $WORKINGDAYS(), contributed by Foswiki:Main/CrawfordCurrie |
| 24 May 2004: | Refactored documentation (no code changes) |
| 03 Apr 2004: | Added $ABS(), $LISTIF(); fixed $VALUE() to remove leading zeros; changed $FIND() and $SEARCH() to return 0 instead of empty string if no match |
| 21 Mar 2004: | Added $LISTITEM(); fixed call to unofficial function |
| 16 Mar 2004: | Added $LISTMAP(), $LISTREVERSE(), $LISTSIZE(), $LISTSORT(), $LISTUNIQUE(), $SETM(); retired $COUNTUNIQUE() in favor of $COUNTITEMS($LISTUNIQUE()); fixed evaluation order issue of $IF(); fixed missing eval error messages suppressed since version 06 Mar 2004; redirect stderr messages to warning |
| 08 Mar 2004: | Added $LIST() |
| 06 Mar 2004: | Added $AND(), $MOD(), $NOT(), $OR(), $PRODUCT(), $PROPER(), $PROPERSPACE(), $RAND(), $REPEAT(), $SIGN(), $VALUE(); added digits parameter to $ROUND(); renamed $MULT() to $PRODUCT(); $MULT() is deprecated and undocumented |
| 27 Feb 2004: | Added $COUNTUNIQUE() |
| 24 Oct 2003: | Added $SET(), $GET(), $MEDIAN(); added $SUMPRODUCT(), inspired by TWiki:Main/RobertWithrow; added $SUMDAYS(), contributed by TWiki:Main/SvenDowideit |
| 24 Oct 2003: | Added $SET(), $GET(), $MEDIAN(); added $SUMPRODUCT(), inspired by TWiki:Main/RobertWithrow; added $SUMDAYS(), contributed by Foswiki:Main/SvenDowideit |
| 21 Oct 2003: | Added support for lists =(1, 2, 3)= and lists of table ranges =(R1:C1..R1:C5, R3:C1..R3:C5)= for all functions that accept a table range; added $TIMEADD(); in $TIMEDIFF() added week unit; in $FORMATTIME() changed $weekday to $wd and added $wday and $weekday |
| 14 Oct 2003: | Added $TIME(), $TODAY(), $FORMATTIME(), $FORMATGMTIME(), $TIMEDIFF() |
| 13 Oct 2003: | Added $MULT(), contributed by TWiki:Main/GerritJanBaarda |
Expand Down
File renamed without changes.
27 changes: 14 additions & 13 deletions ...in/lib/TWiki/Plugins/SpreadSheetPlugin.pm → .../lib/Foswiki/Plugins/SpreadSheetPlugin.pm
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2001-2007 Peter Thoeny, peter@thoeny.org
# Copyright (C) 2008 Foswiki Contributors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -18,26 +19,26 @@
#
# =========================
#
# This is TWiki's Spreadsheet Plugin.
# This is Foswiki's Spreadsheet Plugin.
#

package TWiki::Plugins::SpreadSheetPlugin;
package Foswiki::Plugins::SpreadSheetPlugin;


# =========================
use vars qw(
$web $topic $user $installWeb $VERSION $RELEASE $debug $skipInclude $doInit
);

# This should always be $Rev: 13748 $ so that TWiki can determine the checked-in
# This should always be $Rev: 13748 $ so that Foswiki can determine the checked-in
# status of the plugin. It is used by the build automation tools, so
# you should leave it alone.
$VERSION = '$Rev: 13748 $';

# This is a free-form string you can use to "name" your own plugin version.
# It is *not* used by the build automation tools, but is reported as part
# of the version number in PLUGINDESCRIPTIONS.
$RELEASE = 'any TWiki';
$RELEASE = 'Foswiki';

$doInit = 0;

Expand All @@ -47,19 +48,19 @@ sub initPlugin
( $topic, $web, $user, $installWeb ) = @_;

# check for Plugins.pm versions
if( $TWiki::Plugins::VERSION < 1 ) {
TWiki::Func::writeWarning( "Version mismatch between SpreadSheetPlugin and Plugins.pm" );
if( $Foswiki::Plugins::VERSION < 1 ) {
Foswiki::Func::writeWarning( "Version mismatch between SpreadSheetPlugin and Plugins.pm" );
return 0;
}

# Get plugin debug flag
$debug = TWiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_DEBUG" );
$debug = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_DEBUG" );

# Flag to skip calc if in include
$skipInclude = TWiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_SKIPINCLUDE" );
$skipInclude = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_SKIPINCLUDE" );

# Plugin correctly initialized
TWiki::Func::writeDebug( "- TWiki::Plugins::SpreadSheetPlugin::initPlugin( $web.$topic ) is OK" ) if $debug;
Foswiki::Func::writeDebug( "- Foswiki::Plugins::SpreadSheetPlugin::initPlugin( $web.$topic ) is OK" ) if $debug;
$doInit = 1;
return 1;
}
Expand All @@ -69,7 +70,7 @@ sub commonTagsHandler
{
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead

TWiki::Func::writeDebug( "- SpreadSheetPlugin::commonTagsHandler( $_[2].$_[1] )" ) if $debug;
Foswiki::Func::writeDebug( "- SpreadSheetPlugin::commonTagsHandler( $_[2].$_[1] )" ) if $debug;

if( ( $_[3] ) && ( $skipInclude ) ) {
# bail out, handler called from an %INCLUDE{}%
Expand All @@ -80,13 +81,13 @@ sub commonTagsHandler
return;
}

require TWiki::Plugins::SpreadSheetPlugin::Calc;
require Foswiki::Plugins::SpreadSheetPlugin::Calc;

if( $doInit ) {
$doInit = 0;
TWiki::Plugins::SpreadSheetPlugin::Calc::init( $web, $topic, $debug );
Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web, $topic, $debug );
}
TWiki::Plugins::SpreadSheetPlugin::Calc::CALC( @_ );
Foswiki::Plugins::SpreadSheetPlugin::Calc::CALC( @_ );
}

1;
Expand Down
27 changes: 14 additions & 13 deletions ...b/TWiki/Plugins/SpreadSheetPlugin/Calc.pm → ...Foswiki/Plugins/SpreadSheetPlugin/Calc.pm
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2001-2007 Peter Thoeny, peter@thoeny.org
# Copyright (C) 2008 Foswiki Contributors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -18,13 +19,13 @@
#
# =========================
#
# This is part of TWiki's Spreadsheet Plugin.
# This is part of Foswiki's Spreadsheet Plugin.
#
# The code below is kept out of the main plugin module for
# performance reasons, so it doesn't get compiled until it
# is actually used.

package TWiki::Plugins::SpreadSheetPlugin::Calc;
package Foswiki::Plugins::SpreadSheetPlugin::Calc;

use strict;
use Time::Local;
Expand Down Expand Up @@ -57,7 +58,7 @@ sub init
$dontSpaceRE = "";

# Module initialized
TWiki::Func::writeDebug( "- TWiki::Plugins::SpreadSheetPlugin::Calc::init( $web.$topic )" ) if $debug;
Foswiki::Func::writeDebug( "- Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web.$topic )" ) if $debug;
return 1;
}

Expand All @@ -66,7 +67,7 @@ sub CALC
{
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead

TWiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::CALC( $_[2].$_[1] )" ) if $debug;
Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::CALC( $_[2].$_[1] )" ) if $debug;

@tableMatrix = ();
$cPos = -1;
Expand Down Expand Up @@ -132,7 +133,7 @@ sub CALC
sub doCalc
{
my( $theAttributes ) = @_;
my $text = &TWiki::Func::extractNameValuePair( $theAttributes );
my $text = &Foswiki::Func::extractNameValuePair( $theAttributes );

# Add nesting level to parenthesis,
# e.g. "A(B())" gets "A-esc-1(B-esc-2(-esc-2)-esc-1)"
Expand Down Expand Up @@ -170,7 +171,7 @@ sub doFunc
my( $theFunc, $theAttr ) = @_;

$theAttr = "" unless( defined $theAttr );
TWiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) start" ) if $debug;
Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) start" ) if $debug;

unless( $theFunc =~ /^(IF|LISTIF|LISTMAP|NOEXEC)$/ ) {
# Handle functions recursively
Expand Down Expand Up @@ -961,11 +962,11 @@ sub doFunc
$result = $theAttr;

} elsif ( $theFunc eq "EXISTS" ) {
$result = TWiki::Func::topicExists( $web, $theAttr );
$result = Foswiki::Func::topicExists( $web, $theAttr );
$result = 0 unless( $result );
}

TWiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) returns: $result" ) if $debug;
Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) returns: $result" ) if $debug;
return $result;
}

Expand Down Expand Up @@ -1029,7 +1030,7 @@ sub safeEvalPerl
$theText =~ /(.*)/;
$theText = $1; # untainted variable
return "" unless( $theText );
local $SIG{__DIE__} = sub { TWiki::Func::writeDebug($_[0]); warn $_[0] };
local $SIG{__DIE__} = sub { Foswiki::Func::writeDebug($_[0]); warn $_[0] };
my $result = eval $theText;
if( $@ ) {
$result = $@;
Expand Down Expand Up @@ -1139,7 +1140,7 @@ sub getTableRange
return @arr;
}

TWiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::getTableRange( $theAttr )" ) if $debug;
Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::getTableRange( $theAttr )" ) if $debug;
unless( $theAttr =~ /\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/ ) {
return @arr;
}
Expand Down Expand Up @@ -1167,7 +1168,7 @@ sub getTableRange
}
}
}
TWiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::getTableRange() returns @arr" ) if $debug;
Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::getTableRange() returns @arr" ) if $debug;
return @arr;
}

Expand Down Expand Up @@ -1248,8 +1249,8 @@ sub _properSpace
# FIXME: I18N

unless( $dontSpaceRE ) {
$dontSpaceRE = &TWiki::Func::getPreferencesValue( "DONTSPACE" ) ||
&TWiki::Func::getPreferencesValue( "SPREADSHEETPLUGIN_DONTSPACE" ) ||
$dontSpaceRE = &Foswiki::Func::getPreferencesValue( "DONTSPACE" ) ||
&Foswiki::Func::getPreferencesValue( "SPREADSHEETPLUGIN_DONTSPACE" ) ||
"UnlikelyGibberishWikiWord";
$dontSpaceRE =~ s/[^a-zA-Z0-9\,\s]//go;
$dontSpaceRE = "(" . join( "|", split( /[\,\s]+/, $dontSpaceRE ) ) . ")";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data/System/SpreadSheetPlugin.txt 0644
data/System/VarCALC.txt 0644
lib/Foswiki/Plugins/SpreadSheetPlugin.pm 0444
lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm 0444

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ sub setup_new_session() {
$query->path_info("/Main/WebHome");
$ENV{SCRIPT_NAME} = "view";

# close this TWiki session - its using the wrong mapper and login
# close this Foswiki session - its using the wrong mapper and login
$this->{twiki}->finish();
$this->{twiki} = new Foswiki( undef, $query );
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ $Foswiki::cfg{Plugins}{SmiliesPlugin}{Module} = 'Foswiki::Plugins::SmiliesPlugin
$Foswiki::cfg{Plugins}{CommentPlugin}{Enabled} = 1;
$Foswiki::cfg{Plugins}{CommentPlugin}{Module} = 'Foswiki::Plugins::CommentPlugin';
$Foswiki::cfg{Plugins}{SpreadSheetPlugin}{Enabled} = 1;
$Foswiki::cfg{Plugins}{SpreadSheetPlugin}{Module} = 'TWiki::Plugins::SpreadSheetPlugin';
$Foswiki::cfg{Plugins}{SpreadSheetPlugin}{Module} = 'Foswiki::Plugins::SpreadSheetPlugin';
$Foswiki::cfg{Plugins}{InterwikiPlugin}{Enabled} = 1;
$Foswiki::cfg{Plugins}{InterwikiPlugin}{Module} = 'Foswiki::Plugins::InterwikiPlugin';
$Foswiki::cfg{Plugins}{TablePlugin}{Enabled} = 1;
Expand Down

0 comments on commit 8b78a50

Please sign in to comment.